-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Adding dynamic model fetching to Anthropic app #18499
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughVersion bumped to 0.2.1. The Chat action’s model prop now references a propDefinition from the Anthropic app. The constants file with static MESSAGE_MODELS was removed. The Anthropic app now defines a model prop with dynamic options fetched via a new listModels() method calling /models. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant ChatAction as Chat Action
participant AnthropicApp as Anthropic App
participant AnthropicAPI as Anthropic /models
rect lightgray
note over ChatAction,AnthropicApp: Configuration time (populate model dropdown)
User->>ChatAction: Open config / edit model
ChatAction->>AnthropicApp: Resolve propDefinition "model".options()
AnthropicApp->>AnthropicAPI: GET /models
AnthropicAPI-->>AnthropicApp: List of models
AnthropicApp-->>ChatAction: [{label, value}, ...] with default
ChatAction-->>User: Render selectable models
end
rect #E8F6FF
note over User,ChatAction: Run-time (execution)
User->>ChatAction: Execute with selected model
ChatAction->>AnthropicApp: Invoke chat using selected model
AnthropicApp-->>ChatAction: Response
ChatAction-->>User: Result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
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. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
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: 1
🧹 Nitpick comments (1)
components/anthropic/anthropic.app.mjs (1)
8-21: Add error handling for the dynamic options resolver.The
options()function callslistModels()without error handling. If the API call fails (network issues, authentication problems, rate limits), users will see an unhelpful error when trying to select a model.Consider adding error handling and a fallback:
async options() { - const response = await this.listModels(); - return response.data.map((model) => ({ - label: model.display_name, - value: model.id, - })); + try { + const response = await this.listModels(); + return response.data.map((model) => ({ + label: model.display_name, + value: model.id, + })); + } catch (error) { + console.error("Failed to fetch models:", error); + // Fallback to default model if API call fails + return [{ + label: "Claude Sonnet 4.5 (default)", + value: DEFAULT_MODEL, + }]; + } },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
components/anthropic/actions/chat/chat.mjs(1 hunks)components/anthropic/actions/common/constants.mjs(0 hunks)components/anthropic/anthropic.app.mjs(2 hunks)components/anthropic/package.json(1 hunks)
💤 Files with no reviewable changes (1)
- components/anthropic/actions/common/constants.mjs
🧰 Additional context used
🧬 Code graph analysis (1)
components/anthropic/anthropic.app.mjs (1)
components/anthropic/actions/chat/chat.mjs (1)
response(79-93)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: Lint Code Base
- GitHub Check: pnpm publish
🔇 Additional comments (4)
components/anthropic/package.json (1)
3-3: LGTM! Version bump is appropriate.The patch version increment from 0.2.0 to 0.2.1 is appropriate for adding dynamic model fetching functionality.
components/anthropic/anthropic.app.mjs (1)
42-47: LGTM! The listModels implementation is clean.The method correctly uses the existing
_makeRequestinfrastructure and follows the established pattern. The GET method is correctly inferred by default.components/anthropic/actions/chat/chat.mjs (2)
5-5: LGTM! Version bump is consistent.The version bump to 0.2.1 aligns with the package version change.
11-16: LGTM! Clean refactoring to use propDefinition.The migration from inline model configuration to propDefinition eliminates code duplication and centralizes model management. The model value is correctly consumed at line 83 in the
createMessagecall.
Summary by CodeRabbit
New Features
Chores