-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve tool use response format #306
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to a7b9ef4 in 53 seconds
More details
- Looked at
289
lines of code in6
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. gptme/message.py:44
- Draft comment:
Update the docstring to include 'tool_result' as a possible role for the message sender. - Reason this comment was not posted:
Confidence changes required:50%
The PR introduces a new role 'tool_result' in the Message class, which is used in various places. This change should be reflected in the documentation of the Message class to ensure clarity.
Workflow ID: wflow_Bqw5JXPSO6DeDHb2
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
a1cadba
to
e63fbab
Compare
8a22723
to
97e7e7c
Compare
assert len(content) == 1 | ||
return content[0].text # type: ignore | ||
|
||
parsed_block = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tool call was broken with non stream API.
@@ -99,7 +108,7 @@ def stream( | |||
block = chunk.content_block | |||
if isinstance(block, anthropic.types.ToolUseBlock): | |||
tool_use = block | |||
yield f"\n@{tool_use.name}: " | |||
yield f"\n@{tool_use.name}({tool_use.id}): " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add the tool uid here to save it in the message.
@@ -224,7 +303,7 @@ def _transform_system_messages( | |||
|
|||
# for any subsequent system messages, transform them into a <system> message | |||
for i, message in enumerate(messages): | |||
if message.role == "system": | |||
if message.role == "system" and message.call_id is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to change messages with call_id. They will be handled by the _handle_tool
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this as a code comment, as it's good to know when reading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to 97e7e7c in 1 minute and 32 seconds
More details
- Looked at
1066
lines of code in10
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. tests/test_tool_use.py:70
- Draft comment:
The regex pattern for tool calls has been updated to include a call ID, but the test cases here still use the old pattern without the call ID. Update the test cases to include a call ID in the tool call format. - Reason this comment was not posted:
Comment looked like it was already resolved.
Workflow ID: wflow_FEtlgo6qaP9zjkPI
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Hey @ErikBjare this MR is ready to review:
Let me know what you think. FYI I tested it with openai and anthropic ;-) |
97e7e7c
to
6e66c1b
Compare
43785e5
to
372163b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work!
Will test this out and merge :)
7bd93ea
to
4b12180
Compare
4b12180
to
a0c39f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super impressive, works amazingly! 💪
Thanks again 🙏
🥇 👑
This is an attempt to match the expected output for each API regarding tool use response.
It modify the message dicts to match the expected output.
Also fix tool call not working with stream == False