mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
fix: workflow store agent strategy not up to date
This commit is contained in:
@ -25,6 +25,7 @@ import { useToastContext } from '@/app/components/base/toast'
|
|||||||
import { CollectionType } from '@/app/components/tools/types'
|
import { CollectionType } from '@/app/components/tools/types'
|
||||||
import { useGetLanguage } from '@/context/i18n'
|
import { useGetLanguage } from '@/context/i18n'
|
||||||
import type { AgentNodeType } from '../nodes/agent/types'
|
import type { AgentNodeType } from '../nodes/agent/types'
|
||||||
|
import { useStrategyProviders } from '@/service/use-strategy'
|
||||||
|
|
||||||
export const useChecklist = (nodes: Node[], edges: Edge[]) => {
|
export const useChecklist = (nodes: Node[], edges: Edge[]) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -34,7 +35,7 @@ export const useChecklist = (nodes: Node[], edges: Edge[]) => {
|
|||||||
const buildInTools = useStore(s => s.buildInTools)
|
const buildInTools = useStore(s => s.buildInTools)
|
||||||
const customTools = useStore(s => s.customTools)
|
const customTools = useStore(s => s.customTools)
|
||||||
const workflowTools = useStore(s => s.workflowTools)
|
const workflowTools = useStore(s => s.workflowTools)
|
||||||
const agentStrategies = useStore(s => s.agentStrategies)
|
const { data: agentStrategies } = useStrategyProviders()
|
||||||
|
|
||||||
const needWarningNodes = useMemo(() => {
|
const needWarningNodes = useMemo(() => {
|
||||||
const list = []
|
const list = []
|
||||||
@ -61,9 +62,8 @@ export const useChecklist = (nodes: Node[], edges: Edge[]) => {
|
|||||||
|
|
||||||
if (node.data.type === BlockEnum.Agent) {
|
if (node.data.type === BlockEnum.Agent) {
|
||||||
const data = node.data as AgentNodeType
|
const data = node.data as AgentNodeType
|
||||||
const provider = agentStrategies.find(s => s.plugin_unique_identifier === data.plugin_unique_identifier)
|
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)
|
const strategy = provider?.declaration.strategies?.find(s => s.identity.name === data.agent_strategy_name)
|
||||||
// debugger
|
|
||||||
moreDataForCheckValid = {
|
moreDataForCheckValid = {
|
||||||
provider,
|
provider,
|
||||||
strategy,
|
strategy,
|
||||||
|
|||||||
@ -58,7 +58,6 @@ import I18n from '@/context/i18n'
|
|||||||
import { CollectionType } from '@/app/components/tools/types'
|
import { CollectionType } from '@/app/components/tools/types'
|
||||||
import { CUSTOM_ITERATION_START_NODE } from '@/app/components/workflow/nodes/iteration-start/constants'
|
import { CUSTOM_ITERATION_START_NODE } from '@/app/components/workflow/nodes/iteration-start/constants'
|
||||||
import { useWorkflowConfig } from '@/service/use-workflow'
|
import { useWorkflowConfig } from '@/service/use-workflow'
|
||||||
import { fetchStrategyList } from '@/service/strategy'
|
|
||||||
|
|
||||||
export const useIsChatMode = () => {
|
export const useIsChatMode = () => {
|
||||||
const appDetail = useAppStore(s => s.appDetail)
|
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 = () => {
|
export const useWorkflowInit = () => {
|
||||||
const workflowStore = useWorkflowStore()
|
const workflowStore = useWorkflowStore()
|
||||||
const {
|
const {
|
||||||
@ -482,7 +466,6 @@ export const useWorkflowInit = () => {
|
|||||||
edges: edgesTemplate,
|
edges: edgesTemplate,
|
||||||
} = useWorkflowTemplate()
|
} = useWorkflowTemplate()
|
||||||
const { handleFetchAllTools } = useFetchToolsData()
|
const { handleFetchAllTools } = useFetchToolsData()
|
||||||
const { handleFetchAllAgentStrategies } = useFetchAgentStrategy()
|
|
||||||
const appDetail = useAppStore(state => state.appDetail)!
|
const appDetail = useAppStore(state => state.appDetail)!
|
||||||
const setSyncWorkflowDraftHash = useStore(s => s.setSyncWorkflowDraftHash)
|
const setSyncWorkflowDraftHash = useStore(s => s.setSyncWorkflowDraftHash)
|
||||||
const [data, setData] = useState<FetchWorkflowDraftResponse>()
|
const [data, setData] = useState<FetchWorkflowDraftResponse>()
|
||||||
@ -562,8 +545,7 @@ export const useWorkflowInit = () => {
|
|||||||
handleFetchAllTools('builtin')
|
handleFetchAllTools('builtin')
|
||||||
handleFetchAllTools('custom')
|
handleFetchAllTools('custom')
|
||||||
handleFetchAllTools('workflow')
|
handleFetchAllTools('workflow')
|
||||||
handleFetchAllAgentStrategies()
|
}, [handleFetchPreloadData, handleFetchAllTools])
|
||||||
}, [handleFetchPreloadData, handleFetchAllTools, handleFetchAllAgentStrategies])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|||||||
@ -18,8 +18,8 @@ const nodeDefault: NodeDefault<AgentNodeType> = {
|
|||||||
: ALL_COMPLETION_AVAILABLE_BLOCKS
|
: ALL_COMPLETION_AVAILABLE_BLOCKS
|
||||||
},
|
},
|
||||||
checkValid(payload, t, moreDataForCheckValid: {
|
checkValid(payload, t, moreDataForCheckValid: {
|
||||||
strategyProvider: StrategyPluginDetail | undefined,
|
strategyProvider?: StrategyPluginDetail,
|
||||||
strategy: StrategyDetail | undefined
|
strategy?: StrategyDetail
|
||||||
language: string
|
language: string
|
||||||
}) {
|
}) {
|
||||||
const { strategy, language } = moreDataForCheckValid
|
const { strategy, language } = moreDataForCheckValid
|
||||||
|
|||||||
@ -72,7 +72,6 @@ const useConfig = (id: string, payload: AgentNodeType) => {
|
|||||||
inputs.agent_strategy_provider_name,
|
inputs.agent_strategy_provider_name,
|
||||||
inputs.agent_strategy_name,
|
inputs.agent_strategy_name,
|
||||||
)
|
)
|
||||||
console.log('currentStrategyStatus', currentStrategyStatus)
|
|
||||||
const pluginId = inputs.agent_strategy_provider_name?.split('/').splice(0, 2).join('/')
|
const pluginId = inputs.agent_strategy_provider_name?.split('/').splice(0, 2).join('/')
|
||||||
const pluginDetail = useCheckInstalled({
|
const pluginDetail = useCheckInstalled({
|
||||||
pluginIds: [pluginId || ''],
|
pluginIds: [pluginId || ''],
|
||||||
|
|||||||
@ -22,9 +22,6 @@ import type {
|
|||||||
} from './types'
|
} from './types'
|
||||||
import { WorkflowContext } from './context'
|
import { WorkflowContext } from './context'
|
||||||
import type { NodeTracing, VersionHistory } from '@/types/workflow'
|
import type { NodeTracing, VersionHistory } from '@/types/workflow'
|
||||||
import type {
|
|
||||||
StrategyPluginDetail,
|
|
||||||
} from '@/app/components/plugins/types'
|
|
||||||
|
|
||||||
// #TODO chatVar#
|
// #TODO chatVar#
|
||||||
// const MOCK_DATA = [
|
// const MOCK_DATA = [
|
||||||
@ -101,7 +98,6 @@ type Shape = {
|
|||||||
setCustomTools: (tools: ToolWithProvider[]) => void
|
setCustomTools: (tools: ToolWithProvider[]) => void
|
||||||
workflowTools: ToolWithProvider[]
|
workflowTools: ToolWithProvider[]
|
||||||
setWorkflowTools: (tools: ToolWithProvider[]) => void
|
setWorkflowTools: (tools: ToolWithProvider[]) => void
|
||||||
agentStrategies: StrategyPluginDetail[],
|
|
||||||
clipboardElements: Node[]
|
clipboardElements: Node[]
|
||||||
setClipboardElements: (clipboardElements: Node[]) => void
|
setClipboardElements: (clipboardElements: Node[]) => void
|
||||||
showDebugAndPreviewPanel: boolean
|
showDebugAndPreviewPanel: boolean
|
||||||
@ -234,7 +230,6 @@ export const createWorkflowStore = () => {
|
|||||||
setCustomTools: customTools => set(() => ({ customTools })),
|
setCustomTools: customTools => set(() => ({ customTools })),
|
||||||
workflowTools: [],
|
workflowTools: [],
|
||||||
setWorkflowTools: workflowTools => set(() => ({ workflowTools })),
|
setWorkflowTools: workflowTools => set(() => ({ workflowTools })),
|
||||||
agentStrategies: [],
|
|
||||||
clipboardElements: [],
|
clipboardElements: [],
|
||||||
setClipboardElements: clipboardElements => set(() => ({ clipboardElements })),
|
setClipboardElements: clipboardElements => set(() => ({ clipboardElements })),
|
||||||
showDebugAndPreviewPanel: false,
|
showDebugAndPreviewPanel: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user