vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid

Home Page:https://sdk.vercel.ai/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to Stream

KylerD opened this issue · comments

commented

Description

Version:

"next": "14.2.5"
"ai": "3.2.41"

Using App Router

Route (/api/chat)

  const result = await streamText({
    model: model,
    system: systemContext,
    messages: convertToCoreMessages(messages),
    tools: {
      getKnowledgeSummary: GetKnowledgeSummaryTool,
      checkKnowledge: CheckKnowledgeTool,
    },
  });

  return result.toDataStreamResponse();

Client Component:

"use client";

import { useChat } from "ai/react";
import { unstable_noStore as noStore } from "next/cache";

export function ChatWindow() {
 noStore();

 const { messages, input, setInput, handleInputChange, handleSubmit, isLoading } = useChat({
   maxToolRoundtrips: 5,
 });

This code streams successfully locally, but not once deployed to vercel. All routes and components in this application are dynamic and follow the suggestions from https://sdk.vercel.ai/docs/troubleshooting/common-issues/streaming-not-working-on-vercel

Any idea what I'm missing?

Code example

No response

Additional context

No response

I updated ai from 2.2.37 to 3.2.37 and now huggingface is not working and is giving 405 error when stream generated from HuggingfaceStream() to StreamTextResponse().

It works locally but fails when deployed on vercel.

#2485