updated playground

This commit is contained in:
Yi Ding
2023-08-19 21:16:40 -07:00
parent 16f0492431
commit dbdc525684
2 changed files with 4 additions and 10 deletions
+3 -9
View File
@@ -41,13 +41,10 @@ export default async function handler(
req.body;
const embeddingResults = nodesWithEmbedding.map((config) => {
return {
node: new TextNode({ text: config.text }),
embedding: config.embedding,
};
return new TextNode({ text: config.text, embedding: config.embedding });
});
const indexDict = new IndexDict();
for (const { node } of embeddingResults) {
for (const node of embeddingResults) {
indexDict.addNode(node);
}
@@ -60,10 +57,7 @@ export default async function handler(
index.vectorStore.add(embeddingResults);
if (!index.vectorStore.storesText) {
await index.docStore.addDocuments(
embeddingResults.map((result) => result.node),
true,
);
await index.docStore.addDocuments(embeddingResults, true);
}
await index.indexStore?.addIndexStruct(indexDict);
index.indexStruct = indexDict;
+1 -1
View File
@@ -51,7 +51,7 @@ export default async function handler(
payload: {
nodesWithEmbedding: nodesWithEmbeddings.map((nodeWithEmbedding) => ({
text: nodeWithEmbedding.getContent(MetadataMode.NONE),
embedding: nodeWithEmbedding.embedding,
embedding: nodeWithEmbedding.getEmbedding(),
})),
},
});