Skip to content

Commit 7df4ed1

Browse files
authored
Merge pull request #698 from n4ze3m/next
v1.5.28
2 parents 182a38d + 318ee84 commit 7df4ed1

File tree

11 files changed

+242
-137
lines changed

11 files changed

+242
-137
lines changed

src/assets/locale/en/openai.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"form": {
7070
"name": {
7171
"label": "Model ID",
72-
"placeholder": "llama3.2",
72+
"placeholder": "deepseek-v3.1",
7373
"required": "Model ID is required."
7474
},
7575
"provider": {

src/components/Common/Playground/Message.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ export const PlaygroundMessage = (props: Props) => {
351351
})
352352
}
353353
}}
354-
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
354+
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-[#242424] hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
355355
{!isSpeaking ? (
356356
<Volume2Icon className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />
357357
) : (
@@ -376,7 +376,7 @@ export const PlaygroundMessage = (props: Props) => {
376376
setIsBtnPressed(false)
377377
}, 2000)
378378
}}
379-
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
379+
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-[#242424] hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
380380
{!isBtnPressed ? (
381381
<CopyIcon className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />
382382
) : (
@@ -395,7 +395,7 @@ export const PlaygroundMessage = (props: Props) => {
395395
title={t("generationInfo")}>
396396
<button
397397
aria-label={t("generationInfo")}
398-
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
398+
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-[#242424] hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
399399
<InfoIcon className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />
400400
</button>
401401
</Popover>
@@ -406,7 +406,7 @@ export const PlaygroundMessage = (props: Props) => {
406406
<button
407407
aria-label={t("regenerate")}
408408
onClick={props.onRengerate}
409-
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
409+
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-[#242424] hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
410410
<RotateCcw className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />
411411
</button>
412412
</Tooltip>
@@ -417,7 +417,7 @@ export const PlaygroundMessage = (props: Props) => {
417417
<button
418418
aria-label={t("newBranch")}
419419
onClick={props?.onNewBranch}
420-
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
420+
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-[#242424] hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
421421
<GitBranchIcon className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />
422422
</button>
423423
</Tooltip>
@@ -428,7 +428,7 @@ export const PlaygroundMessage = (props: Props) => {
428428
<button
429429
aria-label={t("continue")}
430430
onClick={props?.onContinue}
431-
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
431+
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-[#242424] hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
432432
<PlayCircle className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />
433433
</button>
434434
</Tooltip>
@@ -440,7 +440,7 @@ export const PlaygroundMessage = (props: Props) => {
440440
<button
441441
onClick={() => setEditMode(true)}
442442
aria-label={t("edit")}
443-
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
443+
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-[#242424] hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
444444
<Pen className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />
445445
</button>
446446
</Tooltip>
@@ -449,7 +449,7 @@ export const PlaygroundMessage = (props: Props) => {
449449
) : (
450450
// add invisible div to prevent layout shift
451451
<div className="invisible">
452-
<div className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500"></div>
452+
<div className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-[#242424] hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500"></div>
453453
</div>
454454
)}
455455
</div>

src/components/Common/ProviderIcon.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { VllmLogo } from "../Icons/VllmLogo"
2121
import { MoonshotIcon } from "../Icons/Moonshot"
2222
import { XAIIcon } from "../Icons/XAI"
2323
import { HuggingFaceIcon } from "../Icons/HuggingFaceIcon"
24+
import { VercelIcon } from "../Icons/VercelIcon"
2425

2526
export const ProviderIcons = ({
2627
provider,
@@ -76,6 +77,8 @@ export const ProviderIcons = ({
7677
return <XAIIcon className={className} />
7778
case "huggingface":
7879
return <HuggingFaceIcon className={className} />
80+
case "vercel":
81+
return <VercelIcon className={className} />
7982
default:
8083
return <OllamaIcon className={className} />
8184
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from "react"
2+
3+
export const VercelIcon = React.forwardRef<
4+
SVGSVGElement,
5+
React.SVGProps<SVGSVGElement>
6+
>((props, ref) => {
7+
return (
8+
<svg
9+
xmlns="http://www.w3.org/2000/svg"
10+
fill="none"
11+
viewBox="0 0 76 65"
12+
{...props}
13+
ref={ref}>
14+
<path fill="currentColor" d="m37.527 0 37.528 65H0z"></path>
15+
</svg>
16+
)
17+
})

src/components/Option/Models/AddCustomModelModal.tsx

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { createModel } from "@/db/dexie/models"
2-
import { getAllOpenAIConfig } from "@/db/dexie/openai"
2+
import { getAllOpenAIConfig, getOpenAIConfigById } from "@/db/dexie/openai"
3+
import { getAllOpenAIModels } from "@/libs/openai"
34
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
4-
import { Input, Modal, Form, Select, Radio } from "antd"
5+
import { Input, Modal, Form, Select, Radio, AutoComplete, Spin } from "antd"
56
import { Loader2 } from "lucide-react"
67
import { useTranslation } from "react-i18next"
8+
import { useMemo } from "react"
9+
import { ProviderIcons } from "@/components/Common/ProviderIcon"
710

811
type Props = {
912
open: boolean
@@ -14,6 +17,8 @@ export const AddCustomModelModal: React.FC<Props> = ({ open, setOpen }) => {
1417
const { t } = useTranslation(["openai"])
1518
const [form] = Form.useForm()
1619
const queryClient = useQueryClient()
20+
const selectedProviderId = Form.useWatch("provider_id", form)
21+
const searchValue = Form.useWatch("model_id", form)
1722

1823
const { data, isPending } = useQuery({
1924
queryKey: ["fetchProviders"],
@@ -23,6 +28,36 @@ export const AddCustomModelModal: React.FC<Props> = ({ open, setOpen }) => {
2328
}
2429
})
2530

31+
const {
32+
data: providerModels,
33+
isFetching: isFetchingModels,
34+
status: modelsStatus
35+
} = useQuery({
36+
queryKey: ["providerModels", selectedProviderId],
37+
queryFn: async () => {
38+
const config = await getOpenAIConfigById(selectedProviderId as string)
39+
const models = await getAllOpenAIModels({
40+
baseUrl: config.baseUrl,
41+
apiKey: config.apiKey,
42+
customHeaders: config.headers
43+
})
44+
return models
45+
},
46+
enabled: !!selectedProviderId
47+
})
48+
49+
const autoCompleteOptions = useMemo(() => {
50+
const list = providerModels ?? []
51+
const cleaned = list.map((m) => ({
52+
value: m.id,
53+
label: `${m.name ?? m.id}`.replaceAll(/accounts\/[^\/]+\/models\//g, "")
54+
}))
55+
if (searchValue && !cleaned.some((o) => o.value === searchValue)) {
56+
return [{ value: searchValue, label: searchValue }, ...cleaned]
57+
}
58+
return cleaned
59+
}, [providerModels, searchValue])
60+
2661
const onFinish = async (values: {
2762
model_id: string
2863
model_type: "chat" | "embedding"
@@ -68,9 +103,32 @@ export const AddCustomModelModal: React.FC<Props> = ({ open, setOpen }) => {
68103
message: t("manageModels.modal.form.name.required")
69104
}
70105
]}>
71-
<Input
106+
<AutoComplete
107+
options={autoCompleteOptions}
72108
placeholder={t("manageModels.modal.form.name.placeholder")}
73109
size="large"
110+
disabled={!selectedProviderId}
111+
filterOption={(inputValue, option) =>
112+
(option?.label as string)
113+
?.toLowerCase()
114+
.includes(inputValue.toLowerCase()) ||
115+
(option?.value as string)
116+
?.toLowerCase()
117+
.includes(inputValue.toLowerCase())
118+
}
119+
notFoundContent={
120+
selectedProviderId ? (
121+
modelsStatus === "pending" || isFetchingModels ? (
122+
<div className="flex items-center justify-center py-2">
123+
<Spin size="small" />
124+
</div>
125+
) : (
126+
t("noModelFound")
127+
)
128+
) : (
129+
t("manageModels.modal.form.provider.placeholder")
130+
)
131+
}
74132
/>
75133
</Form.Item>
76134

@@ -86,13 +144,35 @@ export const AddCustomModelModal: React.FC<Props> = ({ open, setOpen }) => {
86144
<Select
87145
placeholder={t("manageModels.modal.form.provider.placeholder")}
88146
size="large"
89-
loading={isPending}>
90-
{data?.map((provider: any) => (
147+
loading={isPending}
148+
showSearch
149+
filterOption={(input, option) => {
150+
//@ts-ignore
151+
return (
152+
option?.label?.props["data-title"]
153+
?.toLowerCase()
154+
?.indexOf(input.toLowerCase()) >= 0
155+
)
156+
}}
157+
options={data?.map((e: any) => ({
158+
value: e.id,
159+
label: (
160+
<span
161+
key={e.id}
162+
data-title={e.name}
163+
className="flex flex-row gap-3 items-center ">
164+
<ProviderIcons provider={e?.provider} className="size-4" />
165+
<span className="line-clamp-2">{e.name}</span>
166+
</span>
167+
)
168+
}))}
169+
/>
170+
{/* {data?.map((provider: any) => (
91171
<Select.Option key={provider.id} value={provider.id}>
92172
{provider.name}
93173
</Select.Option>
94-
))}
95-
</Select>
174+
))} */}
175+
{/* </Select> */}
96176
</Form.Item>
97177

98178
<Form.Item

src/components/Option/Settings/sidepanel-rag.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const SidepanelRag = ({ hideBorder }: { hideBorder?: boolean }) => {
66
const { t } = useTranslation("settings")
77
const [chatWithWebsiteEmbedding, setChatWithWebsiteEmbedding] = useStorage(
88
"chatWithWebsiteEmbedding",
9-
true
9+
false
1010
)
1111
const [maxWebsiteContext, setMaxWebsiteContext] = useStorage(
1212
"maxWebsiteContext",

src/components/Sidepanel/Chat/form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
3636
const { t } = useTranslation(["playground", "common"])
3737
const [chatWithWebsiteEmbedding] = useStorage(
3838
"chatWithWebsiteEmbedding",
39-
true
39+
false
4040
)
4141
const form = useForm({
4242
initialValues: {

src/hooks/useMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const useMessage = () => {
7474

7575
const [chatWithWebsiteEmbedding] = useStorage(
7676
"chatWithWebsiteEmbedding",
77-
true
77+
false
7878
)
7979
const [maxWebsiteContext] = useStorage("maxWebsiteContext", 4028)
8080

src/services/kb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const isChatWithWebsiteEnabled = async (): Promise<boolean> => {
66
const isChatWithWebsiteEnabled = await storage.get<boolean | undefined>(
77
"chatWithWebsiteEmbedding"
88
)
9-
return isChatWithWebsiteEnabled ?? true
9+
return isChatWithWebsiteEnabled ?? false
1010
}
1111

1212

0 commit comments

Comments
 (0)