Skip to content

Commit

Permalink
[Bugfix] Ensure tool output is a str, for OAI Assistant (#14830)
Browse files Browse the repository at this point in the history
Tool outputs have to be strings apparently. Ensure they are formatted
correctly before passing as intermediate steps.
 

```
BadRequestError: Error code: 400 - {'error': {'message': '1 validation error for Request\nbody -> tool_outputs -> 0 -> output\n  str type expected (type=type_error.str)', 'type': 'invalid_request_error', 'param': None, 'code': None}}
```
  • Loading branch information
hinthornw committed Dec 18, 2023
1 parent bbc98a2 commit 5fc2c57
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libs/langchain/langchain/agents/openai_assistant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _parse_intermediate_steps(
tc.id for tc in run.required_action.submit_tool_outputs.tool_calls
}
tool_outputs = [
{"output": output, "tool_call_id": action.tool_call_id}
{"output": str(output), "tool_call_id": action.tool_call_id}
for action, output in intermediate_steps
if action.tool_call_id in required_tool_call_ids
]
Expand Down

0 comments on commit 5fc2c57

Please sign in to comment.