diff --git a/frontend/src/agents/workflow/WorkflowBuilder.tsx b/frontend/src/agents/workflow/WorkflowBuilder.tsx index b5649d2c..dfa4e532 100644 --- a/frontend/src/agents/workflow/WorkflowBuilder.tsx +++ b/frontend/src/agents/workflow/WorkflowBuilder.tsx @@ -75,7 +75,17 @@ import { validateCodeJsonSchema, } from './codeNodeConfig'; import MobileBlocker from './components/MobileBlocker'; -import PromptTextArea from './components/PromptTextArea'; +import PromptTextArea, { + extractUpstreamVariables, +} from './components/PromptTextArea'; +import { + documentsModeToInputDocuments, + FILE_PASSING_OPTIONS, + FilePassing, + getDocumentsMode, + normalizeFilePassing, + toDocumentVariableOptions, +} from './documentConfig'; import { AgentNode, CodeNode, @@ -104,6 +114,8 @@ interface AgentNodeConfig { chunks?: string; retriever?: string; json_schema?: Record; + input_documents?: string[]; + file_passing?: FilePassing; } interface UserTool { @@ -1455,6 +1467,13 @@ function WorkflowBuilderInner() { return selectedModel.supports_structured_output; }, [selectedNode, availableModels]); + const selectedAgentDocumentOptions = useMemo(() => { + if (!selectedNode || selectedNode.type !== 'agent') return []; + return toDocumentVariableOptions( + extractUpstreamVariables(nodes, edges, selectedNode.id), + ); + }, [selectedNode, nodes, edges]); + const selectedCodeJsonSchemaText = useMemo(() => { if (!selectedNode || selectedNode.type !== 'code') return ''; @@ -2191,6 +2210,131 @@ function WorkflowBuilderInner() { emptyText="No sources available" /> + {(() => { + const inputDocuments = + selectedNode.data.config?.input_documents; + const documentsMode = + getDocumentsMode(inputDocuments); + const chosenDocuments = + documentsMode === 'choose' + ? (inputDocuments ?? []) + : []; + const filePassing = normalizeFilePassing( + selectedNode.data.config?.file_passing, + ); + const setInputDocuments = ( + nextInputDocuments: string[], + ) => + handleUpdateNodeData({ + config: { + ...(selectedNode.data.config || {}), + input_documents: nextInputDocuments, + }, + }); + return ( + <> +
+ +
+ {( + [ + ['all', 'All input docs'], + ['none', 'None'], + ['choose', 'Choose…'], + ] as const + ).map(([mode, modeLabel]) => ( + + ))} +
+ {documentsMode === 'choose' && ( +
+ + setInputDocuments( + documentsModeToInputDocuments( + 'choose', + nextDocuments, + ), + ) + } + placeholder="Select documents..." + searchPlaceholder="Search variables..." + emptyText="No upstream documents" + /> +
+ )} +

+ Documents passed to this agent from + uploads or upstream nodes. +

+
+
+ + +

+ Auto: send native when the model + supports it, otherwise extract text. +

+
+ + ); + })()}