Skip to content

Commit ac8cadc

Browse files
authored
feat: update config ui (#73)
1 parent 147ee42 commit ac8cadc

File tree

6 files changed

+99
-38
lines changed

6 files changed

+99
-38
lines changed

app/api/chat/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { MODELS, SYSTEM_PROMPT_DEFAULT } from "@/lib/config"
44
import { sanitizeUserInput } from "@/lib/sanitize"
55
import { validateUserIdentity } from "@/lib/server/api"
66
import { Attachment } from "@ai-sdk/ui-utils"
7-
import { Message as MessageAISDK, streamText } from "ai"
87
import { createOpenRouter } from "@openrouter/ai-sdk-provider"
9-
8+
import { Message as MessageAISDK, streamText } from "ai"
109

1110
// Maximum allowed duration for streaming (in seconds)
1211
export const maxDuration = 30
@@ -79,11 +78,12 @@ export async function POST(req: Request) {
7978
}
8079

8180
const modelConfig = MODELS.find((m) => m.id === model)
82-
if (!modelConfig){
81+
82+
if (!modelConfig) {
8383
throw new Error(`Model ${model} not found`)
8484
}
8585
let modelInstance
86-
if (modelConfig.provider === 'openrouter') {
86+
if (modelConfig.provider === "openrouter") {
8787
const openRouter = createOpenRouter({
8888
apiKey: process.env.OPENROUTER_API_KEY,
8989
})

app/components/chat-input/select-model.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export function SelectModel({
4646
</TooltipTrigger>
4747
<TooltipContent>Select a model</TooltipContent>
4848
</Tooltip>
49-
5049
<PopoverContentAuth />
5150
</Popover>
5251
)

components/common/model-selector.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ export function ModelSelector({
2929
className,
3030
}: ModelSelectorProps) {
3131
const model = MODELS_OPTIONS.find((model) => model.id === selectedModelId)
32-
const provider = PROVIDERS_OPTIONS.find(
33-
(provider) => provider.id === model?.provider
34-
)
3532

3633
return (
3734
<TooltipProvider>
@@ -46,14 +43,14 @@ export function ModelSelector({
4643
)}
4744
>
4845
<div className="flex items-center gap-2">
49-
{provider?.icon && <provider.icon className="size-5" />}
46+
{model?.icon && <model.icon className="size-5" />}
5047
<span>{model?.name}</span>
5148
</div>
5249
<CaretDown className="size-4 opacity-50" />
5350
</Button>
5451
</DropdownMenuTrigger>
5552
<DropdownMenuContent
56-
className="max-h-[400px] w-[400px] overflow-y-auto"
53+
className="flex max-h-[400px] w-[400px] flex-col space-y-0.5 overflow-y-auto"
5754
align="start"
5855
sideOffset={4}
5956
>
@@ -82,7 +79,7 @@ export function ModelSelector({
8279
onClick={() => model.available && setSelectedModelId(model.id)}
8380
>
8481
<div className="flex items-center gap-3">
85-
{provider?.icon && <provider.icon className="size-5" />}
82+
{model?.icon && <model.icon className="size-5" />}
8683
<div className="flex flex-col gap-0">
8784
<span className="text-base">{model.name}</span>
8885
<span className="text-muted-foreground text-xs">

components/icons/deepseek.tsx

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
import * as React from "react"
22
import type { SVGProps } from "react"
33

4-
const Icon = (props: SVGProps<SVGSVGElement>) => (
5-
<svg
6-
xmlns="http://www.w3.org/2000/svg"
7-
width={64}
8-
height={64}
9-
viewBox="0 0 64 64"
10-
fill="none"
11-
{...props}
12-
>
13-
<g clipPath="url(#a)">
4+
export default function DeepSeekIcon(props: SVGProps<SVGSVGElement>) {
5+
return (
6+
<svg
7+
width={24}
8+
height={24}
9+
viewBox="0 0 24 24"
10+
xmlns="http://www.w3.org/2000/svg"
11+
fill="none"
12+
{...props}
13+
>
1414
<path
15+
d="M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z"
1516
fill="#4D6BFE"
16-
d="M63.328 11.952c-.677-.33-.97.301-1.365.624-.136.104-.25.24-.366.363-.992 1.058-2.149 1.752-3.66 1.669-2.212-.123-4.1.57-5.769 2.261-.355-2.085-1.533-3.328-3.325-4.128-.939-.416-1.888-.829-2.547-1.733-.459-.643-.584-1.36-.813-2.064-.147-.427-.294-.861-.782-.933-.533-.083-.74.362-.949.736-.835 1.525-1.157 3.205-1.125 4.906.072 3.83 1.688 6.88 4.901 9.048.365.248.459.499.344.862-.219.746-.48 1.472-.71 2.221-.146.477-.365.579-.877.373a14.7 14.7 0 0 1-4.629-3.146c-2.285-2.208-4.35-4.646-6.925-6.555q-.896-.662-1.838-1.256c-2.626-2.552.347-4.648 1.035-4.896.72-.261.248-1.152-2.077-1.141s-4.454.786-7.166 1.824a8 8 0 0 1-1.24.365 25.6 25.6 0 0 0-7.688-.272c-5.026.56-9.04 2.939-11.992 6.995C.22 22.949-.615 28.49.405 34.267 1.48 40.357 4.59 45.4 9.365 49.34c4.955 4.088 10.66 6.091 17.168 5.707 3.952-.227 8.355-.757 13.318-4.96 1.253.624 2.565.872 4.746 1.059 1.68.157 3.296-.08 4.547-.342 1.96-.416 1.824-2.232 1.117-2.562-5.746-2.678-4.485-1.587-5.634-2.47 2.922-3.456 7.322-7.045 9.045-18.674.133-.926.019-1.507 0-2.254-.01-.453.093-.632.613-.682 1.443-.15 2.843-.58 4.12-1.267 3.723-2.035 5.227-5.373 5.582-9.379.053-.613-.01-1.242-.659-1.565M30.883 48c-5.57-4.379-8.272-5.821-9.387-5.76-1.045.064-.856 1.256-.627 2.035.24.768.552 1.296.99 1.97.304.446.512 1.11-.302 1.608-1.794 1.11-4.912-.373-5.058-.445-3.63-2.139-6.667-4.96-8.803-8.819-2.064-3.714-3.264-7.698-3.461-11.952-.054-1.029.248-1.392 1.272-1.578a12.5 12.5 0 0 1 4.077-.104c5.685.832 10.523 3.373 14.581 7.397 2.315 2.293 4.067 5.032 5.872 7.71 1.92 2.842 3.984 5.551 6.614 7.77.928.779 1.666 1.37 2.376 1.805-2.139.24-5.707.294-8.144-1.637m2.666-17.173a.817.817 0 0 1 1.107-.766.805.805 0 0 1 .533.768.815.815 0 0 1-.826.819.81.81 0 0 1-.753-.507.8.8 0 0 1-.06-.314m8.294 4.256c-.534.216-1.064.402-1.574.426a3.32 3.32 0 0 1-2.128-.677c-.73-.613-1.253-.955-1.472-2.021a4.6 4.6 0 0 1 .043-1.568c.187-.872-.021-1.432-.637-1.939-.499-.416-1.136-.53-1.835-.53a1.5 1.5 0 0 1-.677-.209c-.294-.144-.534-.506-.304-.954.074-.144.426-.496.512-.56.95-.539 2.045-.363 3.056.042.938.384 1.648 1.088 2.67 2.086 1.042 1.202 1.231 1.536 1.826 2.437.47.707.896 1.432 1.186 2.261.18.52-.05.944-.666 1.206"
1717
/>
18-
</g>
19-
<defs>
20-
<clipPath id="a">
21-
<path fill="#fff" d="M0 0h64v64H0z" />
22-
</clipPath>
23-
</defs>
24-
</svg>
25-
)
26-
export default Icon
18+
</svg>
19+
)
20+
}

lib/config.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ export type Model = {
4040
enabled: boolean
4141
}[]
4242
description?: string
43+
icon: React.ComponentType<React.SVGProps<SVGSVGElement>>
4344
}
4445

4546
export const MODELS_NOT_AVAILABLE = [
46-
4747
{
4848
id: "gemini-1.5-pro",
4949
name: "Gemini 1.5 Pro",
@@ -56,6 +56,7 @@ export const MODELS_NOT_AVAILABLE = [
5656
enabled: true,
5757
},
5858
],
59+
icon: Gemini,
5960
},
6061
{
6162
id: "claude-3-5-sonnet",
@@ -69,6 +70,7 @@ export const MODELS_NOT_AVAILABLE = [
6970
enabled: true,
7071
},
7172
],
73+
icon: Claude,
7274
},
7375
{
7476
id: "claude-3.7-sonnet",
@@ -82,6 +84,7 @@ export const MODELS_NOT_AVAILABLE = [
8284
enabled: true,
8385
},
8486
],
87+
icon: Claude,
8588
},
8689
{
8790
id: "grok-2",
@@ -95,6 +98,7 @@ export const MODELS_NOT_AVAILABLE = [
9598
enabled: true,
9699
},
97100
],
101+
icon: Grok,
98102
},
99103
{
100104
id: "gemini-2.0-flash",
@@ -108,6 +112,7 @@ export const MODELS_NOT_AVAILABLE = [
108112
enabled: true,
109113
},
110114
],
115+
icon: Gemini,
111116
},
112117
{
113118
id: "gemini-2.5-pro",
@@ -121,6 +126,7 @@ export const MODELS_NOT_AVAILABLE = [
121126
enabled: true,
122127
},
123128
],
129+
icon: Gemini,
124130
},
125131
] as Model[]
126132

@@ -136,9 +142,9 @@ export const MODELS = [
136142
},
137143
],
138144
api_sdk: openai("gpt-4.1"),
139-
icon: OpenAI,
140145
description:
141146
"OpenAI’s most powerful model. Excellent at coding, writing, and complex tasks.",
147+
icon: OpenAI,
142148
},
143149
{
144150
id: "gpt-4.1-mini",
@@ -151,9 +157,9 @@ export const MODELS = [
151157
},
152158
],
153159
api_sdk: openai("gpt-4.1-mini"),
154-
icon: OpenAI,
155160
description:
156161
"Fast and smart — a great balance for most tasks. Outperforms GPT‑4o mini.",
162+
icon: OpenAI,
157163
},
158164
{
159165
id: "gpt-4.1-nano",
@@ -166,9 +172,9 @@ export const MODELS = [
166172
},
167173
],
168174
api_sdk: openai("gpt-4.1-nano"),
169-
icon: OpenAI,
170175
description:
171176
"Ultra fast and cheap. Ideal for simple tasks, summaries, or classification.",
177+
icon: OpenAI,
172178
},
173179
{
174180
id: "pixtral-large-latest",
@@ -183,6 +189,7 @@ export const MODELS = [
183189
api_sdk: mistral("pixtral-large-latest"),
184190
description:
185191
"Mistral’s flagship model. Great for reasoning, writing, and advanced tasks.",
192+
icon: Mistral,
186193
},
187194
{
188195
id: "mistral-large-latest",
@@ -195,8 +202,9 @@ export const MODELS = [
195202
},
196203
],
197204
api_sdk: mistral("mistral-large-latest"),
205+
description:
206+
"Fine-tuned for chat. A lighter, faster option for everyday use.",
198207
icon: Mistral,
199-
description: "Fine-tuned for chat. A lighter, faster option for everyday use.",
200208
},
201209
{
202210
id: "deepseek-r1",
@@ -211,6 +219,7 @@ export const MODELS = [
211219
api_sdk: "deepseek/deepseek-r1:free", // this is a special case for openrouter
212220
description:
213221
"A reasoning-first model trained with reinforcement learning, built for math, code, and complex problem solving",
222+
icon: DeepSeek,
214223
},
215224
] as Model[]
216225

@@ -272,6 +281,11 @@ export const PROVIDERS = [
272281
name: "Mistral",
273282
icon: Mistral,
274283
},
284+
{
285+
id: "deepseek",
286+
name: "DeepSeek",
287+
icon: DeepSeek,
288+
},
275289
] as Provider[]
276290

277291
export const PROVIDERS_OPTIONS = [

package-lock.json

Lines changed: 59 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)