You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ERROR [Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.contents[41].parts: contents.parts must not be empty.
While implementing chat with history, be careful in cases where some Message property "content" comes empty, it will cause this error. Apparently this is only happening with ChatGoogleGenerativeAI, I'm using several others and didn't had this issue.
For now i made sure to filter those empty entries out, but still, i think this should be handled either by Google or by this repo.
Thanks!
The text was updated successfully, but these errors were encountered:
Sure thing @lkuligin !
This is what I`m talking about, I understand this is not an intended use case (for me), might happen, accidentally or intentionally, it might, in my case it was an accident during tests, which a message landed empty (Eg.: new HumanMessage({ content: "" })) on my history.
But this case errors only with ChatGoogleGenerativeAI, other chat wrappers wont error.
The sample
async generateGeminiTest(request: ChatRequest) {
const geminiClient = new ChatGoogleGenerativeAI({
modelName: request.model,
temperature: request.temperature,
});
const someAIMessage = "You are a helpful assistant.";
return geminiClient.invoke([
new AIMessage({ content: someAIMessage }),
new HumanMessage({ content: "" }),
new HumanMessage({ content: request.prompt }),
]);
}
The error:
[GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.contents[1].parts: contents.parts must not be empty.
ERROR [Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:streamGenerateContent?alt=sse: [400 Bad Request] * GenerateContentRequest.contents[41].parts: contents.parts must not be empty.
While implementing chat with history, be careful in cases where some Message property "content" comes empty, it will cause this error. Apparently this is only happening with ChatGoogleGenerativeAI, I'm using several others and didn't had this issue.
For now i made sure to filter those empty entries out, but still, i think this should be handled either by Google or by this repo.
Thanks!
The text was updated successfully, but these errors were encountered: