mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
Feature/Add ability to create new doc store on upsert (#3965)
add ability to create new doc store on upsert, update firecrawl properties
This commit is contained in:
@@ -76,6 +76,8 @@ export interface IDocumentStoreUpsertData {
|
||||
docId: string
|
||||
metadata?: string | object
|
||||
replaceExisting?: boolean
|
||||
createNewDocStore?: boolean
|
||||
docStore?: IDocumentStore
|
||||
loader?: {
|
||||
name: string
|
||||
config: ICommonObject
|
||||
|
||||
@@ -32,7 +32,8 @@ import {
|
||||
INodeData,
|
||||
MODE,
|
||||
IOverrideConfig,
|
||||
IExecutePreviewLoader
|
||||
IExecutePreviewLoader,
|
||||
DocumentStoreDTO
|
||||
} from '../../Interface'
|
||||
import { DocumentStoreFileChunk } from '../../database/entities/DocumentStoreFileChunk'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
@@ -1464,6 +1465,7 @@ const upsertDocStore = async (
|
||||
}
|
||||
}
|
||||
const replaceExisting = data.replaceExisting ?? false
|
||||
const createNewDocStore = data.createNewDocStore ?? false
|
||||
const newLoader = typeof data.loader === 'string' ? JSON.parse(data.loader) : data.loader
|
||||
const newSplitter = typeof data.splitter === 'string' ? JSON.parse(data.splitter) : data.splitter
|
||||
const newVectorStore = typeof data.vectorStore === 'string' ? JSON.parse(data.vectorStore) : data.vectorStore
|
||||
@@ -1533,6 +1535,15 @@ const upsertDocStore = async (
|
||||
recordManagerConfig = JSON.parse(entity.recordManagerConfig || '{}')?.config
|
||||
}
|
||||
|
||||
if (createNewDocStore) {
|
||||
const docStoreBody = typeof data.docStore === 'string' ? JSON.parse(data.docStore) : data.docStore
|
||||
const newDocumentStore = docStoreBody ?? { name: `Document Store ${Date.now().toString()}` }
|
||||
const docStore = DocumentStoreDTO.toEntity(newDocumentStore)
|
||||
const documentStore = appDataSource.getRepository(DocumentStore).create(docStore)
|
||||
const dbResponse = await appDataSource.getRepository(DocumentStore).save(documentStore)
|
||||
storeId = dbResponse.id
|
||||
}
|
||||
|
||||
// Step 2: Replace with new values
|
||||
loaderName = newLoader?.name ? getComponentLabelFromName(newLoader?.name) : loaderName
|
||||
loaderId = newLoader?.name || loaderId
|
||||
@@ -1687,6 +1698,7 @@ const upsertDocStore = async (
|
||||
isVectorStoreInsert: true
|
||||
})
|
||||
res.docId = newDocId
|
||||
if (createNewDocStore) res.storeId = storeId
|
||||
|
||||
return res
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user