🐛 fix(chat.py): handle case when artifacts is empty to prevent potential error

The code now handles the case when the `artifacts` variable is empty by setting `input_keys_response` to an empty dictionary. This prevents potential errors that could occur when trying to build the `input_keys_response` object.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-05 20:06:27 -03:00
commit 605f7cecb2

View file

@ -160,7 +160,13 @@ async def stream_build(flow_id: str):
input_keys_response = build_input_keys_response(
langchain_object, artifacts
)
yield str(StreamData(event="message", data=input_keys_response))
else:
input_keys_response = {
"input_keys": {},
"memory_keys": [],
"handle_keys": [],
}
yield str(StreamData(event="message", data=input_keys_response))
chat_manager.set_cache(flow_id, langchain_object)
# We need to reset the chat history