diff --git a/langchain/src/vectorstores/xata.ts b/langchain/src/vectorstores/xata.ts index 16dd64ca62e0..80817c657465 100644 --- a/langchain/src/vectorstores/xata.ts +++ b/langchain/src/vectorstores/xata.ts @@ -128,20 +128,22 @@ export class XataVectorSearch< ); // eslint-disable-next-line @typescript-eslint/no-explicit-any - return records.map((record: any) => [ - new Document({ - pageContent: record.content, - metadata: Object.fromEntries( - Object.entries(record).filter( - ([key]) => - key !== "content" && - key !== "embedding" && - key !== "xata" && - key !== "id" - ) - ), - }), - record.xata.score, - ]); + return ( + records?.map((record: any) => [ + new Document({ + pageContent: record.content, + metadata: Object.fromEntries( + Object.entries(record).filter( + ([key]) => + key !== "content" && + key !== "embedding" && + key !== "xata" && + key !== "id" + ) + ), + }), + record.xata.score, + ]) ?? [] + ); } }