DocUA commited on
Commit
28552c9
·
1 Parent(s): 09efcd1

Re-enable extended thinking for Claude Haiku 4.5 models

Browse files
Files changed (1) hide show
  1. main.py +19 -23
main.py CHANGED
@@ -995,30 +995,26 @@ def generate_legal_position(
995
 
996
  # Add thinking config if enabled
997
  if thinking_enabled and "claude" in model_name.lower():
998
- # Claude Haiku typically does not support thinking mode
999
- if "haiku" in model_name.lower():
1000
- print(f"[WARNING] Thinking mode is not supported for Haiku models. Disabling thinking for {model_name}.")
 
1001
  else:
1002
- # For Claude 4.6 models, we can use Adaptive
1003
- if thinking_type.lower() == "adaptive" and "-4-6" in str(model_name).lower():
1004
- message_params["thinking"] = {"type": "adaptive"}
1005
- message_params["temperature"] = 1.0
1006
- else:
1007
- # 'Enabled' type works for both 4.5 and 4.6 models
1008
- budget = max(1024, int(thinking_budget))
1009
-
1010
- # Anthropic REQUIRES max_tokens > budget_tokens.
1011
- # If the user sets a low max_tokens (e.g. 4000) and high budget (10000), it will fail.
1012
- if message_params["max_tokens"] <= budget:
1013
- recommended_max = budget + 4000
1014
- print(f"[WARNING] max_tokens ({message_params['max_tokens']}) is <= thinking_budget ({budget}). Increasing max_tokens to {recommended_max}.")
1015
- message_params["max_tokens"] = recommended_max
1016
-
1017
- message_params["thinking"] = {
1018
- "type": "enabled",
1019
- "budget_tokens": budget
1020
- }
1021
- message_params["temperature"] = 1.0
1022
 
1023
  # Log full prompts in debug mode
1024
  _log_prompt("anthropic", model_name, system_prompt, content)
 
995
 
996
  # Add thinking config if enabled
997
  if thinking_enabled and "claude" in model_name.lower():
998
+ # For Claude 4.6 models, we can use Adaptive
999
+ if thinking_type.lower() == "adaptive" and "-4-6" in str(model_name).lower():
1000
+ message_params["thinking"] = {"type": "adaptive"}
1001
+ message_params["temperature"] = 1.0
1002
  else:
1003
+ # 'Enabled' type works for both 4.5 and 4.6 models
1004
+ budget = max(1024, int(thinking_budget))
1005
+
1006
+ # Anthropic REQUIRES max_tokens > budget_tokens.
1007
+ # If the user sets a low max_tokens (e.g. 4000) and high budget (10000), it will fail.
1008
+ if message_params["max_tokens"] <= budget:
1009
+ recommended_max = budget + 4000
1010
+ print(f"[WARNING] max_tokens ({message_params['max_tokens']}) is <= thinking_budget ({budget}). Increasing max_tokens to {recommended_max}.")
1011
+ message_params["max_tokens"] = recommended_max
1012
+
1013
+ message_params["thinking"] = {
1014
+ "type": "enabled",
1015
+ "budget_tokens": budget
1016
+ }
1017
+ message_params["temperature"] = 1.0
 
 
 
 
 
1018
 
1019
  # Log full prompts in debug mode
1020
  _log_prompt("anthropic", model_name, system_prompt, content)