diff --git a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx index 4df37bbcbb..20e25ac850 100644 --- a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx +++ b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx @@ -136,8 +136,9 @@ const GetAutomaticRes: FC = ({ }, ] - const [instruction, setInstruction] = useState('') - const [ideaOutput, setIdeaOutput] = useState('') + const [instruction, setInstruction] = useState('The travel plan to Anshun of Guizhou Province in China') // TODO: test value + const [ideaOutput, setIdeaOutput] = useState('use json format to output the result. Content in result uses Chinese. Format: {"summary: "summary content", "result": "result content"}') + const [currentPrompt, setCurrentPrompt] = useState('') const [isFoldIdeaOutput, { toggle: toggleFoldIdeaOutput, }] = useBoolean(true) @@ -226,7 +227,11 @@ const GetAutomaticRes: FC = ({ setLoadingTrue() try { const { error, ...res } = await generateRule({ + flow_id: flowId, + node_id: nodeId, + current: currentPrompt, instruction, + idea_output: ideaOutput, model_config: model, }) setRes(res) diff --git a/web/app/components/workflow-app/hooks/use-configs-map.ts b/web/app/components/workflow-app/hooks/use-configs-map.ts index 0db4f77856..628a1d1d73 100644 --- a/web/app/components/workflow-app/hooks/use-configs-map.ts +++ b/web/app/components/workflow-app/hooks/use-configs-map.ts @@ -5,6 +5,7 @@ export const useConfigsMap = () => { const appId = useStore(s => s.appId) return useMemo(() => { return { + flowId: appId, conversationVarsUrl: `apps/${appId}/workflows/draft/conversation-variables`, systemVarsUrl: `apps/${appId}/workflows/draft/system-variables`, } diff --git a/web/app/components/workflow-app/hooks/use-workflow-run.ts b/web/app/components/workflow-app/hooks/use-workflow-run.ts index c303211715..10155f6128 100644 --- a/web/app/components/workflow-app/hooks/use-workflow-run.ts +++ b/web/app/components/workflow-app/hooks/use-workflow-run.ts @@ -35,7 +35,6 @@ export const useWorkflowRun = () => { const invalidAllLastRun = useInvalidAllLastRun(appId as string) const configsMap = useConfigsMap() const { fetchInspectVars } = useSetWorkflowVarsWithValue({ - flowId: appId as string, ...configsMap, }) diff --git a/web/app/components/workflow/hooks-store/store.ts b/web/app/components/workflow/hooks-store/store.ts index 4e8f74c774..7e7358d9d6 100644 --- a/web/app/components/workflow/hooks-store/store.ts +++ b/web/app/components/workflow/hooks-store/store.ts @@ -49,6 +49,7 @@ type CommonHooksFnMap = { resetConversationVar: (varId: string) => Promise invalidateConversationVarValues: () => void configsMap?: { + flowId: string conversationVarsUrl: string systemVarsUrl: string } 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 ce9fbb77e1..3b5b81ed1f 100644 --- a/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx +++ b/web/app/components/workflow/nodes/_base/components/agent-strategy.tsx @@ -87,6 +87,7 @@ export const AgentStrategy = memo((props: AgentStrategyProps) => { headerClassName='bg-transparent px-0 text-text-secondary system-sm-semibold-uppercase' containerBackgroundClassName='bg-transparent' gradientBorder={false} + nodeId={nodeId} isSupportPromptGenerator={!!def.auto_generate?.type} titleTooltip={schema.tooltip && renderI18nObject(schema.tooltip)} editorContainerClassName='px-0' 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 3796cb19bf..ac9020ebe2 100644 --- a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx +++ b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx @@ -41,6 +41,7 @@ type Props = { className?: string headerClassName?: string instanceId?: string + nodeId?: string title: string | React.JSX.Element value: string onChange: (value: string) => void @@ -83,6 +84,7 @@ const Editor: FC = ({ className, headerClassName, instanceId, + nodeId, title, value, onChange, @@ -160,6 +162,7 @@ const Editor: FC = ({
{value?.length || 0}
{isSupportPromptGenerator && ( = ({ hasSetBlockStatus={hasSetBlockStatus} nodesOutputVars={availableVars} availableNodes={availableNodes} + nodeId={id} isSupportPromptGenerator={payload.role === PromptRole.system} onGenerated={handleGenerated} modelConfig={modelConfig} diff --git a/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx b/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx index ec1456e92c..a866f7397f 100644 --- a/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx +++ b/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx @@ -10,11 +10,13 @@ import { AppType } from '@/types/app' import type { AutomaticRes } from '@/service/debug' import type { ModelConfig, Node, NodeOutPutVar } from '@/app/components/workflow/types' import { GeneratorType } from '@/app/components/app/configuration/config/automatic/types' +import { useHooksStore } from '../../../hooks-store' type Props = { className?: string onGenerated?: (prompt: string) => void modelConfig?: ModelConfig + nodeId: string nodesOutputVars?: NodeOutPutVar[] availableNodes?: Node[] } @@ -22,6 +24,7 @@ type Props = { const PromptGeneratorBtn: FC = ({ className, onGenerated, + nodeId, nodesOutputVars, availableNodes, }) => { @@ -30,6 +33,7 @@ const PromptGeneratorBtn: FC = ({ onGenerated?.(res.prompt) showAutomaticFalse() }, [onGenerated, showAutomaticFalse]) + const configsMap = useHooksStore(s => s.configsMap) return (
= ({ generatorType={GeneratorType.prompt} nodesOutputVars={nodesOutputVars} availableNodes={availableNodes} + flowId={configsMap?.flowId || ''} + nodeId={nodeId} /> )}
diff --git a/web/service/debug.ts b/web/service/debug.ts index 3770c4d398..fea64fc30b 100644 --- a/web/service/debug.ts +++ b/web/service/debug.ts @@ -72,7 +72,7 @@ export const fetchConversationMessages = (appId: string, conversation_id: string } export const generateRule = (body: Record) => { - return post('/rule-generate', { + return post('/instruction-generate', { body, }) }