mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2025-04-17 18:18:11 +00:00
Issue #204 Added a check to ensure that 'chunk.payload' exists and contains the 'id' property (#526)
* Issue #204 Added a check to ensure that 'chunk.payload' exists and contains the 'id' property before attempting to destructure it * run linter * simplify condition and comment --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
This commit is contained in:
parent
a1b4ed43ba
commit
b7d2756754
1 changed files with 12 additions and 5 deletions
|
@ -152,13 +152,20 @@ const QDrant = {
|
|||
|
||||
// Before sending to Qdrant and saving the records to our db
|
||||
// we need to assign the id of each chunk that is stored in the cached file.
|
||||
// The id property must be defined or else it will be unable to be managed by ALLM.
|
||||
chunk.forEach((chunk) => {
|
||||
const id = uuidv4();
|
||||
const { id: _id, ...payload } = chunk.payload;
|
||||
documentVectors.push({ docId, vectorId: id });
|
||||
submission.ids.push(id);
|
||||
submission.vectors.push(chunk.vector);
|
||||
submission.payloads.push(payload);
|
||||
if (chunk?.payload?.hasOwnProperty("id")) {
|
||||
const { id: _id, ...payload } = chunk.payload;
|
||||
documentVectors.push({ docId, vectorId: id });
|
||||
submission.ids.push(id);
|
||||
submission.vectors.push(chunk.vector);
|
||||
submission.payloads.push(payload);
|
||||
} else {
|
||||
console.error(
|
||||
"The 'id' property is not defined in chunk.payload - it will be omitted from being inserted in QDrant collection."
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const additionResult = await client.upsert(namespace, {
|
||||
|
|
Loading…
Add table
Reference in a new issue