* fix: update new api from cortex to support 0.5.0 Signed-off-by: James <namnh0122@gmail.com> * fix stop button for streaming Signed-off-by: James <namnh0122@gmail.com> * fix stop inference for nonstreaming Signed-off-by: James <namnh0122@gmail.com> * chore: remove umami prevent tracking call to vercel Signed-off-by: James <namnh0122@gmail.com> * add warning modal when running more than 2 model concurrently Signed-off-by: James <namnh0122@gmail.com> * fix: skip summarize if abort Signed-off-by: James <namnh0122@gmail.com> * 0.5.0-3 * add inference error popup Signed-off-by: James <namnh0122@gmail.com> * add back import local model Signed-off-by: James <namnh0122@gmail.com> * fix: max token issue (#3225) Signed-off-by: James <namnh0122@gmail.com> * format status Signed-off-by: James <namnh0122@gmail.com> * fix migration missing instructions Signed-off-by: James <namnh0122@gmail.com> * fix: wait for cortex process overlay should be on top (#3224) * fix: wait for cortex process overlay should be on top * chore: update cortex.js * Cortex 0.5.0-5 * add import model to my model screen Signed-off-by: James <namnh0122@gmail.com> * fix: should migrate symlink models (#3226) * fix import on windows (#3229) Signed-off-by: James <namnh0122@gmail.com> * fix yarn lint Signed-off-by: James <namnh0122@gmail.com> * fix: clean up port before start jan (#3232) Signed-off-by: James <namnh0122@gmail.com> --------- Signed-off-by: James <namnh0122@gmail.com> Co-authored-by: Van Pham <64197333+Van-QA@users.noreply.github.com> Co-authored-by: Louis <louis@jan.ai>
74 lines
2.4 KiB
TypeScript
74 lines
2.4 KiB
TypeScript
import { useCallback } from 'react'
|
|
|
|
import { SettingComponentProps } from '@janhq/core'
|
|
import { useAtomValue } from 'jotai'
|
|
|
|
import useModelStop from '@/hooks/useModelStop'
|
|
|
|
import SettingComponentBuilder from '../../../../containers/ModelSetting/SettingComponent'
|
|
|
|
import { activeModelsAtom } from '@/helpers/atoms/Model.atom'
|
|
import { activeThreadAtom } from '@/helpers/atoms/Thread.atom'
|
|
|
|
type Props = {
|
|
componentData: SettingComponentProps[]
|
|
}
|
|
|
|
const AssistantSetting: React.FC<Props> = ({ componentData }) => {
|
|
const activeThread = useAtomValue(activeThreadAtom)
|
|
const activeModels = useAtomValue(activeModelsAtom)
|
|
const stopModel = useModelStop()
|
|
|
|
const onValueChanged = useCallback(
|
|
(key: string, value: string | number | boolean) => {
|
|
if (!activeThread) return
|
|
console.log('onValueChanged', key, value)
|
|
const shouldReloadModel =
|
|
componentData.find((x) => x.key === key)?.requireModelReload ?? false
|
|
if (shouldReloadModel) {
|
|
const model = activeModels.find(
|
|
(model) => activeThread.assistants[0]?.model === model.model
|
|
)
|
|
if (model) stopModel.mutate(model.model)
|
|
}
|
|
|
|
// if (
|
|
// activeThread.assistants[0].tools &&
|
|
// (key === 'chunk_overlap' || key === 'chunk_size')
|
|
// ) {
|
|
// if (
|
|
// activeThread.assistants[0].tools[0]?.settings.chunk_size <
|
|
// activeThread.assistants[0].tools[0]?.settings.chunk_overlap
|
|
// ) {
|
|
// activeThread.assistants[0].tools[0].settings.chunk_overlap =
|
|
// activeThread.assistants[0].tools[0].settings.chunk_size
|
|
// }
|
|
// if (
|
|
// key === 'chunk_size' &&
|
|
// value < activeThread.assistants[0].tools[0].settings.chunk_overlap
|
|
// ) {
|
|
// activeThread.assistants[0].tools[0].settings.chunk_overlap = value
|
|
// } else if (
|
|
// key === 'chunk_overlap' &&
|
|
// value > activeThread.assistants[0].tools[0].settings.chunk_size
|
|
// ) {
|
|
// activeThread.assistants[0].tools[0].settings.chunk_size = value
|
|
// }
|
|
// }
|
|
},
|
|
[activeModels, activeThread, componentData, stopModel]
|
|
)
|
|
|
|
if (!activeThread) return null
|
|
if (componentData.length === 0) return null
|
|
|
|
return (
|
|
<SettingComponentBuilder
|
|
componentProps={componentData}
|
|
onValueUpdated={onValueChanged}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export default AssistantSetting
|