fix: agent node toolbox
This commit is contained in:
parent
08a1f241ca
commit
2ac6f00efb
@ -83,7 +83,6 @@ export const AgentStrategySelector = (props: AgentStrategySelectorProps) => {
|
|||||||
}, [query, list])
|
}, [query, list])
|
||||||
// TODO: should be replaced by real data
|
// TODO: should be replaced by real data
|
||||||
const isExternalInstalled = true
|
const isExternalInstalled = true
|
||||||
// TODO: 验证这玩意写对了没
|
|
||||||
const icon = list?.find(
|
const icon = list?.find(
|
||||||
coll => coll.tools?.find(tool => tool.name === value?.agent_strategy_name),
|
coll => coll.tools?.find(tool => tool.name === value?.agent_strategy_name),
|
||||||
)?.icon as string | undefined
|
)?.icon as string | undefined
|
||||||
@ -125,9 +124,10 @@ export const AgentStrategySelector = (props: AgentStrategySelectorProps) => {
|
|||||||
onChange({
|
onChange({
|
||||||
agent_strategy_name: tool!.tool_name,
|
agent_strategy_name: tool!.tool_name,
|
||||||
agent_strategy_provider_name: tool!.provider_name,
|
agent_strategy_provider_name: tool!.provider_name,
|
||||||
agent_parameters: tool!.params,
|
|
||||||
agent_strategy_label: tool!.tool_label,
|
agent_strategy_label: tool!.tool_label,
|
||||||
agent_output_schema: tool!.output_schema,
|
agent_output_schema: tool!.output_schema,
|
||||||
|
agent_configurations: {},
|
||||||
|
agent_parameters: {},
|
||||||
})
|
})
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
}}
|
}}
|
||||||
|
@ -19,7 +19,8 @@ export type Strategy = {
|
|||||||
agent_strategy_provider_name: string
|
agent_strategy_provider_name: string
|
||||||
agent_strategy_name: string
|
agent_strategy_name: string
|
||||||
agent_strategy_label: string
|
agent_strategy_label: string
|
||||||
agent_parameters?: ToolVarInputs
|
agent_configurations?: Record<string, any>
|
||||||
|
agent_parameters?: Record<string, ToolVarInputs>
|
||||||
agent_output_schema: Record<string, any>
|
agent_output_schema: Record<string, any>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import { FormTypeEnum } from '@/app/components/header/account-setting/model-prov
|
|||||||
const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
||||||
const { inputs, currentStrategy } = useConfig(props.id, props.data)
|
const { inputs, currentStrategy } = useConfig(props.id, props.data)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
// TODO: Implement models
|
|
||||||
const models = useMemo(() => {
|
const models = useMemo(() => {
|
||||||
if (!inputs) return []
|
if (!inputs) return []
|
||||||
// if selected, show in node
|
// if selected, show in node
|
||||||
@ -22,7 +21,7 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
|||||||
const models = currentStrategy?.parameters
|
const models = currentStrategy?.parameters
|
||||||
.filter(param => param.type === FormTypeEnum.modelSelector)
|
.filter(param => param.type === FormTypeEnum.modelSelector)
|
||||||
.reduce((acc, param) => {
|
.reduce((acc, param) => {
|
||||||
const item = inputs.agent_parameters?.[param.name]
|
const item = inputs.agent_configurations?.[param.name]
|
||||||
if (!item) {
|
if (!item) {
|
||||||
if (param.required) {
|
if (param.required) {
|
||||||
acc.push({ param: param.name })
|
acc.push({ param: param.name })
|
||||||
@ -41,18 +40,18 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
|||||||
currentStrategy?.parameters.forEach((param) => {
|
currentStrategy?.parameters.forEach((param) => {
|
||||||
if (param.type === FormTypeEnum.toolSelector) {
|
if (param.type === FormTypeEnum.toolSelector) {
|
||||||
const field = param.name
|
const field = param.name
|
||||||
const value = inputs.agent_parameters?.[field]
|
const value = inputs.agent_configurations?.[field]
|
||||||
if (value) {
|
if (value) {
|
||||||
tools.push({
|
tools.push({
|
||||||
providerName: value.provider_name,
|
providerName: value.provider_name as any,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (param.type === FormTypeEnum.multiToolSelector) {
|
if (param.type === FormTypeEnum.multiToolSelector) {
|
||||||
const field = param.name
|
const field = param.name
|
||||||
const value = inputs.agent_parameters?.[field]
|
const value = inputs.agent_configurations?.[field]
|
||||||
if (value) {
|
if (value) {
|
||||||
(value as any[]).forEach((item) => {
|
(value as unknown as any[]).forEach((item) => {
|
||||||
tools.push({
|
tools.push({
|
||||||
providerName: item.provider_name,
|
providerName: item.provider_name,
|
||||||
})
|
})
|
||||||
@ -61,7 +60,7 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
return tools
|
return tools
|
||||||
}, [currentStrategy, inputs.agent_parameters])
|
}, [currentStrategy?.parameters, inputs.agent_configurations])
|
||||||
return <div className='mb-1 px-3 py-1 space-y-1'>
|
return <div className='mb-1 px-3 py-1 space-y-1'>
|
||||||
{inputs.agent_strategy_name
|
{inputs.agent_strategy_name
|
||||||
? <SettingItem
|
? <SettingItem
|
||||||
|
@ -28,25 +28,27 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
|
|||||||
strategy={inputs.agent_strategy_name ? {
|
strategy={inputs.agent_strategy_name ? {
|
||||||
agent_strategy_provider_name: inputs.agent_strategy_provider_name!,
|
agent_strategy_provider_name: inputs.agent_strategy_provider_name!,
|
||||||
agent_strategy_name: inputs.agent_strategy_name!,
|
agent_strategy_name: inputs.agent_strategy_name!,
|
||||||
agent_parameters: inputs.agent_parameters,
|
agent_configurations: inputs.agent_configurations,
|
||||||
agent_strategy_label: inputs.agent_strategy_label!,
|
agent_strategy_label: inputs.agent_strategy_label!,
|
||||||
agent_output_schema: inputs.output_schema,
|
agent_output_schema: inputs.output_schema,
|
||||||
|
agent_parameters: inputs.agent_parameters,
|
||||||
} : undefined}
|
} : undefined}
|
||||||
onStrategyChange={(strategy) => {
|
onStrategyChange={(strategy) => {
|
||||||
setInputs({
|
setInputs({
|
||||||
...inputs,
|
...inputs,
|
||||||
agent_strategy_provider_name: strategy?.agent_strategy_provider_name,
|
agent_strategy_provider_name: strategy?.agent_strategy_provider_name,
|
||||||
agent_strategy_name: strategy?.agent_strategy_name,
|
agent_strategy_name: strategy?.agent_strategy_name,
|
||||||
|
agent_configurations: strategy?.agent_configurations,
|
||||||
agent_parameters: strategy?.agent_parameters,
|
agent_parameters: strategy?.agent_parameters,
|
||||||
agent_strategy_label: strategy?.agent_strategy_label,
|
agent_strategy_label: strategy?.agent_strategy_label,
|
||||||
output_schema: strategy!.agent_output_schema,
|
output_schema: strategy!.agent_output_schema,
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
formSchema={currentStrategy?.parameters?.map(strategyParamToCredientialForm) || []}
|
formSchema={currentStrategy?.parameters?.map(strategyParamToCredientialForm) || []}
|
||||||
formValue={inputs.agent_parameters || {}}
|
formValue={inputs.agent_configurations || {}}
|
||||||
onFormValueChange={value => setInputs({
|
onFormValueChange={value => setInputs({
|
||||||
...inputs,
|
...inputs,
|
||||||
agent_parameters: value,
|
agent_configurations: value,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
@ -5,7 +5,7 @@ export type AgentNodeType = CommonNodeType & {
|
|||||||
agent_strategy_provider_name?: string
|
agent_strategy_provider_name?: string
|
||||||
agent_strategy_name?: string
|
agent_strategy_name?: string
|
||||||
agent_strategy_label?: string
|
agent_strategy_label?: string
|
||||||
agent_parameters?: Record<string, any>
|
agent_parameters?: Record<string, ToolVarInputs>
|
||||||
agent_configurations?: Record<string, ToolVarInputs>
|
agent_configurations?: Record<string, any>
|
||||||
output_schema: Record<string, any>
|
output_schema: Record<string, any>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user