mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-13 21:02:46 +08:00
Merge pull request #60 from yuanzhanghu/main
fixed the issue that websocket server closes connection when sequenceId reaches 1000.
This commit is contained in:
commit
550068ddec
2
.github/workflows/build_docker.yml
vendored
2
.github/workflows/build_docker.yml
vendored
@ -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
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
3. 接口返回的状态码和响应体
|
||||
|
||||
## 功能
|
||||
### 最新版 v1.1.10
|
||||
### 最新版 v1.1.11
|
||||
|
||||
> 已完成
|
||||
> - [x] 流式、非流式传输
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user