-
-
Notifications
You must be signed in to change notification settings - Fork 95
feat: support Claude models #22
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,5 @@ | ||||||||||||||||||||||||||||||||||||||||||
| import { useCompletion } from '@ai-sdk/react'; | ||||||||||||||||||||||||||||||||||||||||||
| import { useAPIKeyStore } from '@/frontend/stores/APIKeyStore'; | ||||||||||||||||||||||||||||||||||||||||||
| import { toast } from 'sonner'; | ||||||||||||||||||||||||||||||||||||||||||
| import { createMessageSummary, updateThread } from '@/frontend/dexie/queries'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| interface MessageSummaryPayload { | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -22,18 +21,14 @@ export const useMessageSummary = () => { | |||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||
| const payload: MessageSummaryPayload = await response.json(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if (response.ok) { | ||||||||||||||||||||||||||||||||||||||||||
| const { title, isTitle, messageId, threadId } = payload; | ||||||||||||||||||||||||||||||||||||||||||
| const { title, isTitle, messageId, threadId } = payload; | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
22
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Restore proper error handling for HTTP responses. Removing the onResponse: async (response) => {
try {
+ if (!response.ok) {
+ console.error('Request failed:', response.status, response.statusText);
+ return;
+ }
const payload: MessageSummaryPayload = await response.json();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if (isTitle) { | ||||||||||||||||||||||||||||||||||||||||||
| await updateThread(threadId, title); | ||||||||||||||||||||||||||||||||||||||||||
| await createMessageSummary(threadId, messageId, title); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| await createMessageSummary(threadId, messageId, title); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| toast.error('Failed to generate a summary for the message'); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||
| console.error(error); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,8 @@ export const AI_MODELS = [ | |||||||||||||||||||||||||||||||||||||||||
| 'Gemini 2.5 Flash', | ||||||||||||||||||||||||||||||||||||||||||
| 'GPT-4o', | ||||||||||||||||||||||||||||||||||||||||||
| 'GPT-4.1-mini', | ||||||||||||||||||||||||||||||||||||||||||
| 'Claude 3.7 Sonnet', | ||||||||||||||||||||||||||||||||||||||||||
| 'Claude 3.5 Sonnet' | ||||||||||||||||||||||||||||||||||||||||||
| ] as const; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export type AIModel = (typeof AI_MODELS)[number]; | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -18,6 +20,16 @@ export type ModelConfig = { | |||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export const MODEL_CONFIGS = { | ||||||||||||||||||||||||||||||||||||||||||
| 'Claude 3.7 Sonnet': { | ||||||||||||||||||||||||||||||||||||||||||
| modelId: 'claude-3-7-sonnet-20250219', | ||||||||||||||||||||||||||||||||||||||||||
| provider: 'llmgateway', | ||||||||||||||||||||||||||||||||||||||||||
| headerKey: 'Authorization', | ||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
| 'Claude 3.5 Sonnet': { | ||||||||||||||||||||||||||||||||||||||||||
| modelId: 'claude-3-5-sonnet-20241022', | ||||||||||||||||||||||||||||||||||||||||||
| provider: 'llmgateway', | ||||||||||||||||||||||||||||||||||||||||||
| headerKey: 'Authorization', | ||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+23
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify Claude model IDs and Authorization header usage. The model configurations follow the established pattern. However, please verify:
🌐 Web query: 💡 Result: The model IDs for Claude 3.5 Sonnet and Claude 3.7 Sonnet are as follows:
These identifiers are used across various platforms, including Anthropic's API, AWS Bedrock, and Google Cloud's Vertex AI. (docs.anthropic.com) Regarding the API key header format for the Citations: Update Claude 3.5 Sonnet model ID and confirm llmgateway Authorization header
Suggested diff: 'Claude 3.7 Sonnet': {
modelId: 'claude-3-7-sonnet-20250219',
provider: 'llmgateway',
headerKey: 'Authorization',
},
- 'Claude 3.5 Sonnet': {
- modelId: 'claude-3-5-sonnet-20241022',
+ 'Claude 3.5 Sonnet': {
+ modelId: 'claude-3-5-sonnet-20240620',
provider: 'llmgateway',
headerKey: 'Authorization',
},📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| 'Deepseek R1 0528': { | ||||||||||||||||||||||||||||||||||||||||||
| modelId: 'deepseek/deepseek-r1-0528:free', | ||||||||||||||||||||||||||||||||||||||||||
| provider: 'openrouter', | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Fix variable scoping in switch statement.
The static analysis correctly identifies a scoping issue with variable declarations in switch cases. Variables declared in one case can be accessed by other cases, which can lead to unexpected behavior.
Apply this diff to fix the scoping issue by wrapping declarations in blocks:
let aiModel; switch (modelConfig.provider) { - case "google": + case "google": { const google = createGoogleGenerativeAI({ apiKey }); aiModel = google(modelConfig.modelId); break; + } - case "openai": + case "openai": { const openai = createOpenAI({ apiKey }); aiModel = openai(modelConfig.modelId); break; + } - case "openrouter": + case "openrouter": { const openrouter = createOpenRouter({ apiKey }); aiModel = openrouter(modelConfig.modelId); break; + } - case "llmgateway": + case "llmgateway": { const llmgateway = createLLMGateway({ apiKey }); aiModel = llmgateway(modelConfig.modelId); break; + } default: return new Response(🧰 Tools
🪛 Biome (1.9.4)
[error] 24-24: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 29-29: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 34-34: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 39-39: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
🤖 Prompt for AI Agents