From 7a5368c6f67263857518d9e7274f742af0c0e3a2 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Wed, 25 Jun 2025 15:57:40 +0100 Subject: [PATCH] Bugfix/Add return src docs to custom assistant (#4731) add return src docs to custom assistant --- .../CustomAssistantConfigurePreview.jsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/views/assistants/custom/CustomAssistantConfigurePreview.jsx b/packages/ui/src/views/assistants/custom/CustomAssistantConfigurePreview.jsx index 30687141..96fd824f 100644 --- a/packages/ui/src/views/assistants/custom/CustomAssistantConfigurePreview.jsx +++ b/packages/ui/src/views/assistants/custom/CustomAssistantConfigurePreview.jsx @@ -41,6 +41,7 @@ import ConfirmDialog from '@/ui-component/dialog/ConfirmDialog' import PromptGeneratorDialog from '@/ui-component/dialog/PromptGeneratorDialog' import { Available } from '@/ui-component/rbac/available' import ExpandTextDialog from '@/ui-component/dialog/ExpandTextDialog' +import { SwitchInput } from '@/ui-component/switch/Switch' // API import assistantsApi from '@/api/assistants' @@ -351,6 +352,7 @@ const CustomAssistantConfigurePreview = () => { const retrieverToolNodeData = cloneDeep(initNode(retrieverToolNode.data, retrieverToolId)) set(docStoreVSNodeData, 'inputs.selectedStore', selectedDocumentStores[i].id) + set(docStoreVSNodeData, 'outputs.output', 'retriever') const docStoreOption = documentStoreOptions.find((ds) => ds.name === selectedDocumentStores[i].id) // convert to small case and replace space with underscore @@ -364,7 +366,7 @@ const CustomAssistantConfigurePreview = () => { name, description: desc, retriever: `{{${docStoreVSId}.data.instance}}`, - returnSourceDocuments: true + returnSourceDocuments: selectedDocumentStores[i].returnSourceDocuments ?? false }) const docStoreVS = { @@ -671,7 +673,8 @@ const CustomAssistantConfigurePreview = () => { const newDocStore = { id: docStoreId, name: foundDocumentStoreOption?.label || '', - description: foundSelectedDocumentStore?.description || foundDocumentStoreOption?.description || '' + description: foundSelectedDocumentStore?.description || foundDocumentStoreOption?.description || '', + returnSourceDocuments: foundSelectedDocumentStore?.returnSourceDocuments ?? false } newSelectedDocumentStores.push(newDocStore) @@ -1133,6 +1136,18 @@ const CustomAssistantConfigurePreview = () => { setSelectedDocumentStores(newSelectedDocumentStores) }} /> + + Return Source Documents + + + { + const newSelectedDocumentStores = [...selectedDocumentStores] + newSelectedDocumentStores[index].returnSourceDocuments = newValue + setSelectedDocumentStores(newSelectedDocumentStores) + }} + /> ) })}