mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Bugfix/implement missing delete method on pgvector (#3180)
implement missing delete method on pgvector
This commit is contained in:
@@ -191,6 +191,18 @@ class Postgres_VectorStores implements INode {
|
|||||||
return await similaritySearchVectorWithScore(query, k, tableName, postgresConnectionOptions, filter)
|
return await similaritySearchVectorWithScore(query, k, tableName, postgresConnectionOptions, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vectorStore.delete = async (params: { ids: string[] }): Promise<void> => {
|
||||||
|
const { ids } = params
|
||||||
|
|
||||||
|
if (ids?.length) {
|
||||||
|
try {
|
||||||
|
vectorStore.appDataSource.getRepository(vectorStore.documentEntity).delete(ids)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to delete')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await recordManager.createSchema()
|
await recordManager.createSchema()
|
||||||
|
|
||||||
const res = await index({
|
const res = await index({
|
||||||
|
|||||||
@@ -597,11 +597,8 @@ const processAndSaveChunks = async (data: IDocumentStoreLoaderForPreview) => {
|
|||||||
const newLoaderId = data.id ?? uuidv4()
|
const newLoaderId = data.id ?? uuidv4()
|
||||||
const found = existingLoaders.find((ldr: IDocumentStoreLoader) => ldr.id === newLoaderId)
|
const found = existingLoaders.find((ldr: IDocumentStoreLoader) => ldr.id === newLoaderId)
|
||||||
if (found) {
|
if (found) {
|
||||||
// clean up the current status and mark the loader as pending_sync
|
const foundIndex = existingLoaders.findIndex((ldr: IDocumentStoreLoader) => ldr.id === newLoaderId)
|
||||||
found.totalChunks = 0
|
|
||||||
found.totalChars = 0
|
|
||||||
found.status = DocumentStoreStatus.SYNCING
|
|
||||||
entity.loaders = JSON.stringify(existingLoaders)
|
|
||||||
if (!data.loaderId) data.loaderId = found.loaderId
|
if (!data.loaderId) data.loaderId = found.loaderId
|
||||||
if (!data.loaderName) data.loaderName = found.loaderName
|
if (!data.loaderName) data.loaderName = found.loaderName
|
||||||
if (!data.loaderConfig) data.loaderConfig = found.loaderConfig
|
if (!data.loaderConfig) data.loaderConfig = found.loaderConfig
|
||||||
@@ -611,6 +608,25 @@ const processAndSaveChunks = async (data: IDocumentStoreLoaderForPreview) => {
|
|||||||
if (found.credential) {
|
if (found.credential) {
|
||||||
data.credential = found.credential
|
data.credential = found.credential
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let loader: IDocumentStoreLoader = {
|
||||||
|
...found,
|
||||||
|
loaderId: data.loaderId,
|
||||||
|
loaderName: data.loaderName,
|
||||||
|
loaderConfig: data.loaderConfig,
|
||||||
|
splitterId: data.splitterId,
|
||||||
|
splitterName: data.splitterName,
|
||||||
|
splitterConfig: data.splitterConfig,
|
||||||
|
totalChunks: 0,
|
||||||
|
totalChars: 0,
|
||||||
|
status: DocumentStoreStatus.SYNCING
|
||||||
|
}
|
||||||
|
if (data.credential) {
|
||||||
|
loader.credential = data.credential
|
||||||
|
}
|
||||||
|
|
||||||
|
existingLoaders[foundIndex] = loader
|
||||||
|
entity.loaders = JSON.stringify(existingLoaders)
|
||||||
} else {
|
} else {
|
||||||
let loader: IDocumentStoreLoader = {
|
let loader: IDocumentStoreLoader = {
|
||||||
id: newLoaderId,
|
id: newLoaderId,
|
||||||
|
|||||||
Reference in New Issue
Block a user