Skip to content

Commit

Permalink
Improve tool output handling
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianLucas committed Dec 10, 2024
1 parent d437f1d commit 19b9a9d
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,20 +896,15 @@ async def async_respond(self, user_input=None):
output = result.error
else:
output = result.output
self.messages.append(
{
"role": "tool",
"content": output,
"tool_call_id": tool_call.id,
}
)

tool_output = ""

if output:
tool_output += output

if result.base64_image:
self.messages.append(
{
"role": "tool",
"content": "The user will reply with the tool's image output.",
"tool_call_id": tool_call.id,
}
tool_output += (
"\nThe user will reply with the tool's image output."
)
user_content_to_add.append(
{
Expand All @@ -919,6 +914,17 @@ async def async_respond(self, user_input=None):
},
}
)

if tool_output == "":
tool_output = "No output from tool."

self.messages.append(
{
"role": "tool",
"content": tool_output.strip(),
"tool_call_id": tool_call.id,
}
)
else:
text_content = (
"This was the output of the tool call. What does it mean/what's next?\n"
Expand Down

0 comments on commit 19b9a9d

Please sign in to comment.