Skip to content

Commit

Permalink
convert spice error
Browse files Browse the repository at this point in the history
  • Loading branch information
biobootloader committed Apr 1, 2024
1 parent 528e2b9 commit eeae387
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mentat/llm_api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down

0 comments on commit eeae387

Please sign in to comment.