Skip to content
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

fix tool use bug #35

Merged
merged 1 commit into from
Oct 3, 2024
Merged

fix tool use bug #35

merged 1 commit into from
Oct 3, 2024

Conversation

comhar
Copy link
Contributor

@comhar comhar commented Oct 3, 2024

In PR #34 the tool_choice check in Client.__call__ was changed from

if tool_choice and pr: kwargs['tool_choice'] = mk_tool_choice(tool_choice)

to

if tool_choice: kwargs['tool_choice'] = mk_tool_choice(tool_choice)

As shown in this gist tool use (for the calculator example at least) is silently failing when pr is removed. The detailed sections below show the chat history with/without pr. The opening 3 chat messages match but things get out of sync after that.

`tool_choice` with `pr`
[
  {'role': 'user', 'content': [{'type': 'text', 'text': 'What is 604542+6458932?'}]},
  {'role': 'assistant', 'content': [ToolUseBlock(id='toolu_018ErvHSzm6FwTj3VcqWYMDY', input={'a': 604542, 'b': 6458932}, name='sums', type='tool_use')]},
  {'role': 'user', 'content': [{'type': 'tool_result', 'tool_use_id': 'toolu_018ErvHSzm6FwTj3VcqWYMDY', 'content': '7063474'}]},
  {'role': 'assistant', 'content': [TextBlock(text='The sum of 604542 and 6458932 is 7063474.', type='text')]}
]
`tool_choice` without `pr`
[
 {'role': 'user', 'content': [{'type': 'text', 'text': 'What is 604542+6458932?'}]},
 {'role': 'assistant', 'content': [ToolUseBlock(id='toolu_01T6nhnbdKmvbifDaXrmaDVJ', input={'a': 604542, 'b': 6458932}, name='sums', type='tool_use')]},
 {'role': 'user', 'content': [{'type': 'tool_result', 'tool_use_id': 'toolu_01T6nhnbdKmvbifDaXrmaDVJ', 'content': '7063474'}]},
 {'role': 'assistant','content': [ToolUseBlock(id='toolu_01GzsM6QBFVrkdqWX8ZuGh7T', input={'a': 604542, 'b': 6458932}, name='sums', type='tool_use')]},
 {'role': 'user', 'content': [{'type': 'tool_result', 'tool_use_id': 'toolu_01GzsM6QBFVrkdqWX8ZuGh7T', 'content': '7063474'}]}
]

Question

Why was pr originally removed from the tool_choice check?

@comhar comhar added the bug Something isn't working label Oct 3, 2024
Copy link

gitnotebooks bot commented Oct 3, 2024

Found 1 changed notebook. Review the changes at https://app.gitnotebooks.com/AnswerDotAI/claudette/pull/35

@jph00 jph00 merged commit 30938b9 into main Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants