Spaces:
Paused
Paused
Fix Anthropic thinking mode configuration logic
Browse files994 unmodified lines995996997998999100010011002100310041005100610071008100910101011994 unmodified lines# Add thinking config if enabledif thinking_enabled and "claude" in model_name.lower():# For Claude 4.6 models, we can use Adaptiveif thinking_type.lower() == "adaptive" and getattr(model_name, "find", lambda x: -1)("-4-6") != -1:message_params["thinking"] = {"type": "adaptive"}message_params["temperature"] = 1.0else:# 'Enabled' type works for both 4.5 and 4.6 modelsmessage_params["thinking"] = {"type": "enabled","budget_tokens": max(1024, int(thinking_budget))}message_params["temperature"] = 1.0# Log full prompts in debug mode_log_prompt("anthropic", model_name, system_prompt, content)994 unmodified lines9959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024994 unmodified lines# Add thinking config if enabledif thinking_enabled and "claude" in model_name.lower():# Claude Haiku typically does not support thinking modeif "haiku" in model_name.lower():print(f"[WARNING] Thinking mode is not supported for Haiku models. Disabling thinking for {model_name}.")else:# For Claude 4.6 models, we can use Adaptiveif thinking_type.lower() == "adaptive" and "-4-6" in str(model_name).lower():message_params["thinking"] = {"type": "adaptive"}message_params["temperature"] = 1.0else:# 'Enabled' type works for both 4.5 and 4.6 modelsbudget = max(1024, int(thinking_budget))# Anthropic REQUIRES max_tokens > budget_tokens.# If the user sets a low max_tokens (e.g. 4000) and high budget (10000), it will fail.if message_params["max_tokens"] <= budget:recommended_max = budget + 4000print(f"[WARNING] max_tokens ({message_params['max_tokens']}) is <= thinking_budget ({budget}). Increasing max_tokens to {recommended_max}.")message_params["max_tokens"] = recommended_maxmessage_params["thinking"] = {"type": "enabled","budget_tokens": budget}message_params["temperature"] = 1.0# Log full prompts in debug mode_log_prompt("anthropic", model_name, system_prompt, content)
main.py+23-10