From 605f7cecb2b2af44f57573e16f464e24f54310ae Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 5 Jul 2023 20:06:27 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(chat.py):=20handle=20case=20?= =?UTF-8?q?when=20artifacts=20is=20empty=20to=20prevent=20potential=20erro?= =?UTF-8?q?r=20The=20code=20now=20handles=20the=20case=20when=20the=20`art?= =?UTF-8?q?ifacts`=20variable=20is=20empty=20by=20setting=20`input=5Fkeys?= =?UTF-8?q?=5Fresponse`=20to=20an=20empty=20dictionary.=20This=20prevents?= =?UTF-8?q?=20potential=20errors=20that=20could=20occur=20when=20trying=20?= =?UTF-8?q?to=20build=20the=20`input=5Fkeys=5Fresponse`=20object.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/chat.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/langflow/api/v1/chat.py b/src/backend/langflow/api/v1/chat.py index 2423d1431..164dd2dd5 100644 --- a/src/backend/langflow/api/v1/chat.py +++ b/src/backend/langflow/api/v1/chat.py @@ -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