Merge pull request #26794

* [chore]: Agent Observation should be casted to string to avoid errors

* Merge branch 'master' into fix_observation_type_streaming

* [chore]: Using Json.dumps

* [chore]: Exact same logic as  when casting agent oobservation to string
This commit is contained in:
Mohammad Mohtashim 2024-10-01 00:54:51 +05:00 committed by GitHub
parent 34bd718fe1
commit e12f570ead
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -189,10 +189,17 @@ def _convert_agent_observation_to_messages(
Returns:
AIMessage that corresponds to the original tool invocation.
"""
if isinstance(agent_action, AgentActionMessageLog):
return [_create_function_message(agent_action, observation)]
else:
return [HumanMessage(content=observation)]
content = observation
if not isinstance(observation, str):
try:
content = json.dumps(observation, ensure_ascii=False)
except Exception:
content = str(observation)
return [HumanMessage(content=content)]
def _create_function_message(