fix: workflow store agent strategy not up to date

This commit is contained in:
AkaraChen
2025-01-07 09:57:35 +08:00
parent 15f3e46c49
commit 0beebab605
5 changed files with 7 additions and 31 deletions

View File

@ -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,

View File

@ -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<FetchWorkflowDraftResponse>()
@ -562,8 +545,7 @@ export const useWorkflowInit = () => {
handleFetchAllTools('builtin')
handleFetchAllTools('custom')
handleFetchAllTools('workflow')
handleFetchAllAgentStrategies()
}, [handleFetchPreloadData, handleFetchAllTools, handleFetchAllAgentStrategies])
}, [handleFetchPreloadData, handleFetchAllTools])
useEffect(() => {
if (data) {