From c0307022a0dc5ee9ae3a9df0d0e264f4149f9f9d Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Sat, 8 Aug 2026 17:00:29 -0700 Subject: [PATCH] Update Anthropic model config for current Claude models The pinned model `claude-sonnet-4-20250514` is deprecated (retires 2026-06-15), and the request parameters block upgrading away from it: - `temperature` is rejected by current Claude models and returns a 400, so bumping ANTHROPIC_MODEL alone breaks every query at API-call time. - Newer models run adaptive thinking when `thinking` is omitted, which spends part of the 800-token budget on reasoning the app never reads. Pin `claude-sonnet-5`, drop `temperature`, and set `thinking` to disabled so the full max_tokens budget goes to the response. Co-Authored-By: Claude Opus 5 --- backend/ai_generator.py | 7 +++++-- backend/config.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/ai_generator.py b/backend/ai_generator.py index 0363ca90c..149cb46e1 100644 --- a/backend/ai_generator.py +++ b/backend/ai_generator.py @@ -34,10 +34,13 @@ def __init__(self, api_key: str, model: str): self.model = model # Pre-build base API parameters + # Sonnet 5 rejects non-default sampling params, and runs adaptive + # thinking when `thinking` is omitted - disabled here to keep answers + # fast and to leave the full max_tokens budget for the response. self.base_params = { "model": self.model, - "temperature": 0, - "max_tokens": 800 + "max_tokens": 800, + "thinking": {"type": "disabled"} } def generate_response(self, query: str, diff --git a/backend/config.py b/backend/config.py index d9f6392ef..c4ba3712b 100644 --- a/backend/config.py +++ b/backend/config.py @@ -10,7 +10,7 @@ class Config: """Configuration settings for the RAG system""" # Anthropic API settings ANTHROPIC_API_KEY: str = os.getenv("ANTHROPIC_API_KEY", "") - ANTHROPIC_MODEL: str = "claude-sonnet-4-20250514" + ANTHROPIC_MODEL: str = "claude-sonnet-5" # Embedding model settings EMBEDDING_MODEL: str = "all-MiniLM-L6-v2"