Skip to content

Update Anthropic model config for current Claude models - #211

Open
hiryanchen wants to merge 1 commit into
https-deeplearning-ai:mainfrom
hiryanchen:fix/anthropic-model-config
Open

Update Anthropic model config for current Claude models#211
hiryanchen wants to merge 1 commit into
https-deeplearning-ai:mainfrom
hiryanchen:fix/anthropic-model-config

Conversation

@hiryanchen

Copy link
Copy Markdown

Problem

backend/config.py pins ANTHROPIC_MODEL to claude-sonnet-4-20250514, which is deprecated and retires 2026-06-15. Upgrading off it isn't a one-line change, because two things in AIGenerator.base_params are incompatible with current models:

  • temperature: 0 returns a 400. Current Claude models reject non-default sampling parameters. Bumping ANTHROPIC_MODEL on its own makes every query fail at API-call time — the server still starts and ingests documents fine (embeddings are local), so the failure only shows up once you ask a question.
  • thinking is unset. Newer models run adaptive thinking by default, so part of the 800-token max_tokens budget goes to reasoning this app never reads. max_tokens caps thinking plus response text, so answers can get truncated.

Change

  • config.py: pin ANTHROPIC_MODEL to claude-sonnet-5.
  • ai_generator.py: drop temperature, add thinking: {"type": "disabled"} so the full max_tokens budget goes to the response.

Two files, no behavior change to the retrieval flow.

Note for maintainers

Both return sites in ai_generator.py (:90 and :138) do response.content[0].text unconditionally. That's safe with thinking disabled as set here, but it will raise if anyone enables thinking later — a thinking block can land at content[0]. Left alone to keep this PR scoped; happy to fix it here or in a follow-up if you'd prefer.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant