mirror of
https://github.com/trycua/computer.git
synced 2026-05-12 11:29:41 -05:00
added message when scalable oai endpoint is still warming up
This commit is contained in:
@@ -190,25 +190,21 @@ class OAICompatClient(BaseUITarsClient):
|
||||
response_text = await response.text()
|
||||
logger.debug(f"Response content: {response_text}")
|
||||
|
||||
# if 503, then the endpoint is still warming up
|
||||
if response.status == 503:
|
||||
logger.error(f"Endpoint is still warming up, please try again later")
|
||||
raise Exception(f"Endpoint is still warming up: {response_text}")
|
||||
|
||||
# Try to parse as JSON if the content type is appropriate
|
||||
if "application/json" in response.headers.get('Content-Type', ''):
|
||||
response_json = await response.json()
|
||||
else:
|
||||
raise Exception(f"Response is not JSON format")
|
||||
# # Optionally try to parse it anyway
|
||||
# try:
|
||||
# import json
|
||||
# response_json = json.loads(response_text)
|
||||
# except json.JSONDecodeError as e:
|
||||
# print(f"Failed to parse response as JSON: {e}")
|
||||
|
||||
if response.status != 200:
|
||||
error_msg = response_json.get("error", {}).get(
|
||||
"message", str(response_json)
|
||||
)
|
||||
logger.error(f"Error in API call: {error_msg}")
|
||||
raise Exception(f"API error: {error_msg}")
|
||||
|
||||
logger.error(f"Error in API call: {response_text}")
|
||||
raise Exception(f"API error: {response_text}")
|
||||
|
||||
return response_json
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user