mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 07:35:18 +00:00
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:
parent
34bd718fe1
commit
e12f570ead
@ -189,10 +189,17 @@ def _convert_agent_observation_to_messages(
|
|||||||
Returns:
|
Returns:
|
||||||
AIMessage that corresponds to the original tool invocation.
|
AIMessage that corresponds to the original tool invocation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(agent_action, AgentActionMessageLog):
|
if isinstance(agent_action, AgentActionMessageLog):
|
||||||
return [_create_function_message(agent_action, observation)]
|
return [_create_function_message(agent_action, observation)]
|
||||||
else:
|
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(
|
def _create_function_message(
|
||||||
|
Loading…
Reference in New Issue
Block a user