Skip to content

Commit 55f00b0

Browse files
authored
fix: custom llm provider (#1360)
1 parent ef42ac3 commit 55f00b0

File tree

1 file changed

+82
-37
lines changed

1 file changed

+82
-37
lines changed

web/src/app/workspace/providers/[providerName]/models/model-actions.tsx

Lines changed: 82 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import {
1515
DialogTitle,
1616
DialogTrigger,
1717
} from '@/components/ui/dialog';
18+
import {
19+
DropdownMenu,
20+
DropdownMenuContent,
21+
DropdownMenuItem,
22+
DropdownMenuTrigger,
23+
} from '@/components/ui/dropdown-menu';
1824
import {
1925
Form,
2026
FormControl,
@@ -26,16 +32,10 @@ import {
2632
import { Input } from '@/components/ui/input';
2733
import { Label } from '@/components/ui/label';
2834
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
29-
import {
30-
Select,
31-
SelectContent,
32-
SelectItem,
33-
SelectTrigger,
34-
SelectValue,
35-
} from '@/components/ui/select';
3635
import { apiClient } from '@/lib/api/client';
3736
import { zodResolver } from '@hookform/resolvers/zod';
3837
import { Slot } from '@radix-ui/react-slot';
38+
import { ChevronDown } from 'lucide-react';
3939
import { useTranslations } from 'next-intl';
4040
import { useRouter } from 'next/navigation';
4141
import { useCallback, useState } from 'react';
@@ -49,6 +49,45 @@ const defaultValue = {
4949
api: LlmProviderModelCreateApiEnum.completion,
5050
};
5151

52+
const providers = [
53+
{
54+
label: 'AlibabaCloud',
55+
value: 'alibabacloud',
56+
},
57+
{
58+
label: 'Anthropic',
59+
value: 'anthropic',
60+
},
61+
{
62+
label: 'DeepSeek',
63+
value: 'deepseek',
64+
},
65+
{
66+
label: 'Google Gemini',
67+
value: 'gemini',
68+
},
69+
{
70+
label: 'Jina AI',
71+
value: 'jina',
72+
},
73+
{
74+
label: 'OpenAI',
75+
value: 'openai',
76+
},
77+
{
78+
label: 'OpenRouter',
79+
value: 'openrouter',
80+
},
81+
{
82+
label: 'SiliconFlow',
83+
value: 'siliconflow',
84+
},
85+
{
86+
label: 'xAI',
87+
value: 'xai',
88+
},
89+
];
90+
5291
const modelSchema = z.object({
5392
model: z.string().min(1),
5493
api: z.string().min(1),
@@ -295,36 +334,42 @@ export const ModelActions = ({
295334
<FormLabel>
296335
{page_models('model.custom_llm_provider')}
297336
</FormLabel>
298-
<FormControl>
299-
<Select
300-
{...field}
301-
onValueChange={field.onChange}
302-
value={field.value || ''}
303-
>
304-
<SelectTrigger className="w-full cursor-pointer">
305-
<SelectValue
306-
placeholder={page_models(
307-
'model.custom_llm_provider_placeholder',
308-
)}
309-
/>
310-
</SelectTrigger>
311-
<SelectContent>
312-
<SelectItem value="alibabacloud">
313-
AlibabaCloud
314-
</SelectItem>
315-
<SelectItem value="anthropic">Anthropic</SelectItem>
316-
<SelectItem value="deepseek">DeepSeek</SelectItem>
317-
<SelectItem value="gemini">Google Gemini</SelectItem>
318-
<SelectItem value="jina">Jina AI</SelectItem>
319-
<SelectItem value="openai">OpenAI</SelectItem>
320-
<SelectItem value="openrouter">OpenRouter</SelectItem>
321-
<SelectItem value="siliconflow">
322-
SiliconFlow
323-
</SelectItem>
324-
<SelectItem value="xai">xAI</SelectItem>
325-
</SelectContent>
326-
</Select>
327-
</FormControl>
337+
338+
<div className="relative flex flex-row">
339+
<FormControl>
340+
<Input
341+
{...field}
342+
placeholder={page_models(
343+
'model.custom_llm_provider_placeholder',
344+
)}
345+
/>
346+
</FormControl>
347+
348+
<DropdownMenu>
349+
<DropdownMenuTrigger className="absolute top-0.5 right-0.5">
350+
<Button variant="ghost" className="size-8">
351+
<ChevronDown />
352+
</Button>
353+
</DropdownMenuTrigger>
354+
<DropdownMenuContent align="end" className="w-115.5">
355+
{providers.map((provider) => {
356+
return (
357+
<DropdownMenuItem
358+
key={provider.value}
359+
onClick={() =>
360+
form.setValue(
361+
'custom_llm_provider',
362+
provider.value,
363+
)
364+
}
365+
>
366+
{provider.label}
367+
</DropdownMenuItem>
368+
);
369+
})}
370+
</DropdownMenuContent>
371+
</DropdownMenu>
372+
</div>
328373
</FormItem>
329374
)}
330375
/>

0 commit comments

Comments
 (0)