Merge pull request #18 from rwrz/fix_thinking

fix thinking (@mettamatt)
This commit is contained in:
Winston Du 2025-08-20 23:29:55 -04:00 committed by GitHub
commit 08778097ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -172,7 +172,7 @@ class Tool(BaseModel):
input_schema: Dict[str, Any]
class ThinkingConfig(BaseModel):
enabled: bool
enabled: bool = True
class MessagesRequest(BaseModel):
model: str
@ -547,13 +547,17 @@ def convert_anthropic_to_litellm(anthropic_request: MessagesRequest) -> Dict[str
# Create LiteLLM request dict
litellm_request = {
"model": anthropic_request.model, # t understands "anthropic/claude-x" format
"model": anthropic_request.model, # it understands "anthropic/claude-x" format
"messages": messages,
"max_tokens": max_tokens,
"temperature": anthropic_request.temperature,
"stream": anthropic_request.stream,
}
# Only include thinking field for Anthropic models
if anthropic_request.thinking and anthropic_request.model.startswith("anthropic/"):
litellm_request["thinking"] = anthropic_request.thinking
# Add optional parameters if present
if anthropic_request.stop_sequences:
litellm_request["stop"] = anthropic_request.stop_sequences