From 77084737dd530e45b850618da779cafbaa4bdce4 Mon Sep 17 00:00:00 2001 From: alpha-nerd-nomyo Date: Tue, 3 Feb 2026 15:51:13 +0100 Subject: [PATCH] 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. --- nomyo/SecureCompletionClient.py | 7 ++++++- nomyo/nomyo.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nomyo/SecureCompletionClient.py b/nomyo/SecureCompletionClient.py index e157482..790d97d 100644 --- a/nomyo/SecureCompletionClient.py +++ b/nomyo/SecureCompletionClient.py @@ -754,8 +754,13 @@ class SecureCompletionClient: else: # 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( - f"Unexpected status code: {response.status_code}", + f"Unexpected status code: {response.status_code} {unexp_detail['detail']}", status_code=response.status_code ) diff --git a/nomyo/nomyo.py b/nomyo/nomyo.py index 59a61d3..b92d6b2 100644 --- a/nomyo/nomyo.py +++ b/nomyo/nomyo.py @@ -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.