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

Python: Fix Anthropic parallel tool call #10005

Merged
merged 5 commits into from
Dec 19, 2024

Conversation

TaoChenOSU
Copy link
Contributor

@TaoChenOSU TaoChenOSU commented Dec 17, 2024

Motivation and Context

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 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

  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

@TaoChenOSU TaoChenOSU added the python Pull requests for the Python Semantic Kernel label Dec 17, 2024
@TaoChenOSU TaoChenOSU self-assigned this Dec 17, 2024
@TaoChenOSU TaoChenOSU requested a review from a team as a code owner December 17, 2024 23:33
@github-actions github-actions bot changed the title Fix Anthropic parallel tool call Python: Fix Anthropic parallel tool call Dec 17, 2024
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Dec 17, 2024

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
semantic_kernel/connectors/ai/anthropic/services
   anthropic_chat_completion.py163895%157, 163, 175, 181, 185, 242–244, 371
   utils.py47394%64, 97–100
TOTAL16779185989% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2968 4 💤 0 ❌ 0 🔥 1m 16s ⏱️

@TaoChenOSU TaoChenOSU enabled auto-merge December 18, 2024 23:59
@TaoChenOSU TaoChenOSU added this pull request to the merge queue Dec 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 19, 2024
@TaoChenOSU TaoChenOSU added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit f50117f Dec 19, 2024
25 checks passed
@TaoChenOSU TaoChenOSU deleted the taochen/python-fix-anthropic-parallel-tool-call branch December 19, 2024 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
Status: Sprint: Done
Development

Successfully merging this pull request may close these issues.

4 participants