From 3ae7787011b7ef52c27448c2230009eb5f599c2b Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Wed, 8 Jan 2025 17:36:26 +0800 Subject: [PATCH 1/2] fix: number not supported --- web/app/components/tools/utils/to-form-schema.ts | 2 +- .../nodes/_base/components/agent-strategy.tsx | 16 ++++++++++++++-- .../nodes/_base/components/prompt/editor.tsx | 4 ++-- .../components/workflow/nodes/agent/panel.tsx | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/web/app/components/tools/utils/to-form-schema.ts b/web/app/components/tools/utils/to-form-schema.ts index 4e83248c9b..7086c903d1 100644 --- a/web/app/components/tools/utils/to-form-schema.ts +++ b/web/app/components/tools/utils/to-form-schema.ts @@ -1,5 +1,5 @@ import type { ToolCredential, ToolParameter } from '../types' -const toType = (type: string) => { +export const toType = (type: string) => { switch (type) { case 'string': return 'text-input' diff --git a/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx b/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx index 4ec46a6d61..7efd77b4c5 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx @@ -19,6 +19,7 @@ import { useWorkflowStore } from '../../../store' import { useRenderI18nObject } from '@/hooks/use-i18n' import type { NodeOutPutVar } from '../../../types' import type { Node } from 'reactflow' +import { toType } from '@/app/components/tools/utils/to-form-schema' export type Strategy = { agent_strategy_provider_name: string @@ -150,7 +151,7 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => { onGenerated={handleGenerated} title={renderI18nObject(schema.label)} headerClassName='bg-transparent px-0 text-text-secondary system-sm-semibold-uppercase' - containerClassName='bg-transparent' + containerBackgroundClassName='bg-transparent' gradientBorder={false} isSupportPromptGenerator={!!schema.auto_generate?.type} titleTooltip={schema.tooltip && renderI18nObject(schema.tooltip)} @@ -181,7 +182,18 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => { strategy ?
- formSchemas={formSchema} + formSchemas={[...formSchema, { + name: 'max_iteration', + type: toType('number'), + required: true, + label: { + en_US: 'Max Iteration', + zh_Hans: '最大迭代次数', + pt_BR: 'Max Iteration', + }, + show_on: [], + variable: 'max-ite', + }]} value={formValue} onChange={onFormValueChange} validating={false} diff --git a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx index e1d43e10e3..43db8a276e 100644 --- a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx +++ b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx @@ -68,7 +68,7 @@ type Props = { onEditionTypeChange?: (editionType: EditionType) => void varList?: Variable[] handleAddVariable?: (payload: any) => void - containerClassName?: string + containerBackgroundClassName?: string gradientBorder?: boolean titleTooltip?: ReactNode inputClassName?: string @@ -103,7 +103,7 @@ const Editor: FC = ({ handleAddVariable, onGenerated, modelConfig, - containerClassName, + containerBackgroundClassName: containerClassName, gradientBorder = true, titleTooltip, inputClassName, diff --git a/web/app/components/workflow/nodes/agent/panel.tsx b/web/app/components/workflow/nodes/agent/panel.tsx index ab8ff1c4b9..2b1f3827b3 100644 --- a/web/app/components/workflow/nodes/agent/panel.tsx +++ b/web/app/components/workflow/nodes/agent/panel.tsx @@ -14,6 +14,7 @@ import ResultPanel from '@/app/components/workflow/run/result-panel' import formatTracing from '@/app/components/workflow/run/utils/format-log' import { useLogs } from '@/app/components/workflow/run/hooks' import type { Props as FormProps } from '@/app/components/workflow/nodes/_base/components/before-run-form/form' +import { toType } from '@/app/components/tools/utils/to-form-schema' const i18nPrefix = 'workflow.nodes.agent' @@ -22,6 +23,7 @@ export function strategyParamToCredientialForm(param: StrategyParamItem): Creden ...param as any, variable: param.name, show_on: [], + type: toType(param.type), } } From 0248c8cb8c4b101ca008becb5b0dda666783218c Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Wed, 8 Jan 2025 17:47:47 +0800 Subject: [PATCH 2/2] fix: agent key --- web/app/components/plugins/constants.ts | 2 +- web/app/components/plugins/hooks.ts | 12 ++++++------ web/app/components/plugins/types.ts | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/app/components/plugins/constants.ts b/web/app/components/plugins/constants.ts index 40a3f0da83..02439be510 100644 --- a/web/app/components/plugins/constants.ts +++ b/web/app/components/plugins/constants.ts @@ -21,7 +21,7 @@ export const tagKeys = [ export const categoryKeys = [ 'model', 'tool', - 'agent', + 'agent-strategy', 'extension', 'bundle', ] diff --git a/web/app/components/plugins/hooks.ts b/web/app/components/plugins/hooks.ts index 371b769019..f4b81d98c1 100644 --- a/web/app/components/plugins/hooks.ts +++ b/web/app/components/plugins/hooks.ts @@ -42,10 +42,10 @@ export const useCategories = (translateFromOut?: TFunction) => { const t = translateFromOut || translation const categories = categoryKeys.map((category) => { - if (category === 'agent') { + if (category === 'agent-strategy') { return { - name: 'agent_strategy', - label: t(`plugin.category.${category}s`), + name: 'agent-strategy', + label: t('plugin.category.agents'), } } return { @@ -70,10 +70,10 @@ export const useSingleCategories = (translateFromOut?: TFunction) => { const t = translateFromOut || translation const categories = categoryKeys.map((category) => { - if (category === 'agent') { + if (category === 'agent-strategy') { return { - name: 'agent_strategy', - label: t(`plugin.categorySingle.${category}`), + name: 'agent-strategy', + label: t('plugin.categorySingle.agent'), } } return { diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index b58c25f9e3..15da9991a6 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -6,7 +6,7 @@ export enum PluginType { tool = 'tool', model = 'model', extension = 'extension', - agent = 'agent_strategy', + agent = 'agent-strategy', } export enum PluginSource {