-
-
Notifications
You must be signed in to change notification settings - Fork 22.3k
[Bugfix][Frontend] Anthropic API: honor the thinking request parameter
#53058
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -118,6 +118,18 @@ class AnthropicOutputConfig(BaseModel): | |||||||||||||||||||||||||||||
| format: AnthropicJsonOutputFormat | None = None | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| class AnthropicThinkingConfig(BaseModel): | ||||||||||||||||||||||||||||||
| """Extended-thinking configuration. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ``display`` controls visibility only: reasoning still runs and is still | ||||||||||||||||||||||||||||||
| billed under every setting. | ||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| type: Literal["enabled", "disabled", "adaptive"] = "enabled" | ||||||||||||||||||||||||||||||
| budget_tokens: int | None = None | ||||||||||||||||||||||||||||||
| display: Literal["summarized", "omitted"] | None = None | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+129
to
+131
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. Per Anthropic Messages API spec, budget_tokens is a required field when type is enabled (
Suggested change
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. But the goal are just to be able to emulate Anthropics API to support Claude Code harness. vLLM will not be able to handle budget_tokens anyway? I don't think it really matters so I let the maintainer decide if vLLM need that kind of consistency |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| class AnthropicMessagesRequest(BaseModel): | ||||||||||||||||||||||||||||||
| """Anthropic Messages API request""" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -126,6 +138,7 @@ class AnthropicMessagesRequest(BaseModel): | |||||||||||||||||||||||||||||
| max_tokens: int | ||||||||||||||||||||||||||||||
| metadata: dict[str, Any] | None = None | ||||||||||||||||||||||||||||||
| output_config: AnthropicOutputConfig | None = None | ||||||||||||||||||||||||||||||
| thinking: AnthropicThinkingConfig | None = None | ||||||||||||||||||||||||||||||
| stop_sequences: ( | ||||||||||||||||||||||||||||||
| Annotated[list[str], Field(max_length=envs.VLLM_MAX_STOP_STRINGS)] | None | ||||||||||||||||||||||||||||||
| ) = None | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason it hasn’t been introduced yet is that, if I remember correctly, these fields are going to be deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecated in Claude Code? Is it not beneficial to be able to control reasoning. It's a huge difference using different harness like OpenCode (OpenAI api) vs. Claude Code (Anthropic API) since vLLM handles reasoning well via OpenAI API but not in Anthropic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cf. https://platform.claude.com/doc/en/build-with-claude/extended-thinking
Although I do not reckon that the whole
thinkingfield is deprecated,thinking.budget_tokensis no longer supported since 4.7There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chaunceyjiang I think this is a good addition since it's not going to be deprecated. The newly released DeepSeek Harness does support it as one example: https://github.com/earendil-works/pi/blob/5cd93f688aaab89dbb6dfa4aca535f21796ae185/packages/ai/src/api/anthropic-messages.ts#L1069 This is what DeepSeek Harness are using, dynamic thinking / effort for each prompt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I’ll test it locally.