-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
GoogleGenerativeAIError: [400 Bad Request] * BatchEmbedContentsRequest.requests: at most 100 requests can be in one batch #4491
Comments
🤖 Hey there, @ajaykrupalk! Great to see you back. Running into a bit of a snag, aren't we? Let's crack this one together. To resolve the "GoogleGenerativeAIError: [400 Bad Request] * BatchEmbedContentsRequest.requests: at most 100 requests can be in one batch" error when using Google Gemini Pro with GithubRepoLoader, you need to set the Here is how you can do it: import { GoogleGeminiProEmbeddings } from "langchain/embeddings/google";
const model = new GoogleGeminiProEmbeddings({ maxConcurrency: 100 }); This code will ensure that LangChain only sends 100 requests to Google Gemini Pro at a time, thus avoiding the error. This solution was also applied in a similar issue in the langchainjs repository: GoogleGenerativeAIEmbeddings cannot embed more than 100 documents, which was resolved by a pull request: google-genai[patch]: Extend GoogleGenerativeAIEmbeddings to embed more than 100 documents. As for the default value of Sources
|
@dosu-bot these are the changes I implemented yet I am seeing the error: const embeddings = new GoogleGenerativeAIEmbeddings({ |
🤖 Based on the information you've provided, it seems like you've correctly set the This could be due to the way the Here is the implementation of the export const chunkArray = <T>(arr: T[], chunkSize: number) =>
arr.reduce((chunks, elem, index) => {
const chunkIndex = Math.floor(index / chunkSize);
const chunk = chunks[chunkIndex] || [];
// eslint-disable-next-line no-param-reassign
chunks[chunkIndex] = chunk.concat([elem]);
return chunks;
}, [] as T[][]); This function is supposed to split the You can find the To resolve this issue, you should ensure that the I hope this helps! If you have any further questions, feel free to ask. Sources
|
hello @ajaykrupalk, I have also faced this issue. I used a little hack to bypass the issue. I processed the texts in batches. and we hit API every minute for one batch.
|
Hey @RitikSinha thank you, this will be really helpful. I will definitely try it. |
This can be fixed using the following code. The below code is used to send 50 documents at a time to the vector store. const batchSize = 50;
const totalDocuments = documents.length;
for (let i = 0; i < totalDocuments; i += batchSize) {
const batch = documents.slice(i, i + batchSize);
await vectorstore.addDocuments(batch);
} |
How do I resolve this error when using Google Gemini Pro along with GithubRepoLoader?
GoogleGenerativeAIError: [400 Bad Request] * BatchEmbedContentsRequest.requests: at most 100 requests can be in one batch
The text was updated successfully, but these errors were encountered: