mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
feat: question classify panel
This commit is contained in:
@ -0,0 +1,32 @@
|
||||
import { useCallback, useState } from 'react'
|
||||
import produce from 'immer'
|
||||
import type { QuestionClassifierNodeType } from './types'
|
||||
|
||||
const useConfig = (initInputs: QuestionClassifierNodeType) => {
|
||||
const [inputs, setInputs] = useState<QuestionClassifierNodeType>(initInputs)
|
||||
|
||||
// model
|
||||
const handleModelChanged = useCallback((model: { provider: string; modelId: string; mode?: string }) => {
|
||||
const newInputs = produce(inputs, (draft) => {
|
||||
draft.model.provider = model.provider
|
||||
draft.model.name = model.modelId
|
||||
draft.model.mode = model.mode!
|
||||
})
|
||||
setInputs(newInputs)
|
||||
}, [inputs, setInputs])
|
||||
|
||||
const handleCompletionParamsChange = useCallback((newParams: Record<string, any>) => {
|
||||
const newInputs = produce(inputs, (draft) => {
|
||||
draft.model.completion_params = newParams
|
||||
})
|
||||
setInputs(newInputs)
|
||||
}, [inputs, setInputs])
|
||||
|
||||
return {
|
||||
inputs,
|
||||
handleModelChanged,
|
||||
handleCompletionParamsChange,
|
||||
}
|
||||
}
|
||||
|
||||
export default useConfig
|
||||
Reference in New Issue
Block a user