Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions vllm/entrypoints/anthropic/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ class AnthropicMessagesRequest(BaseModel):
default=None,
description="KVTransfer parameters used for disaggregated serving.",
)
chat_template_kwargs: dict[str, Any] | None = Field(
default=None,
description=(
"Additional keyword args to pass to the chat template renderer. "
"Will be accessible by the template."
),
)

@field_validator("model")
@classmethod
Expand Down Expand Up @@ -212,6 +219,15 @@ class AnthropicCountTokensRequest(BaseModel):
tool_choice: AnthropicToolChoice | None = None
tools: list[AnthropicTool] | None = None

# vLLM-specific fields that are not in Anthropic spec
chat_template_kwargs: dict[str, Any] | None = Field(
default=None,
description=(
"Additional keyword args to pass to the chat template renderer. "
"Will be accessible by the template."
),
)

@field_validator("model")
@classmethod
def validate_model(cls, v):
Expand Down
2 changes: 2 additions & 0 deletions vllm/entrypoints/anthropic/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ def _build_base_request(
return ChatCompletionRequest(
model=anthropic_request.model,
messages=openai_messages,
chat_template_kwargs=anthropic_request.chat_template_kwargs,
)

return ChatCompletionRequest(
Expand All @@ -335,6 +336,7 @@ def _build_base_request(
top_p=anthropic_request.top_p,
top_k=anthropic_request.top_k,
kv_transfer_params=anthropic_request.kv_transfer_params,
chat_template_kwargs=anthropic_request.chat_template_kwargs,
)

@classmethod
Expand Down
Loading