diff --git a/web/app/components/workflow/hooks/use-checklist.ts b/web/app/components/workflow/hooks/use-checklist.ts index 9646b0da87..722ae5f032 100644 --- a/web/app/components/workflow/hooks/use-checklist.ts +++ b/web/app/components/workflow/hooks/use-checklist.ts @@ -25,6 +25,7 @@ import { useToastContext } from '@/app/components/base/toast' import { CollectionType } from '@/app/components/tools/types' import { useGetLanguage } from '@/context/i18n' import type { AgentNodeType } from '../nodes/agent/types' +import { useStrategyProviders } from '@/service/use-strategy' export const useChecklist = (nodes: Node[], edges: Edge[]) => { const { t } = useTranslation() @@ -34,7 +35,7 @@ export const useChecklist = (nodes: Node[], edges: Edge[]) => { const buildInTools = useStore(s => s.buildInTools) const customTools = useStore(s => s.customTools) const workflowTools = useStore(s => s.workflowTools) - const agentStrategies = useStore(s => s.agentStrategies) + const { data: agentStrategies } = useStrategyProviders() const needWarningNodes = useMemo(() => { const list = [] @@ -61,9 +62,8 @@ export const useChecklist = (nodes: Node[], edges: Edge[]) => { if (node.data.type === BlockEnum.Agent) { const data = node.data as AgentNodeType - const provider = agentStrategies.find(s => s.plugin_unique_identifier === data.plugin_unique_identifier) - const strategy = provider?.declaration.strategies.find(s => s.identity.name === data.agent_strategy_name) - // debugger + const provider = agentStrategies?.find(s => s.plugin_unique_identifier === data.plugin_unique_identifier) + const strategy = provider?.declaration.strategies?.find(s => s.identity.name === data.agent_strategy_name) moreDataForCheckValid = { provider, strategy, diff --git a/web/app/components/workflow/hooks/use-workflow.ts b/web/app/components/workflow/hooks/use-workflow.ts index 8ce31b8acf..0f6ae59b6e 100644 --- a/web/app/components/workflow/hooks/use-workflow.ts +++ b/web/app/components/workflow/hooks/use-workflow.ts @@ -58,7 +58,6 @@ import I18n from '@/context/i18n' import { CollectionType } from '@/app/components/tools/types' import { CUSTOM_ITERATION_START_NODE } from '@/app/components/workflow/nodes/iteration-start/constants' import { useWorkflowConfig } from '@/service/use-workflow' -import { fetchStrategyList } from '@/service/strategy' export const useIsChatMode = () => { const appDetail = useAppStore(s => s.appDetail) @@ -460,21 +459,6 @@ export const useFetchToolsData = () => { } } -export const useFetchAgentStrategy = () => { - const workflowStore = useWorkflowStore() - const handleFetchAllAgentStrategies = useCallback(async () => { - const agentStrategies = await fetchStrategyList() - - workflowStore.setState({ - agentStrategies: agentStrategies || [], - }) - }, [workflowStore]) - - return { - handleFetchAllAgentStrategies, - } -} - export const useWorkflowInit = () => { const workflowStore = useWorkflowStore() const { @@ -482,7 +466,6 @@ export const useWorkflowInit = () => { edges: edgesTemplate, } = useWorkflowTemplate() const { handleFetchAllTools } = useFetchToolsData() - const { handleFetchAllAgentStrategies } = useFetchAgentStrategy() const appDetail = useAppStore(state => state.appDetail)! const setSyncWorkflowDraftHash = useStore(s => s.setSyncWorkflowDraftHash) const [data, setData] = useState() @@ -562,8 +545,7 @@ export const useWorkflowInit = () => { handleFetchAllTools('builtin') handleFetchAllTools('custom') handleFetchAllTools('workflow') - handleFetchAllAgentStrategies() - }, [handleFetchPreloadData, handleFetchAllTools, handleFetchAllAgentStrategies]) + }, [handleFetchPreloadData, handleFetchAllTools]) useEffect(() => { if (data) { diff --git a/web/app/components/workflow/nodes/agent/default.ts b/web/app/components/workflow/nodes/agent/default.ts index da1cba4adc..4d7965c77f 100644 --- a/web/app/components/workflow/nodes/agent/default.ts +++ b/web/app/components/workflow/nodes/agent/default.ts @@ -18,8 +18,8 @@ const nodeDefault: NodeDefault = { : ALL_COMPLETION_AVAILABLE_BLOCKS }, checkValid(payload, t, moreDataForCheckValid: { - strategyProvider: StrategyPluginDetail | undefined, - strategy: StrategyDetail | undefined + strategyProvider?: StrategyPluginDetail, + strategy?: StrategyDetail language: string }) { const { strategy, language } = moreDataForCheckValid diff --git a/web/app/components/workflow/nodes/agent/use-config.ts b/web/app/components/workflow/nodes/agent/use-config.ts index d1446892c2..fda254be13 100644 --- a/web/app/components/workflow/nodes/agent/use-config.ts +++ b/web/app/components/workflow/nodes/agent/use-config.ts @@ -72,7 +72,6 @@ const useConfig = (id: string, payload: AgentNodeType) => { inputs.agent_strategy_provider_name, inputs.agent_strategy_name, ) - console.log('currentStrategyStatus', currentStrategyStatus) const pluginId = inputs.agent_strategy_provider_name?.split('/').splice(0, 2).join('/') const pluginDetail = useCheckInstalled({ pluginIds: [pluginId || ''], diff --git a/web/app/components/workflow/store.ts b/web/app/components/workflow/store.ts index b05c6676c0..6bd47eaa01 100644 --- a/web/app/components/workflow/store.ts +++ b/web/app/components/workflow/store.ts @@ -22,9 +22,6 @@ import type { } from './types' import { WorkflowContext } from './context' import type { NodeTracing, VersionHistory } from '@/types/workflow' -import type { - StrategyPluginDetail, -} from '@/app/components/plugins/types' // #TODO chatVar# // const MOCK_DATA = [ @@ -101,7 +98,6 @@ type Shape = { setCustomTools: (tools: ToolWithProvider[]) => void workflowTools: ToolWithProvider[] setWorkflowTools: (tools: ToolWithProvider[]) => void - agentStrategies: StrategyPluginDetail[], clipboardElements: Node[] setClipboardElements: (clipboardElements: Node[]) => void showDebugAndPreviewPanel: boolean @@ -234,7 +230,6 @@ export const createWorkflowStore = () => { setCustomTools: customTools => set(() => ({ customTools })), workflowTools: [], setWorkflowTools: workflowTools => set(() => ({ workflowTools })), - agentStrategies: [], clipboardElements: [], setClipboardElements: clipboardElements => set(() => ({ clipboardElements })), showDebugAndPreviewPanel: false,