Skip to content

Commit a9f9c88

Browse files
authored
Bugfix/Save chunk's metadata (#2366)
save metadata chunk
1 parent 26e7a1a commit a9f9c88

File tree

2 files changed

+5
-3
lines changed
  • packages/server/src

2 files changed

+5
-3
lines changed

packages/server/src/controllers/documentstore/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const editDocumentStoreFileChunk = async (req: Request, res: Response, next: Nex
141141
)
142142
}
143143
const body = req.body
144-
if (typeof body === 'undefined' || body.pageContent === 'undefined' || body.pageContent === '') {
144+
if (typeof body === 'undefined') {
145145
throw new InternalFlowiseError(
146146
StatusCodes.PRECONDITION_FAILED,
147147
`Error: documentStoreController.editDocumentStoreFileChunk - body not provided!`
@@ -151,7 +151,8 @@ const editDocumentStoreFileChunk = async (req: Request, res: Response, next: Nex
151151
req.params.storeId,
152152
req.params.loaderId,
153153
req.params.chunkId,
154-
body.pageContent
154+
body.pageContent,
155+
body.metadata
155156
)
156157
return res.json(apiResponse)
157158
} catch (error) {

packages/server/src/services/documentstore/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ const deleteDocumentStoreFileChunk = async (storeId: string, docId: string, chun
282282
}
283283
}
284284

285-
const editDocumentStoreFileChunk = async (storeId: string, docId: string, chunkId: string, content: string) => {
285+
const editDocumentStoreFileChunk = async (storeId: string, docId: string, chunkId: string, content: string, metadata: ICommonObject) => {
286286
try {
287287
const appServer = getRunningExpressApp()
288288
const entity = await appServer.AppDataSource.getRepository(DocumentStore).findOneBy({
@@ -305,6 +305,7 @@ const editDocumentStoreFileChunk = async (storeId: string, docId: string, chunkI
305305
}
306306
found.totalChars -= editChunk.pageContent.length
307307
editChunk.pageContent = content
308+
editChunk.metadata = JSON.stringify(metadata)
308309
found.totalChars += content.length
309310
await appServer.AppDataSource.getRepository(DocumentStoreFileChunk).save(editChunk)
310311
entity.loaders = JSON.stringify(loaders)

0 commit comments

Comments
 (0)