-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: Fix Anthropic parallel tool call (#10005)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> When using the Anthropic connector with function calling, it's possible that the model will request multiple functions in a single request. This is referred to as [`parallel tool use`](https://docs.anthropic.com/en/docs/build-with-claude/tool-use#disabling-parallel-tool-use) by Anthropic. When the model requests multiple functions, it expects the tool results to be included in a single user message to be passed back to the model. Right now, the Anthropic connector parses the tool results into multiple user messages, which causes the model to throw an error. This is a possible regression introduced by this PR: #9938 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Fix the Anthropic connector to handle parallel tool calls. 2. Add unit tests to ensure that future changes don't break this functionality. 3. Enable integration test on Anthropic since we have a service endpoint now. 4. Refactoring. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
- Loading branch information
1 parent
16690ed
commit f50117f
Showing
5 changed files
with
611 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.