From d63007d9288366bac07b4728f3efa9b9bd8bcabf Mon Sep 17 00:00:00 2001 From: RWRZ Date: Tue, 29 Apr 2025 07:53:19 -0300 Subject: [PATCH] fix thinking (@mettamatt) --- server.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index f4966b2..9e8d582 100644 --- a/server.py +++ b/server.py @@ -169,7 +169,7 @@ class Tool(BaseModel): input_schema: Dict[str, Any] class ThinkingConfig(BaseModel): - enabled: bool + enabled: bool = True class MessagesRequest(BaseModel): model: str @@ -539,13 +539,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