mirror of https://github.com/langgenius/dify.git
fix: workflow store agent strategy not up to date
This commit is contained in:
parent
15f3e46c49
commit
0beebab605
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ const nodeDefault: NodeDefault<AgentNodeType> = {
|
|||
: ALL_COMPLETION_AVAILABLE_BLOCKS
|
||||
},
|
||||
checkValid(payload, t, moreDataForCheckValid: {
|
||||
strategyProvider: StrategyPluginDetail | undefined,
|
||||
strategy: StrategyDetail | undefined
|
||||
strategyProvider?: StrategyPluginDetail,
|
||||
strategy?: StrategyDetail
|
||||
language: string
|
||||
}) {
|
||||
const { strategy, language } = moreDataForCheckValid
|
||||
|
|
|
|||
|
|
@ -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 || ''],
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue