mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 18:39:06 +08:00
fix: None type in cot assistant app (#2142)
This commit is contained in:
parent
c17baef172
commit
501caf0a69
@ -473,7 +473,7 @@ class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
|
|||||||
|
|
||||||
result = ''
|
result = ''
|
||||||
for scratchpad in agent_scratchpad:
|
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
|
return result
|
||||||
|
|
||||||
@ -543,7 +543,7 @@ class AssistantCotApplicationRunner(BaseAssistantApplicationRunner):
|
|||||||
# add assistant message
|
# add assistant message
|
||||||
if len(agent_scratchpad) > 0:
|
if len(agent_scratchpad) > 0:
|
||||||
prompt_messages.append(AssistantPromptMessage(
|
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
|
# add user message
|
||||||
|
@ -172,7 +172,6 @@ class AssistantFunctionCallApplicationRunner(BaseAssistantApplicationRunner):
|
|||||||
for tool_call_id, tool_call_name, tool_call_args in tool_calls:
|
for tool_call_id, tool_call_name, tool_call_args in tool_calls:
|
||||||
tool_instance = tool_instances.get(tool_call_name)
|
tool_instance = tool_instances.get(tool_call_name)
|
||||||
if not tool_instance:
|
if not tool_instance:
|
||||||
logger.error(f"failed to find tool instance: {tool_call_name}")
|
|
||||||
tool_response = {
|
tool_response = {
|
||||||
"tool_call_id": tool_call_id,
|
"tool_call_id": tool_call_id,
|
||||||
"tool_call_name": tool_call_name,
|
"tool_call_name": tool_call_name,
|
||||||
@ -220,7 +219,6 @@ class AssistantFunctionCallApplicationRunner(BaseAssistantApplicationRunner):
|
|||||||
|
|
||||||
if error_response:
|
if error_response:
|
||||||
observation = error_response
|
observation = error_response
|
||||||
logger.error(error_response)
|
|
||||||
tool_response = {
|
tool_response = {
|
||||||
"tool_call_id": tool_call_id,
|
"tool_call_id": tool_call_id,
|
||||||
"tool_call_name": tool_call_name,
|
"tool_call_name": tool_call_name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user