mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-30 22:57:45 +02:00
Handle tool errors in display properly (can show valueError
to user) (#2481)
* handle tool errors in display properly (can show valueerrors to user) * update for clarity
This commit is contained in:
@@ -745,10 +745,18 @@ def stream_chat_message_objects(
|
||||
tool_result = packet
|
||||
yield cast(ChatPacket, packet)
|
||||
logger.debug("Reached end of stream")
|
||||
except Exception as e:
|
||||
error_msg = str(e)
|
||||
logger.exception(f"Failed to process chat message: {error_msg}")
|
||||
except ValueError as e:
|
||||
logger.exception("Failed to process chat message.")
|
||||
|
||||
error_msg = str(e)
|
||||
yield StreamingError(error=error_msg)
|
||||
db_session.rollback()
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
logger.exception("Failed to process chat message.")
|
||||
|
||||
error_msg = str(e)
|
||||
stack_trace = traceback.format_exc()
|
||||
client_error_msg = litellm_exception_to_error_msg(e, llm)
|
||||
if llm.config.api_key and len(llm.config.api_key) > 2:
|
||||
|
@@ -200,6 +200,7 @@ class ImageGenerationTool(Tool):
|
||||
revised_prompt=response.data[0]["revised_prompt"],
|
||||
url=response.data[0]["url"],
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.debug(f"Error occured during image generation: {e}")
|
||||
|
||||
|
Reference in New Issue
Block a user