-
Notifications
You must be signed in to change notification settings - Fork 207
Add DeepSeek Model Support via OpenRouter Integration #57
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
Changes from 3 commits
b949c60
16088d5
479ba4a
d1da823
7d2b74f
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 |
---|---|---|
|
@@ -111,11 +111,11 @@ export function Chat() { | |
errorMsg = parsed.error || errorMsg | ||
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. remove changes here too |
||
} catch { | ||
errorMsg = error.message || errorMsg | ||
} | ||
toast({ | ||
title: errorMsg, | ||
status: "error", | ||
}) | ||
} | ||
toast({ | ||
title: errorMsg, | ||
status: "error", | ||
}) | ||
} | ||
}, [error]) | ||
|
||
|
@@ -164,7 +164,7 @@ export function Chat() { | |
const rateData = await checkRateLimits(uid, isAuthenticated) | ||
|
||
if (rateData.remaining === 0 && !isAuthenticated) { | ||
setHasDialogAuth(true) | ||
setHasDialogAuth(true) | ||
return false | ||
} | ||
|
||
|
@@ -304,23 +304,23 @@ export function Chat() { | |
if (!uid) return | ||
|
||
const optimisticId = `optimistic-${Date.now().toString()}` | ||
const optimisticAttachments = | ||
files.length > 0 ? createOptimisticAttachments(files) : [] | ||
|
||
const optimisticMessage = { | ||
id: optimisticId, | ||
content: input, | ||
role: "user" as const, | ||
createdAt: new Date(), | ||
experimental_attachments: | ||
optimisticAttachments.length > 0 ? optimisticAttachments : undefined, | ||
} | ||
const optimisticAttachments = | ||
files.length > 0 ? createOptimisticAttachments(files) : [] | ||
|
||
setMessages((prev) => [...prev, optimisticMessage]) | ||
setInput("") | ||
const optimisticMessage = { | ||
id: optimisticId, | ||
content: input, | ||
role: "user" as const, | ||
createdAt: new Date(), | ||
experimental_attachments: | ||
optimisticAttachments.length > 0 ? optimisticAttachments : undefined, | ||
} | ||
|
||
const submittedFiles = [...files] | ||
setFiles([]) | ||
setMessages((prev) => [...prev, optimisticMessage]) | ||
setInput("") | ||
|
||
const submittedFiles = [...files] | ||
setFiles([]) | ||
|
||
const allowed = await checkLimitsAndNotify(uid) | ||
if (!allowed) { | ||
|
@@ -332,33 +332,33 @@ export function Chat() { | |
|
||
const currentChatId = await ensureChatExists(uid) | ||
if (!currentChatId) { | ||
setMessages((prev) => prev.filter((msg) => msg.id !== optimisticId)) | ||
cleanupOptimisticAttachments(optimisticMessage.experimental_attachments) | ||
setIsSubmitting(false) | ||
return | ||
} | ||
setMessages((prev) => prev.filter((msg) => msg.id !== optimisticId)) | ||
cleanupOptimisticAttachments(optimisticMessage.experimental_attachments) | ||
setIsSubmitting(false) | ||
return | ||
} | ||
|
||
if (input.length > MESSAGE_MAX_LENGTH) { | ||
toast({ | ||
title: `The message you submitted was too long, please submit something shorter. (Max ${MESSAGE_MAX_LENGTH} characters)`, | ||
status: "error", | ||
}) | ||
if (input.length > MESSAGE_MAX_LENGTH) { | ||
toast({ | ||
title: `The message you submitted was too long, please submit something shorter. (Max ${MESSAGE_MAX_LENGTH} characters)`, | ||
status: "error", | ||
}) | ||
setMessages((prev) => prev.filter((msg) => msg.id !== optimisticId)) | ||
cleanupOptimisticAttachments(optimisticMessage.experimental_attachments) | ||
setIsSubmitting(false) | ||
return | ||
} | ||
|
||
let attachments: Attachment[] | null = [] | ||
if (submittedFiles.length > 0) { | ||
attachments = await handleFileUploads(uid, currentChatId) | ||
if (attachments === null) { | ||
setMessages((prev) => prev.filter((m) => m.id !== optimisticId)) | ||
cleanupOptimisticAttachments(optimisticMessage.experimental_attachments) | ||
setIsSubmitting(false) | ||
return | ||
} | ||
} | ||
|
||
let attachments: Attachment[] | null = [] | ||
if (submittedFiles.length > 0) { | ||
attachments = await handleFileUploads(uid, currentChatId) | ||
if (attachments === null) { | ||
setMessages((prev) => prev.filter((m) => m.id !== optimisticId)) | ||
cleanupOptimisticAttachments(optimisticMessage.experimental_attachments) | ||
setIsSubmitting(false) | ||
return | ||
} | ||
} | ||
|
||
const options = { | ||
body: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as React from "react" | ||
import type { SVGProps } from "react" | ||
|
||
const Icon = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg fill="none" | ||
fillRule="evenodd" | ||
style={{ flex: "none", lineHeight: "1" }} | ||
height={64} | ||
width={64} | ||
viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
|
||
<path fill="#000" | ||
fillRule="evenodd" | ||
d="M42.01 4.893l18.05 10.263v0.218l-18.235 10.153 0.043-5.293-2.053-0.075c-2.648-0.07-4.028 0.005-5.67 0.275-2.66 0.438-5.095 1.443-7.868 3.38l-5.415 3.743c-0.71 0.488-1.238 0.84-1.7 1.138l-1.288 0.805-0.993 0.585 0.963 0.575 1.325 0.845c1.19 0.785 2.925 1.99 6.753 4.665 2.775 1.938 5.208 2.943 7.868 3.38l0.75 0.113c1.735 0.228 3.438 0.235 7.063 0.083l0.055-5.398 18.05 10.263v0.218L41.473 55l0.035-4.655-1.588 0.055c-3.465 0.105-5.343 0.005-7.845-0.405-4.235-0.7-8.15-2.315-12.203-5.148l-5.395-3.75a54.993 54.993 0 01-1.888-1.245l-1.168-0.7a139.818 139.818 0 01-1.9-1.075C7.27 36.825 1.408 35.29 0 35.29V24.72l0.35 0.01c1.41-0.018 7.275-1.555 9.523-2.81l2.54-1.45 1.095-0.685c1.07-0.7 2.68-1.815 6.715-4.633 4.053-2.833 7.965-4.45 12.203-5.148 2.88-0.475 4.935-0.533 9.535-0.345l0.05-4.768z" | ||
clipRule="evenodd"> | ||
</path> | ||
</svg> | ||
) | ||
|
||
export default Icon |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import Gemini from "@/components/icons/gemini" | |
import Grok from "@/components/icons/grok" | ||
import Mistral from "@/components/icons/mistral" | ||
import OpenAI from "@/components/icons/openai" | ||
import OpenRouter from "@/components/icons/openrouter" | ||
import { mistral } from "@ai-sdk/mistral" | ||
import { openai } from "@ai-sdk/openai" | ||
import { | ||
|
@@ -41,19 +42,7 @@ export type Model = { | |
} | ||
|
||
export const MODELS_NOT_AVAILABLE = [ | ||
{ | ||
id: "deepseek-r1", | ||
name: "DeepSeek R1", | ||
provider: "deepseek", | ||
available: false, | ||
api_sdk: false, | ||
features: [ | ||
{ | ||
id: "file-upload", | ||
enabled: false, | ||
}, | ||
], | ||
}, | ||
|
||
{ | ||
id: "gemini-1.5-pro", | ||
name: "Gemini 1.5 Pro", | ||
|
@@ -205,6 +194,19 @@ export const MODELS = [ | |
}, | ||
], | ||
api_sdk: mistral("mistral-large-latest"), | ||
icon: Mistral, | ||
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. keep description:
"Fine-tuned for chat. A lighter, faster option for everyday use.", |
||
}, | ||
{ | ||
id: "deepseek-r1", | ||
name: "DeepSeek R1", | ||
provider: "openrouter", | ||
features: [ | ||
{ | ||
id: "file-upload", | ||
enabled: true, | ||
}, | ||
], | ||
api_sdk: "deepseek/deepseek-r1:free", // this is a special case for openrouter | ||
description: | ||
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. add description for |
||
"Fine-tuned for chat. A lighter, faster option for everyday use.", | ||
}, | ||
|
@@ -253,6 +255,11 @@ const PROVIDERS_NOT_AVAILABLE = [ | |
] as Provider[] | ||
|
||
export const PROVIDERS = [ | ||
{ | ||
id: "openrouter", | ||
name: "OpenRouter", | ||
icon: OpenRouter, | ||
}, | ||
{ | ||
id: "openai", | ||
name: "OpenAI", | ||
|
@@ -410,7 +417,7 @@ export const SUGGESTIONS = [ | |
highlight: "Explain", | ||
prompt: `Explain`, | ||
items: [ | ||
"Explain quantum physics like I’m 10", | ||
"Explain quantum physics like I'm 10", | ||
"Explain stoicism in simple terms", | ||
"Explain how a neural network works", | ||
"Explain the difference between AI and AGI", | ||
|
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