Closed akmalmzamri closed 2 months ago
Same here, trying to use streamObject
with Gemini 1.5 Flash
same here bruh where are the fixes
Hi @lgrammel. Do you have any updates on this?
If this is a 500 from google that appears only part of the time, it's an issue with google not the ai sdk
Do you have a concrete scenario that reproduces the error 100% of the time?
Hi everyone, I have the error 100% of the time when i use the 'models/gemini-1.5-flash-latest' model with streamObject or generateObject but with the others models it works well, here is an example of an action i use :
'use server';
import { google } from '@ai-sdk/google';
import { generateObject } from 'ai';
import { z } from 'zod';
export const streamCourseObject = async ({
promptContent,
}: {
promptContent: string;
}) => {
'use server';
try {
const { object } = await generateObject({
model: google('models/gemini-1.5-flash-latest'),
prompt: `${process.env.COURSE_PROMPT}${promptContent}`,
schema: z.object({
course: z.object({
resume: z.array(
z.object({ htmlContent: z.string(), timestamp: z.number() }),
),
keyConcepts: z.array(z.string()),
}),
}),
});
return { course: object.course };
} catch (error) {
console.error('Error in streamCourseObject:', error);
return {
error:
"Sorry, we couldn't generate the course object. Please retry later",
};
}
};
Thanks
@Ahmed-OC if it works with the other models, but not with flash, then it's an issue on the Google side. If it was an issue with the AI SDK, it would not work with the other models.
Hey guys,
The solution for me was to add { mode: 'json' }
to parameters.
@Ahmed-OC great, I'll switch the default mode to json https://github.com/vercel/ai/pull/2691
Updated default mode to json
Description
Hi all. I'm having a great time using Vercel AI SDK with OpenAI. However, I'm experiencing a few blocking issues with Gemini and Google Generative AI Provider when using
streamObject
.One of the issues I'm facing is that the
streamObject
call failed 90% of the time. This is the error that I receivedEverything's fine when I use
streamText
.Code example
Additional context
My deps