🐛 fix(manager.py): change default value of chat_inputs from empty string to empty dictionary to improve data consistency and prevent potential errors

🐛 fix(utils.py): handle case when chat_inputs.message is None by assigning an empty dictionary to it to prevent potential errors
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-07 18:37:49 -03:00
commit 9ee76fd18f
2 changed files with 3 additions and 3 deletions

View file

@ -117,7 +117,7 @@ class ChatManager:
self, client_id: str, payload: Dict, langchain_object: Any
):
# Process the graph data and chat message
chat_inputs = payload.pop("inputs", "")
chat_inputs = payload.pop("inputs", {})
chat_inputs = ChatMessage(message=chat_inputs)
self.chat_history.add_message(client_id, chat_inputs)

View file

@ -21,9 +21,9 @@ async def process_graph(
# Generate result and thought
try:
if not chat_inputs.message:
if chat_inputs.message is None:
logger.debug("No message provided")
raise ValueError("No message provided")
chat_inputs.message = {}
logger.debug("Generating result and thought")
result, intermediate_steps = await get_result_and_steps(