mirror of
https://github.com/run-llama/ts-playground.git
synced 2026-07-01 20:44:01 -04:00
I Implemented your solution in a chat bot but I have got the message : You exceeded your current quota, please check your plan and billing details. #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @etouraille on GitHub (Nov 13, 2023).
Though, I have got the paying option : Here is my code :
`const essay = await fs.readFile(
"cv.txt",
"utf-8",
);
// Create Document object with essay
const document = new Document({text: essay});
@yisding commented on GitHub (Nov 13, 2023):
Your issue is probably an OpenAI related throttling issue. I know they've been having some API instability the last few days. Maybe try taking a look at your OpenAI settings on their UI?
@blacksoulx37 commented on GitHub (Nov 25, 2023):
const nodes = getNodesFromDocument(
new Document({text: essay}),
new SentenceSplitter({chunkSize: 1024, chunkOverlap: 20}),
);
const nodesWithEmbeddings = await VectorStoreIndex.getNodeEmbeddingResults(
nodes,
serviceContextFromDefaults(),
true,
);
const _nodesWithEmbedding = nodesWithEmbeddings.map((nodeWithEmbedding) => ({
text: nodeWithEmbedding.getContent(MetadataMode.NONE),
embedding: nodeWithEmbedding.getEmbedding(),
}))
const embeddingResults = _nodesWithEmbedding.map((config) => {
return new TextNode({text: config.text, embedding: config.embedding});
});
const indexDict = new IndexDict();
for (const node of embeddingResults) {
indexDict.addNode(node);
}
// Split text and create embeddings. Store them in a VectorStoreIndex
const index = await VectorStoreIndex.init({
indexStruct: indexDict,
serviceContext: serviceContextFromDefaults({
llm: new OpenAI({
model: "gpt-4",
temperature: 0.5,
topP: 0.8,
}),
}),
});
await index.vectorStore.add(embeddingResults);
if (!index.vectorStore.storesText) {
await index.docStore.addDocuments(embeddingResults, true);
}
await index.indexStore?.addIndexStruct(indexDict);
index.indexStruct = indexDict;
const retriever = index.asRetriever();
retriever.similarityTopK = 20 ?? 2;
const queryEngine = new RetrieverQueryEngine(retriever);`