fix: improve error handling and update base URL for SecureCompletionClient

Enhanced error message handling in SecureCompletionClient to provide more detailed information when unexpected status codes occur. The base URL for SecureChatCompletion has been updated.
This commit is contained in:
Alpha Nerd 2026-02-03 15:51:13 +01:00
parent 5641a746b7
commit 77084737dd
2 changed files with 7 additions and 2 deletions

View file

@ -754,8 +754,13 @@ class SecureCompletionClient:
else: else:
# Unexpected status code # Unexpected status code
unexp_detail = response.json()
if not isinstance(unexp_detail, dict):
unexp_detail = {"detail": "unknown"}
if isinstance(unexp_detail, dict) and "detail" not in unexp_detail.keys():
unexp_detail["detail"] = "unknown"
raise APIError( raise APIError(
f"Unexpected status code: {response.status_code}", f"Unexpected status code: {response.status_code} {unexp_detail['detail']}",
status_code=response.status_code status_code=response.status_code
) )

View file

@ -50,7 +50,7 @@ class SecureChatCompletion:
``` ```
""" """
def __init__(self, base_url: str = "https://api.nomyo.ai:12434", allow_http: bool = False, api_key: Optional[str] = None, secure_memory: bool = True): def __init__(self, base_url: str = "https://api.nomyo.ai", allow_http: bool = False, api_key: Optional[str] = None, secure_memory: bool = True):
""" """
Initialize the secure chat completion client. Initialize the secure chat completion client.