-
Notifications
You must be signed in to change notification settings - Fork 430
List Anthropic models via dedicated handler #1732
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
Add a dedicated list-anthropic implementation to handle Anthropic's models endpoint and required headers. Anthropic requires the anthropic-version header and returns a different JSON shape, so extracting this logic into apps/desktop/src/components/settings/ai/shared/list-anthropic.ts prevents console errors and ensures proper model parsing, filtering, and timeout handling. The previous Anthropic handling in list-openai.ts was removed and imports updated to use the new module. ㅍ
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughRefactors Anthropic model listing logic from a consolidated module into a dedicated file, updates HTTP fetching to use Tauri's HTTP plugin with improved error handling, and reorganizes imports to reflect the separation of concerns. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/desktop/src/components/settings/ai/llm/select.tsx(1 hunks)apps/desktop/src/components/settings/ai/shared/list-anthropic.ts(1 hunks)apps/desktop/src/components/settings/ai/shared/list-common.ts(2 hunks)apps/desktop/src/components/settings/ai/shared/list-openai.ts(0 hunks)
💤 Files with no reviewable changes (1)
- apps/desktop/src/components/settings/ai/shared/list-openai.ts
🧰 Additional context used
🧬 Code graph analysis (1)
apps/desktop/src/components/settings/ai/shared/list-anthropic.ts (1)
apps/desktop/src/components/settings/ai/shared/list-common.ts (7)
ListModelsResult(14-17)DEFAULT_RESULT(19-19)fetchJson(34-45)partition(52-68)ModelIgnoreReason(4-10)shouldIgnoreCommonKeywords(47-50)REQUEST_TIMEOUT(20-20)
⏰ 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). (2)
- GitHub Check: fmt
- GitHub Check: ci (macos, macos-14)
🔇 Additional comments (8)
apps/desktop/src/components/settings/ai/shared/list-common.ts (2)
1-1: LGTM: Tauri HTTP plugin is the correct choice for desktop apps.Using
tauriFetchfrom@tauri-apps/plugin-httpinstead of nativefetchis appropriate for Tauri desktop applications, as it avoids CORS restrictions and permission issues that can occur with browser-based fetch in desktop contexts.
36-44: LGTM: Enhanced error handling with better debugging context.The changes improve error handling by:
- Including the response body in error messages for better debugging
- Preserving the original error object instead of wrapping it, which maintains stack traces and error types
apps/desktop/src/components/settings/ai/llm/select.tsx (2)
17-26: LGTM: Clean import reorganization reflecting modular structure.The updated imports properly reflect the separation of Anthropic model listing into its own dedicated module, improving modularity and maintainability.
228-230: LGTM: Consistent usage of the new Anthropic model listing function.The function call properly uses the newly imported
listAnthropicModelswith the expected parameters.apps/desktop/src/components/settings/ai/shared/list-anthropic.ts (4)
1-11: LGTM: Appropriate imports for Effect-based async flow.The imports properly bring in Effect utilities for functional composition and shared helpers from
list-common.
31-33: LGTM: Appropriate guard clause for invalid base URL.The early return prevents unnecessary API calls when the base URL is not configured.
42-54: LGTM: Proper model filtering and partitioning logic.The implementation correctly:
- Decodes the response using the schema
- Filters models based on common keywords
- Partitions results into accepted and ignored models
- Extracts the model ID as the key
55-58: LGTM: Appropriate timeout and error handling.The timeout and fallback to
DEFAULT_RESULTon any error ensure the function doesn't hang and provides graceful degradation.
No description provided.