35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { useStrategyProviderDetail } from '@/service/use-strategy'
|
|
import useNodeCrud from '../_base/hooks/use-node-crud'
|
|
import useVarList from '../_base/hooks/use-var-list'
|
|
import type { AgentNodeType } from './types'
|
|
import {
|
|
useNodesReadOnly,
|
|
} from '@/app/components/workflow/hooks'
|
|
|
|
const useConfig = (id: string, payload: AgentNodeType) => {
|
|
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
|
const { inputs, setInputs } = useNodeCrud<AgentNodeType>(id, payload)
|
|
// variables
|
|
const { handleVarListChange, handleAddVariable } = useVarList<AgentNodeType>({
|
|
inputs,
|
|
setInputs,
|
|
})
|
|
const strategies = useStrategyProviderDetail(
|
|
inputs.agent_strategy_provider_name || '',
|
|
)
|
|
const currentStrategy = strategies.data?.declaration.strategies.find(
|
|
str => str.identity.name === inputs.agent_strategy_name,
|
|
)
|
|
console.log('currentStrategy', currentStrategy, 'strategies', strategies, 'inputs', inputs)
|
|
return {
|
|
readOnly,
|
|
inputs,
|
|
setInputs,
|
|
handleVarListChange,
|
|
handleAddVariable,
|
|
currentStrategy,
|
|
}
|
|
}
|
|
|
|
export default useConfig
|