Bugfix/Add return src docs to custom assistant (#4731)

add return src docs to custom assistant
This commit is contained in:
Henry Heng
2025-06-25 15:57:40 +01:00
committed by GitHub
parent d66e40e2e7
commit 7a5368c6f6
@@ -41,6 +41,7 @@ import ConfirmDialog from '@/ui-component/dialog/ConfirmDialog'
import PromptGeneratorDialog from '@/ui-component/dialog/PromptGeneratorDialog' import PromptGeneratorDialog from '@/ui-component/dialog/PromptGeneratorDialog'
import { Available } from '@/ui-component/rbac/available' import { Available } from '@/ui-component/rbac/available'
import ExpandTextDialog from '@/ui-component/dialog/ExpandTextDialog' import ExpandTextDialog from '@/ui-component/dialog/ExpandTextDialog'
import { SwitchInput } from '@/ui-component/switch/Switch'
// API // API
import assistantsApi from '@/api/assistants' import assistantsApi from '@/api/assistants'
@@ -351,6 +352,7 @@ const CustomAssistantConfigurePreview = () => {
const retrieverToolNodeData = cloneDeep(initNode(retrieverToolNode.data, retrieverToolId)) const retrieverToolNodeData = cloneDeep(initNode(retrieverToolNode.data, retrieverToolId))
set(docStoreVSNodeData, 'inputs.selectedStore', selectedDocumentStores[i].id) set(docStoreVSNodeData, 'inputs.selectedStore', selectedDocumentStores[i].id)
set(docStoreVSNodeData, 'outputs.output', 'retriever')
const docStoreOption = documentStoreOptions.find((ds) => ds.name === selectedDocumentStores[i].id) const docStoreOption = documentStoreOptions.find((ds) => ds.name === selectedDocumentStores[i].id)
// convert to small case and replace space with underscore // convert to small case and replace space with underscore
@@ -364,7 +366,7 @@ const CustomAssistantConfigurePreview = () => {
name, name,
description: desc, description: desc,
retriever: `{{${docStoreVSId}.data.instance}}`, retriever: `{{${docStoreVSId}.data.instance}}`,
returnSourceDocuments: true returnSourceDocuments: selectedDocumentStores[i].returnSourceDocuments ?? false
}) })
const docStoreVS = { const docStoreVS = {
@@ -671,7 +673,8 @@ const CustomAssistantConfigurePreview = () => {
const newDocStore = { const newDocStore = {
id: docStoreId, id: docStoreId,
name: foundDocumentStoreOption?.label || '', name: foundDocumentStoreOption?.label || '',
description: foundSelectedDocumentStore?.description || foundDocumentStoreOption?.description || '' description: foundSelectedDocumentStore?.description || foundDocumentStoreOption?.description || '',
returnSourceDocuments: foundSelectedDocumentStore?.returnSourceDocuments ?? false
} }
newSelectedDocumentStores.push(newDocStore) newSelectedDocumentStores.push(newDocStore)
@@ -1133,6 +1136,18 @@ const CustomAssistantConfigurePreview = () => {
setSelectedDocumentStores(newSelectedDocumentStores) setSelectedDocumentStores(newSelectedDocumentStores)
}} }}
/> />
<Stack sx={{ mt: 2, position: 'relative', alignItems: 'center' }} direction='row'>
<Typography>Return Source Documents</Typography>
<TooltipWithParser title='Return the actual source documents that were used to answer the question' />
</Stack>
<SwitchInput
value={ds.returnSourceDocuments ?? false}
onChange={(newValue) => {
const newSelectedDocumentStores = [...selectedDocumentStores]
newSelectedDocumentStores[index].returnSourceDocuments = newValue
setSelectedDocumentStores(newSelectedDocumentStores)
}}
/>
</Box> </Box>
) )
})} })}