mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-19 04:30:10 +01: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
@ -152,13 +152,20 @@ const QDrant = {
|
|||||||
|
|
||||||
// Before sending to Qdrant and saving the records to our db
|
// 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.
|
// 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) => {
|
chunk.forEach((chunk) => {
|
||||||
const id = uuidv4();
|
const id = uuidv4();
|
||||||
const { id: _id, ...payload } = chunk.payload;
|
if (chunk?.payload?.hasOwnProperty("id")) {
|
||||||
documentVectors.push({ docId, vectorId: id });
|
const { id: _id, ...payload } = chunk.payload;
|
||||||
submission.ids.push(id);
|
documentVectors.push({ docId, vectorId: id });
|
||||||
submission.vectors.push(chunk.vector);
|
submission.ids.push(id);
|
||||||
submission.payloads.push(payload);
|
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, {
|
const additionResult = await client.upsert(namespace, {
|
||||||
|
Loading…
Reference in New Issue
Block a user