diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index 457bc3f..157f9f9 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.2.2 + type=raw,value=v1.2.3 - name: Build and push uses: docker/build-push-action@v5 diff --git a/README.md b/README.md index 144844d..175d51f 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ ## 功能 -### 最新版 v1.2.2 +### 最新版 v1.2.3 > 已完成 > - [x] 流式、非流式传输 diff --git a/chatgpt/ChatService.py b/chatgpt/ChatService.py index dcd09c6..d1624c7 100644 --- a/chatgpt/ChatService.py +++ b/chatgpt/ChatService.py @@ -65,7 +65,11 @@ class ChatService: self.s = Client(proxy=self.proxy_url) self.ws = None - self.wss_mode, self.wss_url = await token2wss(self.req_token) + if conversation_only: + self.wss_mode = False + self.wss_url = None + else: + self.wss_mode, self.wss_url = await token2wss(self.req_token) self.oai_device_id = str(uuid.uuid4()) self.persona = None @@ -287,12 +291,11 @@ class ChatService: async def send_conversation(self): try: - subprotocols = ["json.reliable.webpubsub.azure.v1"] try: if self.wss_mode: if not self.wss_url: self.wss_url = await self.get_wss_url() - self.ws = await websockets.connect(self.wss_url, ping_interval=None, subprotocols=subprotocols) + self.ws = await websockets.connect(self.wss_url, ping_interval=None, subprotocols=["json.reliable.webpubsub.azure.v1"]) except Exception as e: logger.error(f"Failed to connect to wss: {str(e)}", ) raise HTTPException(status_code=502, detail="Failed to connect to wss") @@ -308,10 +311,13 @@ class ChatService: check_is_limit(detail, token=self.req_token, model=self.req_model) else: if "cf-please-wait" in rtext: + logger.error(f"Failed to send conversation: cf-please-wait") raise HTTPException(status_code=r.status_code, detail="cf-please-wait") if r.status_code == 429: + logger.error(f"Failed to send conversation: rate-limit") raise HTTPException(status_code=r.status_code, detail="rate-limit") detail = r.text[:100] + logger.error(f"Failed to send conversation: {detail}") raise HTTPException(status_code=r.status_code, detail=detail) content_type = r.headers.get("Content-Type", "") @@ -332,7 +338,7 @@ class ChatService: logger.info(f"next wss_url: {self.wss_url}") if not self.ws: try: - self.ws = await websockets.connect(self.wss_url, ping_interval=None, subprotocols=subprotocols) + self.ws = await websockets.connect(self.wss_url, ping_interval=None, subprotocols=["json.reliable.webpubsub.azure.v1"]) except Exception as e: logger.error(f"Failed to connect to wss: {str(e)}", ) raise HTTPException(status_code=502, detail="Failed to connect to wss") diff --git a/utils/config.py b/utils/config.py index 17944bb..8c322e9 100644 --- a/utils/config.py +++ b/utils/config.py @@ -42,7 +42,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.2.2 | https://github.com/lanqian528/chat2api") +logger.info("Chat2Api v1.2.3 | https://github.com/lanqian528/chat2api") logger.info("-" * 60) logger.info("Environment variables:") logger.info("API_PREFIX: " + str(api_prefix))