Skip to content

Fix anthropic thinking + response_format #9594

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

Merged
merged 6 commits into from
Mar 28, 2025

Conversation

krrishdholakia
Copy link
Contributor

@krrishdholakia krrishdholakia commented Mar 27, 2025

Title

  • fix(anthropic/chat/transformation.py): Don't set tool choice on response_format conversion when thinking is enabled

Not allowed by Anthropic

Fixes #8901

  • refactor: move test to base anthropic chat tests

ensures consistent behaviour across vertex/anthropic/bedrock

  • fix(anthropic/chat/transformation.py): if thinking token is specified and max tokens is not - ensure max token to anthropic is higher than thinking tokens

  • feat(converse_transformation.py): correctly handle thinking + response format on Bedrock Converse

Fixes #8901

  • fix(converse_transformation.py): correctly handle adding max tokens

  • test: handle service unavailable error

Relevant issues

Fixes #8901

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on (make test-unit)[https://docs.litellm.ai/docs/extras/contributing_code]
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix
🧹 Refactoring

Changes

…nse_format conversion when thinking is enabled

Not allowed by Anthropic

Fixes #8901
ensures consistent behaviour across vertex/anthropic/bedrock
… and max tokens is not - ensure max token to anthropic is higher than thinking tokens
Copy link

vercel bot commented Mar 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2025 5:45am

@krrishdholakia krrishdholakia merged commit 222898d into main Mar 28, 2025
36 of 39 checks passed
@krrishdholakia krrishdholakia deleted the litellm_dev_03_27_2025_p1 branch March 28, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Claude 3.7 extended thinking mode and structured output via LiteLLM not compatible
1 participant