From 8834e71a8c957dec83cbbcdaf137ef0ae9216a1f Mon Sep 17 00:00:00 2001 From: David Riccitelli Date: Wed, 17 Apr 2024 02:10:08 +0300 Subject: [PATCH] see #12874: provide the exception to the StreamChatErrorEvent (#12879) --- llama-index-core/llama_index/core/chat_engine/types.py | 4 ++-- .../llama_index/core/instrumentation/events/chat_engine.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/llama-index-core/llama_index/core/chat_engine/types.py b/llama-index-core/llama_index/core/chat_engine/types.py index f84a156627db9e..a987281f6181d7 100644 --- a/llama-index-core/llama_index/core/chat_engine/types.py +++ b/llama-index-core/llama_index/core/chat_engine/types.py @@ -175,7 +175,7 @@ def write_response_to_history( chat.message.content = final_text.strip() # final message memory.put(chat.message) except Exception as e: - dispatch_event(StreamChatErrorEvent()) + dispatch_event(StreamChatErrorEvent(exception=e)) if not raise_error: logger.warning( f"Encountered exception writing response to history: {e}" @@ -229,7 +229,7 @@ async def awrite_response_to_history( chat.message.content = final_text.strip() # final message memory.put(chat.message) except Exception as e: - dispatch_event(StreamChatErrorEvent()) + dispatch_event(StreamChatErrorEvent(exception=e)) logger.warning(f"Encountered exception writing response to history: {e}") dispatch_event(StreamChatEndEvent()) self._is_done = True diff --git a/llama-index-core/llama_index/core/instrumentation/events/chat_engine.py b/llama-index-core/llama_index/core/instrumentation/events/chat_engine.py index fb9e9091bbc32d..b7170a9a11bbe6 100644 --- a/llama-index-core/llama_index/core/instrumentation/events/chat_engine.py +++ b/llama-index-core/llama_index/core/instrumentation/events/chat_engine.py @@ -16,6 +16,8 @@ def class_name(cls): class StreamChatErrorEvent(BaseEvent): + exception: Exception + @classmethod def class_name(cls): """Class name."""