mirror of
https://github.com/run-llama/ts-playground.git
synced 2026-07-01 20:44:01 -04:00
updated playground
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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(),
|
||||
})),
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user