From 501caf0a69580cd27ad4c29350a70345a57e16d0 Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:59:09 +0800 Subject: [PATCH] fix: None type in cot assistant app (#2142) --- api/core/features/assistant_cot_runner.py | 4 ++-- api/core/features/assistant_fc_runner.py | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/api/core/features/assistant_cot_runner.py b/api/core/features/assistant_cot_runner.py index 130833c7b3..f2778a020c 100644 --- a/api/core/features/assistant_cot_runner.py +++ b/api/core/features/assistant_cot_runner.py @@ -473,7 +473,7 @@ class AssistantCotApplicationRunner(BaseAssistantApplicationRunner): result = '' for scratchpad in agent_scratchpad: - result += scratchpad.thought + next_iteration.replace("{{observation}}", scratchpad.observation) + "\n" + result += scratchpad.thought + next_iteration.replace("{{observation}}", scratchpad.observation or '') + "\n" return result @@ -543,7 +543,7 @@ class AssistantCotApplicationRunner(BaseAssistantApplicationRunner): # add assistant message if len(agent_scratchpad) > 0: prompt_messages.append(AssistantPromptMessage( - content=agent_scratchpad[-1].thought + "\n" + agent_scratchpad[-1].observation + content=(agent_scratchpad[-1].thought or '') + "\n" + (agent_scratchpad[-1].observation or '') )) # add user message diff --git a/api/core/features/assistant_fc_runner.py b/api/core/features/assistant_fc_runner.py index dfd59527d9..7f18607e1f 100644 --- a/api/core/features/assistant_fc_runner.py +++ b/api/core/features/assistant_fc_runner.py @@ -172,7 +172,6 @@ class AssistantFunctionCallApplicationRunner(BaseAssistantApplicationRunner): for tool_call_id, tool_call_name, tool_call_args in tool_calls: tool_instance = tool_instances.get(tool_call_name) if not tool_instance: - logger.error(f"failed to find tool instance: {tool_call_name}") tool_response = { "tool_call_id": tool_call_id, "tool_call_name": tool_call_name, @@ -220,7 +219,6 @@ class AssistantFunctionCallApplicationRunner(BaseAssistantApplicationRunner): if error_response: observation = error_response - logger.error(error_response) tool_response = { "tool_call_id": tool_call_id, "tool_call_name": tool_call_name,