2024-05-24 21:01:10 +05:30
|
|
|
import { BetaTag } from "@/components/Common/Beta"
|
2024-05-23 00:39:44 +05:30
|
|
|
import { SaveButton } from "@/components/Common/SaveButton"
|
|
|
|
|
import { getAllModelSettings, setModelSetting } from "@/services/model-settings"
|
|
|
|
|
import { useQuery, useQueryClient } from "@tanstack/react-query"
|
2024-05-24 20:00:09 +05:30
|
|
|
import { Form, Skeleton, Input, InputNumber, Collapse } from "antd"
|
2024-05-23 00:39:44 +05:30
|
|
|
import React from "react"
|
|
|
|
|
import { useTranslation } from "react-i18next"
|
2024-05-24 21:01:10 +05:30
|
|
|
|
2024-05-23 00:39:44 +05:30
|
|
|
export const ModelSettings = () => {
|
|
|
|
|
const { t } = useTranslation("common")
|
|
|
|
|
const [form] = Form.useForm()
|
|
|
|
|
const client = useQueryClient()
|
|
|
|
|
const { isPending: isLoading } = useQuery({
|
|
|
|
|
queryKey: ["fetchModelConfig"],
|
|
|
|
|
queryFn: async () => {
|
|
|
|
|
const data = await getAllModelSettings()
|
|
|
|
|
form.setFieldsValue(data)
|
|
|
|
|
return data
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div>
|
2024-05-24 21:19:53 +05:30
|
|
|
<div className="inline-flex items-center gap-2">
|
2024-08-20 16:11:50 +05:30
|
|
|
<BetaTag />
|
|
|
|
|
<h2 className="text-base font-semibold leading-7 text-gray-900 dark:text-white">
|
|
|
|
|
{t("modelSettings.label")}
|
|
|
|
|
</h2>
|
2024-05-24 21:01:10 +05:30
|
|
|
</div>
|
2024-06-03 00:30:10 +05:30
|
|
|
<p className="text-sm text-gray-700 dark:text-neutral-400 mt-1">
|
2024-05-23 00:39:44 +05:30
|
|
|
{t("modelSettings.description")}
|
|
|
|
|
</p>
|
|
|
|
|
<div className="border border-b border-gray-200 dark:border-gray-600 mt-3 mb-6"></div>
|
|
|
|
|
</div>
|
|
|
|
|
{!isLoading ? (
|
|
|
|
|
<Form
|
|
|
|
|
onFinish={(values: {
|
|
|
|
|
keepAlive: string
|
|
|
|
|
temperature: number
|
|
|
|
|
topK: number
|
|
|
|
|
topP: number
|
2024-08-20 16:11:50 +05:30
|
|
|
numGpu: number
|
2024-05-23 00:39:44 +05:30
|
|
|
}) => {
|
|
|
|
|
Object.entries(values).forEach(([key, value]) => {
|
|
|
|
|
setModelSetting(key, value)
|
|
|
|
|
})
|
|
|
|
|
client.invalidateQueries({
|
|
|
|
|
queryKey: ["fetchModelConfig"]
|
|
|
|
|
})
|
|
|
|
|
}}
|
|
|
|
|
form={form}
|
|
|
|
|
layout="vertical">
|
|
|
|
|
<Form.Item
|
|
|
|
|
name="keepAlive"
|
|
|
|
|
help={t("modelSettings.form.keepAlive.help")}
|
|
|
|
|
label={t("modelSettings.form.keepAlive.label")}>
|
|
|
|
|
<Input
|
|
|
|
|
size="large"
|
|
|
|
|
placeholder={t("modelSettings.form.keepAlive.placeholder")}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
|
|
|
|
name="temperature"
|
|
|
|
|
label={t("modelSettings.form.temperature.label")}>
|
|
|
|
|
<InputNumber
|
|
|
|
|
size="large"
|
|
|
|
|
style={{ width: "100%" }}
|
|
|
|
|
placeholder={t("modelSettings.form.temperature.placeholder")}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item name="numCtx" label={t("modelSettings.form.numCtx.label")}>
|
|
|
|
|
<InputNumber
|
|
|
|
|
style={{ width: "100%" }}
|
|
|
|
|
placeholder={t("modelSettings.form.numCtx.placeholder")}
|
|
|
|
|
size="large"
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
2024-11-09 16:56:47 +05:30
|
|
|
<Form.Item
|
|
|
|
|
name="numPredict"
|
|
|
|
|
label={t("modelSettings.form.numPredict.label")}>
|
|
|
|
|
<InputNumber
|
|
|
|
|
style={{ width: "100%" }}
|
|
|
|
|
placeholder={t("modelSettings.form.numPredict.placeholder")}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
2024-05-23 00:39:44 +05:30
|
|
|
<Collapse
|
|
|
|
|
ghost
|
|
|
|
|
className="border-none bg-transparent"
|
|
|
|
|
items={[
|
|
|
|
|
{
|
|
|
|
|
key: "1",
|
|
|
|
|
label: t("modelSettings.advanced"),
|
|
|
|
|
children: (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<Form.Item
|
|
|
|
|
name="topK"
|
|
|
|
|
label={t("modelSettings.form.topK.label")}>
|
|
|
|
|
<InputNumber
|
|
|
|
|
style={{ width: "100%" }}
|
|
|
|
|
placeholder={t("modelSettings.form.topK.placeholder")}
|
|
|
|
|
size="large"
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
name="topP"
|
|
|
|
|
label={t("modelSettings.form.topP.label")}>
|
|
|
|
|
<InputNumber
|
|
|
|
|
style={{ width: "100%" }}
|
|
|
|
|
size="large"
|
|
|
|
|
placeholder={t("modelSettings.form.topP.placeholder")}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
2024-08-20 16:11:50 +05:30
|
|
|
<Form.Item
|
|
|
|
|
name="numGpu"
|
|
|
|
|
label={t("modelSettings.form.numGpu.label")}>
|
|
|
|
|
<InputNumber
|
|
|
|
|
style={{ width: "100%" }}
|
|
|
|
|
size="large"
|
|
|
|
|
placeholder={t(
|
|
|
|
|
"modelSettings.form.numGpu.placeholder"
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</Form.Item>
|
2024-05-23 00:39:44 +05:30
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div className="flex justify-end">
|
|
|
|
|
<SaveButton btnType="submit" />
|
|
|
|
|
</div>
|
|
|
|
|
</Form>
|
|
|
|
|
) : (
|
|
|
|
|
<Skeleton active />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|