Repository navigation
fix(anthropic): round-trip thinking blocks to OpenAI backends on /v1/messages #37953
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
Changes from 2 commits
766f72f
32bf1ab
5317a5a
71d6f5f
68bda94
d46b0bd
8a1fe28
e02f34b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,7 @@ def create_tool_name_mapping( | |
|
|
||
| from litellm.litellm_core_utils.prompt_templates.common_utils import ( | ||
| parse_tool_call_arguments, | ||
| reasoning_content_from_thinking_blocks, | ||
| with_prompt_cache_breakpoint, | ||
| ) | ||
| from litellm.litellm_core_utils.prompt_templates.factory import ( | ||
|
|
@@ -592,6 +593,9 @@ def translate_anthropic_messages_to_openai( | |
| assistant_message["tool_calls"] = tool_calls | ||
| if len(thinking_blocks) > 0: | ||
| assistant_message["thinking_blocks"] = thinking_blocks | ||
| reasoning_content = reasoning_content_from_thinking_blocks(thinking_blocks) | ||
| if reasoning_content: | ||
| assistant_message["reasoning_content"] = reasoning_content | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low: Thinking blocks bypass input guardrails A user can place content in an assistant
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Pre-existing surface: these blocks already went upstream via |
||
| new_messages.append(assistant_message) | ||
|
|
||
| return new_messages | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.