Skip to content
Source
Sign inSign up
TanStack/ai

fix(ai-anthropic): drop sampling keys on models that reject them #1705

Mergedharshlocham(GitHub profile, opens in a new tab)merged 11 commits intomain fromrefs/pull/1705/headmerged by AlemTuzlak View on GitHub

Showing 7 changed files with 19 additions and 4 deletions (loading 4).

x
0 of 7 viewed, 7 left
5 additions and 0 deletions.changeset/summarize-skip-temperature-no-sampling.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-anthropic': patch
+---
+​
+The Anthropic text adapter drops `temperature`, `top_p`, and `top_k` from the request on models that reject non-default sampling parameters. `anthropicSummarize()` on those models no longer sends the summarize default `temperature: 0.3`, so the request no longer fails with a 400.
2 additions and 0 deletionsdocs/adapters/anthropic.mdModified
View file
@@ -136,6 +136,8 @@
console.log(result.summary);
```
​
+Some models reject a non-default `temperature`, `top_p`, or `top_k`. On those models, `summarize()` does not send its default `temperature` of `0.3`.
+​
## Files
​
`anthropicFiles` uploads media to the Anthropic Files API, so a message can point to the file. See [Files API](../advanced/files-api).
12 additions and 4 deletionspackages/ai-anthropic/src/adapters/text.tsModified
View file
@@ -50,6 +50,7 @@
ANTHROPIC_MODEL_INPUT_MODALITIES,
ANTHROPIC_MODEL_MID_CONVERSATION_CHANNELS,
ANTHROPIC_MODEL_REASONING,
+ ANTHROPIC_MODELS_REJECTING_SAMPLING,
ANTHROPIC_NO_FORCED_TOOL_MODELS,
getAnthropicDefaultMaxTokens,
} from '../model-meta'