-
-
Notifications
You must be signed in to change notification settings - Fork 115
fix: add missing Anthropic models type and update the anthropic docs #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: add missing Anthropic models type and update the anthropic docs #234
Conversation
📝 WalkthroughWalkthroughExports a new public type Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 markdownlint-cli2 (0.18.1).changeset/add-anthropic-models-export.mdmarkdownlint-cli2 v0.18.1 (markdownlint v0.38.0) docs/adapters/anthropic.mdmarkdownlint-cli2 v0.18.1 (markdownlint v0.38.0) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
docs/adapters/anthropic.md (2)
46-54: Configuration example uses outdated function signature.This example still uses the old
createAnthropicChat(apiKey, config)signature, but the breaking change requires the model as the first parameter:createAnthropicChat(model, apiKey, config).Proposed fix
## Configuration ```typescript import { createAnthropicChat, type AnthropicChatConfig } from "@tanstack/ai-anthropic"; const config: Omit<AnthropicChatConfig, 'apiKey'> = { baseURL: "https://api.anthropic.com", // Optional, for custom endpoints }; -const adapter = createAnthropicChat(process.env.ANTHROPIC_API_KEY!, config); +const adapter = createAnthropicChat("claude-sonnet-4-5", process.env.ANTHROPIC_API_KEY!, config);</details> --- `195-204`: **API reference doesn't reflect the new function signature.** The `createAnthropicChat` documentation still shows the old signature `(apiKey, config?)`. Update it to reflect the breaking change where model is the first parameter. <details> <summary>Proposed fix</summary> ```diff ### `createAnthropicChat(apiKey, config?)` +### `createAnthropicChat(model, apiKey, config?)` Creates an Anthropic chat adapter with an explicit API key. **Parameters:** +- `model` - The Anthropic model identifier (e.g., `'claude-sonnet-4-5'`) - `apiKey` - Your Anthropic API key - `config.baseURL?` - Custom base URL (optional) **Returns:** An Anthropic chat adapter instance.
🤖 Fix all issues with AI agents
In @.changeset/add-anthropic-models-export.md:
- Around line 1-3: The changeset is incorrectly marked as 'minor' despite
introducing a breaking change to the createAnthropicChat function signature
(model is now the first parameter); update the changeset entry in
.changeset/add-anthropic-models-export.md to use a 'major' release type so
semantic versioning reflects the breaking change and consumers are notified of
the API change.
- Around line 37-49: The adapter function currently types its parameter as
ANTHROPIC_MODELS (a tuple) which requires the whole tuple instead of a single
model string; update the parameter type to ANTHROPIC_MODELS[number] so
adapter(model: ANTHROPIC_MODELS[number]) and the call
adapter('claude-sonnet-4-5') are type-correct, or alternatively export a union
alias (e.g., type AnthropicModel = ANTHROPIC_MODELS[number]) and use that in
adapter and any createAnthropicChat/chat calls to improve ergonomics.
In `@docs/adapters/anthropic.md`:
- Around line 33-36: The adapter function parameter currently uses the aggregate
type ANTHROPIC_MODELS; change its parameter type to the element type
ANTHROPIC_MODELS[number] so the adapter(model: ANTHROPIC_MODELS[number]) accepts
a single model string; update the adapter declaration that calls
createAnthropicChat (and any other usages of adapter) to use
ANTHROPIC_MODELS[number] as the parameter type.
| const adapter = createAnthropicChat(process.env.ANTHROPIC_API_KEY!, { | ||
| // ... your config options | ||
| }); | ||
| const adapter = (model: AnthropicModels) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this change please
|
|
||
| The type ensures only valid Anthropic model identifiers can be passed, preventing runtime errors. | ||
|
|
||
| ### Breaking Change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the breaking change section as it's not a breaking change
| @@ -0,0 +1,64 @@ | |||
| --- | |||
| '@tanstack/ai-anthropic': major | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a major change, this hsould be set to patch
AlemTuzlak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check comments
🎯 Changes
WHAT
Added missing
ANTHROPIC_MODELStype export to the public API of@tanstack/ai-anthropicand updated the documentation to correctly reference it.The
ANTHROPIC_MODELSis a const tuple that contains all supported Anthropic model identifiers:WHY
When I tried to use the
createAnthropicChataccording to the docs it gave me type errors and I find out that the first parameter it takes is the model name, not the API KEY as the docs suggest.Then I find out that there is actually a type
ANTHROPIC_MODELSwhich is not exported that I can use to construct the adapter.HOW - Consumers Should Update
Now you can import and use
ANTHROPIC_MODELSfor proper type safety when creating adapter instances:✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Breaking Changes
New Features
✏️ Tip: You can customize this high-level summary in your review settings.