From eeae387679e29204b3656c8f3d3b6cb151a120eb Mon Sep 17 00:00:00 2001 From: BioBootloader Date: Sun, 31 Mar 2024 17:06:28 -0700 Subject: [PATCH] convert spice error --- mentat/llm_api_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mentat/llm_api_handler.py b/mentat/llm_api_handler.py index d593f11ef..cee189c22 100644 --- a/mentat/llm_api_handler.py +++ b/mentat/llm_api_handler.py @@ -30,7 +30,7 @@ ) from openai.types.chat.completion_create_params import ResponseFormat from PIL import Image -from spice import APIConnectionError, Spice, SpiceEmbeddings, SpiceResponse, SpiceWhisper +from spice import APIConnectionError, Spice, SpiceEmbeddings, SpiceError, SpiceResponse, SpiceWhisper from mentat.errors import MentatError, ReturnToUser from mentat.session_context import SESSION_CONTEXT @@ -69,6 +69,8 @@ async def async_wrapper(*args: Any, **kwargs: Any) -> Any: return await func(*args, **kwargs) except APIConnectionError: raise MentatError("API connection error: please check your internet connection and" " try again.") + except SpiceError as e: + raise MentatError(f"API error: {e}") return async_wrapper else: @@ -79,6 +81,8 @@ def sync_wrapper(*args: Any, **kwargs: Any) -> Any: return func(*args, **kwargs) except APIConnectionError: raise MentatError("API connection error: please check your internet connection and" " try again.") + except SpiceError as e: + raise MentatError(f"API error: {e}") return sync_wrapper