|
|
|
@ -14,13 +14,12 @@ import MultipleToolSelector from '@/app/components/plugins/plugin-detail-panel/m
|
|
|
|
import Field from './field'
|
|
|
|
import Field from './field'
|
|
|
|
import type { ComponentProps } from 'react'
|
|
|
|
import type { ComponentProps } from 'react'
|
|
|
|
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
|
|
|
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
|
|
|
|
|
|
|
import Editor from './prompt/editor'
|
|
|
|
|
|
|
|
|
|
|
|
export type Strategy = {
|
|
|
|
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_configurations?: Record<string, any>
|
|
|
|
|
|
|
|
agent_parameters?: Record<string, ToolVarInputs>
|
|
|
|
|
|
|
|
agent_output_schema: Record<string, any>
|
|
|
|
agent_output_schema: Record<string, any>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -36,80 +35,16 @@ type CustomSchema<Type, Field = {}> = Omit<CredentialFormSchema, 'type'> & { typ
|
|
|
|
|
|
|
|
|
|
|
|
type ToolSelectorSchema = CustomSchema<'tool-selector'>
|
|
|
|
type ToolSelectorSchema = CustomSchema<'tool-selector'>
|
|
|
|
type MultipleToolSelectorSchema = CustomSchema<'array[tools]'>
|
|
|
|
type MultipleToolSelectorSchema = CustomSchema<'array[tools]'>
|
|
|
|
|
|
|
|
type StringSchema = CustomSchema<'string', {
|
|
|
|
type CustomField = ToolSelectorSchema | MultipleToolSelectorSchema
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const devMockForm = [{
|
|
|
|
|
|
|
|
name: 'instruction',
|
|
|
|
|
|
|
|
label: {
|
|
|
|
|
|
|
|
en_US: 'Instruction',
|
|
|
|
|
|
|
|
zh_Hans: '指令',
|
|
|
|
|
|
|
|
pt_BR: 'Instruction',
|
|
|
|
|
|
|
|
ja_JP: 'Instruction',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
placeholder: null,
|
|
|
|
|
|
|
|
scope: null,
|
|
|
|
|
|
|
|
auto_generate: {
|
|
|
|
|
|
|
|
type: 'prompt_instruction',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
template: {
|
|
|
|
template: {
|
|
|
|
enabled: true,
|
|
|
|
enabled: boolean
|
|
|
|
},
|
|
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
|
|
default: null,
|
|
|
|
|
|
|
|
min: null,
|
|
|
|
|
|
|
|
max: null,
|
|
|
|
|
|
|
|
options: [],
|
|
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: 'query',
|
|
|
|
|
|
|
|
label: {
|
|
|
|
|
|
|
|
en_US: 'Query',
|
|
|
|
|
|
|
|
zh_Hans: '查询',
|
|
|
|
|
|
|
|
pt_BR: 'Query',
|
|
|
|
|
|
|
|
ja_JP: 'Query',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
placeholder: null,
|
|
|
|
|
|
|
|
scope: null,
|
|
|
|
|
|
|
|
auto_generate: null,
|
|
|
|
|
|
|
|
template: null,
|
|
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
|
|
default: null,
|
|
|
|
|
|
|
|
min: null,
|
|
|
|
|
|
|
|
max: null,
|
|
|
|
|
|
|
|
options: [],
|
|
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: 'max iterations',
|
|
|
|
|
|
|
|
label: {
|
|
|
|
|
|
|
|
en_US: 'Max Iterations',
|
|
|
|
|
|
|
|
zh_Hans: '最大迭代次数',
|
|
|
|
|
|
|
|
pt_BR: 'Max Iterations',
|
|
|
|
|
|
|
|
ja_JP: 'Max Iterations',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
placeholder: null,
|
|
|
|
|
|
|
|
scope: null,
|
|
|
|
|
|
|
|
auto_generate: null,
|
|
|
|
|
|
|
|
template: null,
|
|
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
|
|
default: '1',
|
|
|
|
|
|
|
|
min: 1,
|
|
|
|
|
|
|
|
max: 10,
|
|
|
|
|
|
|
|
type: FormTypeEnum.textNumber,
|
|
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
|
|
en_US: 'The maximum number of iterations to run',
|
|
|
|
|
|
|
|
zh_Hans: '运行的最大迭代次数',
|
|
|
|
|
|
|
|
pt_BR: 'The maximum number of iterations to run',
|
|
|
|
|
|
|
|
ja_JP: 'The maximum number of iterations to run',
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}].map((item) => {
|
|
|
|
auto_generate: {
|
|
|
|
return {
|
|
|
|
type: string
|
|
|
|
...item,
|
|
|
|
|
|
|
|
variable: item.name,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type CustomField = ToolSelectorSchema | MultipleToolSelectorSchema | StringSchema
|
|
|
|
|
|
|
|
|
|
|
|
export const AgentStrategy = (props: AgentStrategyProps) => {
|
|
|
|
export const AgentStrategy = (props: AgentStrategyProps) => {
|
|
|
|
const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange } = props
|
|
|
|
const { strategy, onStrategyChange, formSchema, formValue, onFormValueChange } = props
|
|
|
|
@ -188,6 +123,18 @@ export const AgentStrategy = (props: AgentStrategyProps) => {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'string': {
|
|
|
|
|
|
|
|
const value = props.value[schema.variable]
|
|
|
|
|
|
|
|
const onChange = (value: any) => {
|
|
|
|
|
|
|
|
props.onChange({ ...props.value, [schema.variable]: value })
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return <Editor
|
|
|
|
|
|
|
|
value={value}
|
|
|
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
|
|
|
title={schema.label[language]}
|
|
|
|
|
|
|
|
headerClassName='bg-transparent'
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return <div className='space-y-2'>
|
|
|
|
return <div className='space-y-2'>
|
|
|
|
@ -196,10 +143,7 @@ export const AgentStrategy = (props: AgentStrategyProps) => {
|
|
|
|
strategy
|
|
|
|
strategy
|
|
|
|
? <div>
|
|
|
|
? <div>
|
|
|
|
<Form<CustomField>
|
|
|
|
<Form<CustomField>
|
|
|
|
formSchemas={[
|
|
|
|
formSchemas={formSchema}
|
|
|
|
...formSchema,
|
|
|
|
|
|
|
|
...devMockForm as any,
|
|
|
|
|
|
|
|
]}
|
|
|
|
|
|
|
|
value={formValue}
|
|
|
|
value={formValue}
|
|
|
|
onChange={onFormValueChange}
|
|
|
|
onChange={onFormValueChange}
|
|
|
|
validating={false}
|
|
|
|
validating={false}
|
|
|
|
|