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

The streamable UI has been slow to update. This may be a bug or a performance issue or you forgot to call .done() #3092

Open
ajaykrupalk opened this issue Sep 21, 2024 · 0 comments
Labels

Comments

@ajaykrupalk
Copy link

Description

My first tool call is happening as expected, but the consecutive call is returning this error The streamable UI has been slow to update. This may be a bug or a performance issue or you forgot to call .done()

My code can be found here

I am following the next.js template for rsc-preview https://github.com/vercel-labs/ai-sdk-preview-rsc-genui

Code example

const contentStream = createStreamableValue("");

const { value: stream } = await streamUI({
model: google('gemini-1.5-flash-latest'),
system: \ - you are a friendly assistant - you are concise with your responses - you do not use lists ,
messages: messages.get() as CoreMessage[],
text: async function* ({ content, done }) {
if (done) {
messages.done([
...(messages.get() as CoreMessage[]),
{ role: "assistant", content },
]);

            contentStream.done();
        } else {
            contentStream.update(content);
        }

        return textComponent;
    },
    tools: {
        viewUsage: {
            description: "view current usage for youtube",
            parameters: z.object({
                type: z.enum(["youtube"]),
            }),
            generate: async function* ({ type }) {
                const toolCallId = generateId();

                messages.done([
                    ...(messages.get() as CoreMessage[]),
                    {
                        role: "assistant",
                        content: [
                            {
                                type: "tool-call",
                                toolCallId,
                                toolName: "viewUsage",
                                args: { type },
                            },
                        ],
                    },
                    {
                        role: "tool",
                        content: [
                            {
                                type: "tool-result",
                                toolName: "viewUsage",
                                toolCallId,
                                result: `The current usage for ${type} is currently displayed on the screen`,
                            },
                        ],
                    },
                ]);

                return (
                    <Message role="assistant" content={<UsageView type={type} />} />
                );
            },
        },

})

Additional context

I am using gemini-1.5-flash-latest. Hope it is not something to do with the provider or model

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

No branches or pull requests

2 participants