feat: finalize UI form new right panel thread

This commit is contained in:
Faisal Amir 2024-01-02 01:24:16 +07:00
parent 590fa67244
commit 347e47f1ce
11 changed files with 418 additions and 229 deletions

View File

@ -41,7 +41,7 @@ export default function CardSidebar({
return ( return (
<div <div
className={twMerge( className={twMerge(
'flex w-full flex-col border-t border-border bg-zinc-100 dark:bg-zinc-600/10', 'flex w-full flex-col border-t border-border bg-zinc-100 dark:bg-zinc-900',
asChild ? 'rounded-lg border' : 'border-t' asChild ? 'rounded-lg border' : 'border-t'
)} )}
> >
@ -56,7 +56,7 @@ export default function CardSidebar({
{!asChild && ( {!asChild && (
<div <div
ref={setToggle} ref={setToggle}
className="cursor-pointer rounded-lg bg-zinc-100 p-2 pr-0 dark:bg-zinc-600/10" className="cursor-pointer rounded-lg bg-zinc-100 p-2 pr-0 dark:bg-zinc-900"
onClick={() => setMore(!more)} onClick={() => setMore(!more)}
> >
<MoreVerticalIcon className="h-5 w-5" /> <MoreVerticalIcon className="h-5 w-5" />
@ -64,7 +64,7 @@ export default function CardSidebar({
)} )}
<button <button
onClick={() => setShow(!show)} onClick={() => setShow(!show)}
className="flex w-full flex-1 items-center space-x-2 rounded-lg bg-zinc-100 px-3 py-2 dark:bg-zinc-600/10" className="flex w-full flex-1 items-center space-x-2 rounded-lg bg-zinc-100 px-3 py-2 dark:bg-zinc-900"
> >
<ChevronDownIcon <ChevronDownIcon
className={twMerge( className={twMerge(

View File

@ -9,38 +9,49 @@ import {
TooltipTrigger, TooltipTrigger,
} from '@janhq/uikit' } from '@janhq/uikit'
import { useAtomValue } from 'jotai' // import { useAtomValue } from 'jotai'
import { InfoIcon } from 'lucide-react' import { InfoIcon } from 'lucide-react'
import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' // import useUpdateModelParameters from '@/hooks/useUpdateModelParameters'
import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' // import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom'
type Props = { type Props = {
name: string name: string
title: string title: string
description: string description: string
checked: boolean value: boolean
onBlur: () => void
onChange: () => void
} }
const Checkbox: React.FC<Props> = ({ name, title, checked, description }) => { const Checkbox: React.FC<Props> = ({
const { updateModelParameter } = useUpdateModelParameters() name,
const threadId = useAtomValue(getActiveThreadIdAtom) value,
title,
description,
onChange,
onBlur,
}) => {
// const { updateModelParameter } = useUpdateModelParameters()
// const threadId = useAtomValue(getActiveThreadIdAtom)
const onCheckedChange = (checked: boolean) => { // const onCheckedChange = (checked: boolean) => {
if (!threadId) return // if (!threadId) return
updateModelParameter(threadId, name, checked) // updateModelParameter(threadId, name, checked)
} // }
return ( return (
<div className="flex justify-between"> <div className="flex justify-between">
<div className="mb-1 flex items-center gap-x-2"> <div className="mb-1 flex items-center gap-x-2">
<p className="text-sm font-semibold text-gray-600">{title}</p> <p className="text-sm font-semibold text-zinc-500 dark:text-gray-300">
{title}
</p>
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<InfoIcon size={16} className="flex-shrink-0" /> <InfoIcon size={16} className="flex-shrink-0 dark:text-gray-500" />
</TooltipTrigger> </TooltipTrigger>
<TooltipPortal> <TooltipPortal>
<TooltipContent side="top" className="max-w-[240px]"> <TooltipContent side="top" className="max-w-[240px]">
@ -51,7 +62,13 @@ const Checkbox: React.FC<Props> = ({ name, title, checked, description }) => {
</Tooltip> </Tooltip>
</div> </div>
<Switch checked={checked} onCheckedChange={onCheckedChange} /> <Switch
name={name}
defaultChecked={value}
onCheckedChange={onChange}
onChange={onChange}
onBlur={onBlur}
/>
</div> </div>
) )
} }

View File

@ -7,13 +7,13 @@ import {
TooltipTrigger, TooltipTrigger,
} from '@janhq/uikit' } from '@janhq/uikit'
import { useAtomValue } from 'jotai' // import { useAtomValue } from 'jotai'
import { InfoIcon } from 'lucide-react' import { InfoIcon } from 'lucide-react'
import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' // import useUpdateModelParameters from '@/hooks/useUpdateModelParameters'
import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' // import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom'
type Props = { type Props = {
title: string title: string
@ -21,6 +21,8 @@ type Props = {
description: string description: string
placeholder: string placeholder: string
value: string value: string
onBlur: () => void
onChange: () => void
} }
const ModelConfigInput: React.FC<Props> = ({ const ModelConfigInput: React.FC<Props> = ({
@ -29,23 +31,27 @@ const ModelConfigInput: React.FC<Props> = ({
value, value,
description, description,
placeholder, placeholder,
onChange,
onBlur,
}) => { }) => {
const { updateModelParameter } = useUpdateModelParameters() // const { updateModelParameter } = useUpdateModelParameters()
const threadId = useAtomValue(getActiveThreadIdAtom) // const threadId = useAtomValue(getActiveThreadIdAtom)
const onValueChanged = (e: React.ChangeEvent<HTMLTextAreaElement>) => { // const onValueChanged = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
if (!threadId) return // if (!threadId) return
updateModelParameter(threadId, name, e.target.value) // updateModelParameter(threadId, name, e.target.value)
} // }
return ( return (
<div className="flex flex-col"> <div className="flex flex-col">
<div className="mb-4 flex items-center gap-x-2"> <div className="mb-4 flex items-center gap-x-2">
<p className="text-sm font-semibold text-gray-600">{title}</p> <p className="text-sm font-semibold text-zinc-500 dark:text-gray-300">
{title}
</p>
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<InfoIcon size={16} className="flex-shrink-0" /> <InfoIcon size={16} className="flex-shrink-0 dark:text-gray-500" />
</TooltipTrigger> </TooltipTrigger>
<TooltipPortal> <TooltipPortal>
<TooltipContent side="top" className="max-w-[240px]"> <TooltipContent side="top" className="max-w-[240px]">
@ -56,9 +62,10 @@ const ModelConfigInput: React.FC<Props> = ({
</Tooltip> </Tooltip>
</div> </div>
<Textarea <Textarea
name={name}
placeholder={placeholder} placeholder={placeholder}
onChange={onValueChanged} onChange={onChange}
value={value} onBlur={onBlur}
/> />
</div> </div>
) )

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import React from 'react' import React from 'react'
import { Slider, Input, TooltipPortal } from '@janhq/uikit' import { Slider, Input, TooltipPortal } from '@janhq/uikit'
@ -7,12 +8,12 @@ import {
TooltipTrigger, TooltipTrigger,
TooltipArrow, TooltipArrow,
} from '@janhq/uikit' } from '@janhq/uikit'
import { useAtomValue } from 'jotai' // import { useAtomValue } from 'jotai'
import { InfoIcon } from 'lucide-react' import { InfoIcon } from 'lucide-react'
import useUpdateModelParameters from '@/hooks/useUpdateModelParameters' // import useUpdateModelParameters from '@/hooks/useUpdateModelParameters'
import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom' // import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom'
type Props = { type Props = {
name: string name: string
@ -21,7 +22,9 @@ type Props = {
min: number min: number
max: number max: number
step: number step: number
value: number value: number[]
onChange: (e: any) => void
onBlur: (e: any) => void
} }
const SliderRightPanel: React.FC<Props> = ({ const SliderRightPanel: React.FC<Props> = ({
@ -30,24 +33,28 @@ const SliderRightPanel: React.FC<Props> = ({
min, min,
max, max,
description, description,
onChange,
onBlur,
step, step,
value, value,
}) => { }) => {
const { updateModelParameter } = useUpdateModelParameters() // const { updateModelParameter } = useUpdateModelParameters()
const threadId = useAtomValue(getActiveThreadIdAtom) // const threadId = useAtomValue(getActiveThreadIdAtom)
const onValueChanged = (e: number[]) => { // const onValueChanged = (e: number[]) => {
if (!threadId) return // if (!threadId) return
updateModelParameter(threadId, name, e[0]) // updateModelParameter(threadId, name, e[0])
} // }
return ( return (
<div className="flex flex-col"> <div className="flex flex-col">
<div className="mb-4 flex items-center gap-x-2"> <div className="mb-4 flex items-center gap-x-2">
<p className="text-sm font-semibold text-gray-600">{title}</p> <p className="text-sm font-semibold text-zinc-500 dark:text-gray-300">
{title}
</p>
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<InfoIcon size={16} className="flex-shrink-0" /> <InfoIcon size={16} className="flex-shrink-0 dark:text-gray-500" />
</TooltipTrigger> </TooltipTrigger>
<TooltipPortal> <TooltipPortal>
<TooltipContent side="top" className="max-w-[240px]"> <TooltipContent side="top" className="max-w-[240px]">
@ -60,8 +67,11 @@ const SliderRightPanel: React.FC<Props> = ({
<div className="flex items-center gap-x-4"> <div className="flex items-center gap-x-4">
<div className="relative w-full"> <div className="relative w-full">
<Slider <Slider
value={[value]} defaultValue={value}
onValueChange={onValueChanged} onValueChange={(e) => onChange(e[0])}
onChange={(e) => onChange(e)}
onBlur={onBlur}
name={name}
min={min} min={min}
max={max} max={max}
step={step} step={step}
@ -78,8 +88,10 @@ const SliderRightPanel: React.FC<Props> = ({
className="-mt-4 h-8 w-16" className="-mt-4 h-8 w-16"
min={min} min={min}
max={max} max={max}
value={String(value)} name={name}
onChange={(e) => onValueChanged([Number(e.target.value)])} value={value[0] || String(value[0])}
onChange={(e) => onChange([e.target.value])}
onBlur={onBlur}
/> />
</div> </div>
</div> </div>

View File

@ -25,11 +25,7 @@ export default function useUpdateModelParameters() {
const activeThreadState = useAtomValue(activeThreadStateAtom) const activeThreadState = useAtomValue(activeThreadStateAtom)
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom) const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom)
const updateModelParameter = async ( const updateModelParameter = async (threadId: string, values: any) => {
threadId: string,
name: string,
value: number | boolean | string
) => {
const thread = threads.find((thread) => thread.id === threadId) const thread = threads.find((thread) => thread.id === threadId)
if (!thread) { if (!thread) {
console.error(`Thread ${threadId} not found`) console.error(`Thread ${threadId} not found`)
@ -40,9 +36,10 @@ export default function useUpdateModelParameters() {
console.error('No active thread') console.error('No active thread')
return return
} }
const updatedModelParams: ModelParams = { const updatedModelParams: ModelParams = {
...activeModelParams, ...activeModelParams,
[name]: value, ...values,
} }
// update the state // update the state

View File

@ -118,7 +118,6 @@ const ChatBody: React.FC = () => {
{messages.map((message, index) => ( {messages.map((message, index) => (
<div key={message.id}> <div key={message.id}>
<ChatItem {...message} key={message.id} /> <ChatItem {...message} key={message.id} />
{message.status === MessageStatus.Error && {message.status === MessageStatus.Error &&
index === messages.length - 1 && ( index === messages.length - 1 && (
<div <div

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useAtomValue } from 'jotai' import { useAtomValue } from 'jotai'
import { selectedModelAtom } from '@/containers/DropdownListSidebar' import { selectedModelAtom } from '@/containers/DropdownListSidebar'
@ -9,7 +10,7 @@ import settingComponentBuilder from '../ModelSetting/settingComponentBuilder'
import { getActiveThreadModelParamsAtom } from '@/helpers/atoms/Thread.atom' import { getActiveThreadModelParamsAtom } from '@/helpers/atoms/Thread.atom'
const EngineSetting: React.FC = () => { const EngineSetting = (props: { form: any }) => {
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom) const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom)
const selectedModel = useAtomValue(selectedModelAtom) const selectedModel = useAtomValue(selectedModelAtom)
@ -22,9 +23,9 @@ const EngineSetting: React.FC = () => {
componentData.sort((a, b) => a.title.localeCompare(b.title)) componentData.sort((a, b) => a.title.localeCompare(b.title))
return ( return (
<form className="flex flex-col"> <div className="flex flex-col">
{settingComponentBuilder(componentData)} {settingComponentBuilder(componentData, props.form)}
</form> </div>
) )
} }

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import React from 'react' import React from 'react'
import { useAtomValue } from 'jotai' import { useAtomValue } from 'jotai'
@ -11,7 +12,7 @@ import settingComponentBuilder from './settingComponentBuilder'
import { getActiveThreadModelParamsAtom } from '@/helpers/atoms/Thread.atom' import { getActiveThreadModelParamsAtom } from '@/helpers/atoms/Thread.atom'
const ModelSetting: React.FC = () => { const ModelSetting = (props: { form: any }) => {
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom) const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom)
const selectedModel = useAtomValue(selectedModelAtom) const selectedModel = useAtomValue(selectedModelAtom)
@ -24,9 +25,9 @@ const ModelSetting: React.FC = () => {
componentData.sort((a, b) => a.title.localeCompare(b.title)) componentData.sort((a, b) => a.title.localeCompare(b.title))
return ( return (
<form className="flex flex-col"> <div className="flex flex-col">
{settingComponentBuilder(componentData)} {settingComponentBuilder(componentData, props.form)}
</form> </div>
) )
} }

View File

@ -1,4 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable no-case-declarations */ /* eslint-disable no-case-declarations */
import { FormControl, FormField, FormItem, FormMessage } from '@janhq/uikit'
import Checkbox from '@/containers/Checkbox' import Checkbox from '@/containers/Checkbox'
import ModelConfigInput from '@/containers/ModelConfigInput' import ModelConfigInput from '@/containers/ModelConfigInput'
import Slider from '@/containers/Slider' import Slider from '@/containers/Slider'
@ -29,12 +32,28 @@ type CheckboxData = {
checked: boolean checked: boolean
} }
const settingComponentBuilder = (componentData: SettingComponentData[]) => { const settingComponentBuilder = (
const components = componentData.map((data) => { componentData: SettingComponentData[],
form?: any,
onlyPrompt?: boolean
) => {
const components = componentData
.filter((x) =>
onlyPrompt ? x.name === 'prompt_template' : x.name !== 'prompt_template'
)
.map((data) => {
switch (data.controllerType) { switch (data.controllerType) {
case 'slider': case 'slider':
const { min, max, step, value } = data.controllerData as SliderData const { min, max, step, value } = data.controllerData as SliderData
return ( return (
<FormField
key={data.title}
control={form.control}
name={data.name}
render={({ field }) => (
<>
<FormItem>
<FormControl>
<Slider <Slider
key={data.name} key={data.name}
title={data.title} title={data.title}
@ -42,32 +61,64 @@ const settingComponentBuilder = (componentData: SettingComponentData[]) => {
min={min} min={min}
max={max} max={max}
step={step} step={step}
value={value} {...field}
name={data.name} value={[field.value || value]}
/>
</FormControl>
<FormMessage />
</FormItem>
</>
)}
/> />
) )
case 'input': case 'input':
const { placeholder, value: textValue } = const { placeholder, value: textValue } =
data.controllerData as InputData data.controllerData as InputData
return ( return (
<FormField
key={data.title}
control={form.control}
name={data.name}
render={({ field }) => (
<FormItem>
<FormControl>
<ModelConfigInput <ModelConfigInput
title={data.title} title={data.title}
key={data.name} key={data.name}
name={data.name}
description={data.description} description={data.description}
placeholder={placeholder} placeholder={placeholder}
value={textValue} {...field}
value={field.value || textValue}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/> />
) )
case 'checkbox': case 'checkbox':
const { checked } = data.controllerData as CheckboxData const { checked } = data.controllerData as CheckboxData
return ( return (
<FormField
key={data.title}
control={form.control}
name={data.name}
render={({ field }) => (
<>
<FormItem>
<FormControl>
<Checkbox <Checkbox
key={data.name} key={data.name}
name={data.name}
description={data.description} description={data.description}
title={data.title} title={data.title}
checked={checked} {...field}
value={field.value || checked}
/>
</FormControl>
<FormMessage />
</FormItem>
</>
)}
/> />
) )
default: default:

View File

@ -1,8 +1,18 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import React, { useContext } from 'react' import React, { useContext } from 'react'
import { FieldValues, useForm } from 'react-hook-form'
import { getUserSpace, openFileExplorer, joinPath } from '@janhq/core' import { getUserSpace, openFileExplorer, joinPath } from '@janhq/core'
import { Input, Textarea } from '@janhq/uikit' import {
Input,
Textarea,
Form,
Button,
FormField,
FormItem,
FormControl,
} from '@janhq/uikit'
import { atom, useAtomValue } from 'jotai' import { atom, useAtomValue } from 'jotai'
@ -15,17 +25,21 @@ import DropdownListSidebar, {
selectedModelAtom, selectedModelAtom,
} from '@/containers/DropdownListSidebar' } from '@/containers/DropdownListSidebar'
import { FeatureToggleContext } from '@/context/FeatureToggle'
import { useCreateNewThread } from '@/hooks/useCreateNewThread' import { useCreateNewThread } from '@/hooks/useCreateNewThread'
import useUpdateModelParameters from '@/hooks/useUpdateModelParameters'
import { getConfigurationsData } from '@/utils/componentSettings'
import { toSettingParams } from '@/utils/model_param' import { toSettingParams } from '@/utils/model_param'
import EngineSetting from '../EngineSetting' import EngineSetting from '../EngineSetting'
import ModelSetting from '../ModelSetting' import ModelSetting from '../ModelSetting'
import settingComponentBuilder from '../ModelSetting/settingComponentBuilder'
import { import {
activeThreadAtom, activeThreadAtom,
getActiveThreadIdAtom,
getActiveThreadModelParamsAtom, getActiveThreadModelParamsAtom,
threadStatesAtom, threadStatesAtom,
} from '@/helpers/atoms/Thread.atom' } from '@/helpers/atoms/Thread.atom'
@ -35,13 +49,15 @@ export const showRightSideBarAtom = atom<boolean>(true)
const Sidebar: React.FC = () => { const Sidebar: React.FC = () => {
const showing = useAtomValue(showRightSideBarAtom) const showing = useAtomValue(showRightSideBarAtom)
const activeThread = useAtomValue(activeThreadAtom) const activeThread = useAtomValue(activeThreadAtom)
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom)
const selectedModel = useAtomValue(selectedModelAtom) const selectedModel = useAtomValue(selectedModelAtom)
const { updateThreadMetadata } = useCreateNewThread() const { updateThreadMetadata } = useCreateNewThread()
const { updateModelParameter } = useUpdateModelParameters()
const threadStates = useAtomValue(threadStatesAtom) const threadStates = useAtomValue(threadStatesAtom)
const { experimentalFeatureEnabed } = useContext(FeatureToggleContext) const threadId = useAtomValue(getActiveThreadIdAtom)
const modelEngineParams = toSettingParams(activeModelParams)
const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom) const componentDataEngineSetting = getConfigurationsData(modelEngineParams)
const modelSettingParams = toSettingParams(activeModelParams)
const onReviewInFinderClick = async (type: string) => { const onReviewInFinderClick = async (type: string) => {
if (!activeThread) return if (!activeThread) return
@ -109,6 +125,62 @@ const Sidebar: React.FC = () => {
openFileExplorer(fullPath) openFileExplorer(fullPath)
} }
const form = useForm()
const filterChangedFormFields = <T extends FieldValues>(
allFields: T,
dirtyFields: Partial<Record<keyof T, boolean | boolean[]>>
): Partial<T> => {
const changedFieldValues = Object.keys(dirtyFields).reduce(
(acc, currentField) => {
const isDirty = Array.isArray(dirtyFields[currentField])
? (dirtyFields[currentField] as boolean[]).some((value) => {
value === true
})
: dirtyFields[currentField] === true
if (isDirty) {
return {
...acc,
[currentField]: allFields[currentField],
}
}
return acc
},
{} as Partial<T>
)
return changedFieldValues
}
const onSubmit = async (values: any) => {
if (!threadId) return
if (!activeThread) return
if (Object.keys(form.formState.dirtyFields).length) {
if (
Object.keys(form.formState.dirtyFields).includes('title') ||
Object.keys(form.formState.dirtyFields).includes('instructions')
) {
updateThreadMetadata({
...activeThread,
title: values.title || activeThread.title,
assistants: [
{
...activeThread.assistants[0],
instructions:
values.instructions || activeThread?.assistants[0].instructions,
},
],
})
}
updateModelParameter(
threadId,
filterChangedFormFields(values, form.formState.dirtyFields)
)
form.reset()
}
}
return ( return (
<div <div
className={twMerge( className={twMerge(
@ -118,6 +190,8 @@ const Sidebar: React.FC = () => {
: 'w-0 translate-x-full opacity-0' : 'w-0 translate-x-full opacity-0'
)} )}
> >
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<div <div
className={twMerge( className={twMerge(
'flex flex-col gap-1 delay-200', 'flex flex-col gap-1 delay-200',
@ -132,16 +206,26 @@ const Sidebar: React.FC = () => {
> >
Title Title
</label> </label>
<FormField
key={activeThread?.title}
control={form.control}
name="title"
render={({ field }) => (
<>
<FormItem>
<FormControl>
<Input <Input
id="thread-title" id="thread-title"
value={activeThread?.title} {...field}
onChange={(e) => { defaultValue={activeThread?.title}
if (activeThread) name="title"
updateThreadMetadata({ onChange={(e) => field.onChange(e)}
...activeThread, value={field.value}
title: e.target.value || '', />
}) </FormControl>
}} </FormItem>
</>
)}
/> />
</div> </div>
<div className="flex flex-col"> <div className="flex flex-col">
@ -176,24 +260,31 @@ const Sidebar: React.FC = () => {
> >
Instructions Instructions
</label> </label>
<FormField
key={activeThread?.title}
control={form.control}
name="instructions"
render={({ field }) => (
<>
<FormItem>
<FormControl>
<Textarea <Textarea
id="assistant-instructions" id="assistant-instructions"
placeholder="Eg. You are a helpful assistant." placeholder="Eg. You are a helpful assistant."
value={activeThread?.assistants[0].instructions ?? ''} {...field}
onChange={(e) => { name="instructions"
if (activeThread) defaultValue={
updateThreadMetadata({ activeThread?.assistants[0].instructions
...activeThread, }
assistants: [ value={field.value}
{ />
...activeThread.assistants[0], </FormControl>
instructions: e.target.value || '', </FormItem>
}, </>
], )}
})
}}
/> />
</div> </div>
{/* Temporary disabled */}
{/* <div> {/* <div>
<label <label
id="tool-title" id="tool-title"
@ -210,7 +301,6 @@ const Sidebar: React.FC = () => {
</div> */} </div> */}
</div> </div>
</CardSidebar> </CardSidebar>
<CardSidebar <CardSidebar
title="Model" title="Model"
onRevealInFinderClick={onReviewInFinderClick} onRevealInFinderClick={onReviewInFinderClick}
@ -222,19 +312,23 @@ const Sidebar: React.FC = () => {
<div className="mt-6"> <div className="mt-6">
<CardSidebar title="Inference Parameters" asChild> <CardSidebar title="Inference Parameters" asChild>
<div className="p-2"> <div className="p-2">
<ModelSetting /> <ModelSetting form={form} />
</div> </div>
</CardSidebar> </CardSidebar>
</div> </div>
<div className="mt-4"> <div className="mt-4">
<CardSidebar title="Model Parameters" asChild> <CardSidebar title="Model Parameters" asChild>
<div className="p-2">{/* <ModelSetting /> */}</div> <div className="p-2">
{settingComponentBuilder(
componentDataEngineSetting,
form,
true
)}
</div>
</CardSidebar> </CardSidebar>
</div> </div>
{experimentalFeatureEnabed &&
Object.keys(modelSettingParams).length ? (
<div className="mt-4"> <div className="mt-4">
<CardSidebar <CardSidebar
title="Engine Parameters" title="Engine Parameters"
@ -243,14 +337,23 @@ const Sidebar: React.FC = () => {
asChild asChild
> >
<div className="p-2"> <div className="p-2">
<EngineSetting /> <EngineSetting form={form} />
</div> </div>
</CardSidebar> </CardSidebar>
</div> </div>
) : null}
{Object.keys(form.formState.dirtyFields).length !== 0 && (
<div className="pt-4">
<Button type="submit" block>
Submit
</Button>
</div>
)}
</div> </div>
</CardSidebar> </CardSidebar>
</div> </div>
</form>
</Form>
</div> </div>
) )
} }

View File

@ -39,6 +39,7 @@ export const toSettingParams = (
embedding: undefined, embedding: undefined,
n_parallel: undefined, n_parallel: undefined,
cpu_threads: undefined, cpu_threads: undefined,
prompt_template: undefined,
} }
const settingParams: ModelSettingParams = {} const settingParams: ModelSettingParams = {}