mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-13 21:02:46 +08:00
v1.2.3 fix bugs
This commit is contained in:
parent
9093c4eac3
commit
c469ee32fb
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.2.2
|
||||
type=raw,value=v1.2.3
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user