From 228b8e855c579869e22a94a9f3933755ef067b3f Mon Sep 17 00:00:00 2001 From: amanape <83104063+amanape@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:33:51 +0400 Subject: [PATCH] Handle case of incorrect model --- openhands/controller/agent_controller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openhands/controller/agent_controller.py b/openhands/controller/agent_controller.py index 7b7522e33a6..9c485b5c0d3 100644 --- a/openhands/controller/agent_controller.py +++ b/openhands/controller/agent_controller.py @@ -144,8 +144,11 @@ async def report_error(self, message: str, exception: Exception | None = None): if exception: self.state.last_error += f': {exception}' detail = str(exception) if exception is not None else '' + if exception is not None and isinstance(exception, litellm.AuthenticationError): detail = 'Please check your credentials. Is your API key correct?' + if exception is not None and isinstance(exception, litellm.NotFoundError): + detail = 'The current selected model does not exist or you do not have access to it' self.event_stream.add_event( ErrorObservation(f'{message}:{detail}'), EventSource.USER )