Compare commits

...

1 Commits

Author SHA1 Message Date
Henry 23fc91817e add return src docs to custom assistant 2025-06-25 15:44:22 +01:00
1 changed files with 17 additions and 2 deletions

View File

@ -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)
}}
/>
<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>
)
})}