diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index f0d7509..db3dbb7 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -37,7 +37,7 @@ jobs: images: lanqian528/chat2api tags: | type=raw,value=latest,enable={{is_default_branch}} - type=raw,value=v1.1.10 + type=raw,value=v1.1.11 - name: Build and push uses: docker/build-push-action@v5 diff --git a/README.md b/README.md index d0ecd3e..c35168c 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ 3. 接口返回的状态码和响应体 ## 功能 -### 最新版 v1.1.10 +### 最新版 v1.1.11 > 已完成 > - [x] 流式、非流式传输 diff --git a/chatgpt/chatFormat.py b/chatgpt/chatFormat.py index dc9d79c..5db68dc 100644 --- a/chatgpt/chatFormat.py +++ b/chatgpt/chatFormat.py @@ -77,6 +77,13 @@ async def wss_stream_response(websocket, conversation_id): data = resultObj.get("data", {}) if conversation_id != data.get("conversation_id", ""): continue + sequenceId = resultObj.get('sequenceId') + if sequenceId and sequenceId % 80 == 0: + await websocket.send( + json.dumps( + {"type": "sequenceAck", "sequenceId": sequenceId} + ) + ) decoded_bytes = pybase64.b64decode(data.get("body", None)) yield decoded_bytes else: @@ -87,6 +94,7 @@ async def wss_stream_response(websocket, conversation_id): except websockets.ConnectionClosed as e: if e.code == 1000: logger.error("WebSocket closed normally with code 1000 (OK)") + yield b"data: [DONE]\n\n" else: logger.error(f"WebSocket closed with error code {e.code}") except Exception as e: diff --git a/utils/config.py b/utils/config.py index cf35ae4..bd9e4a5 100644 --- a/utils/config.py +++ b/utils/config.py @@ -39,7 +39,7 @@ arkose_token_url_list = arkose_token_url.split(',') if arkose_token_url else [] proxy_url_list = proxy_url.split(',') if proxy_url else [] logger.info("-" * 60) -logger.info("Chat2Api v1.1.10 | https://github.com/lanqian528/chat2api") +logger.info("Chat2Api v1.1.11 | https://github.com/lanqian528/chat2api") logger.info("-" * 60) logger.info("Environment variables:") logger.info("API_PREFIX: " + str(api_prefix))