Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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. #4

Open
etouraille opened this issue Nov 13, 2023 · 2 comments

Comments

@etouraille
Copy link

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});

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);`
@yisding
Copy link
Contributor

yisding commented 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
Copy link

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);`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants