Next.js Discord

Discord Forum

Vercel AI SDK + FastAPI + Langchain Agents

Unanswered
Sloth bear posted this in #help-forum
Open in Discord
Sloth bearOP
Hi,

I've an agent setup in the python server that is built using FastAPI and I'm streaming a response back to my Next.js API route using the following axios call:

const res = await axios.post(
    "http://127.0.0.1:8000/hydra_response",
    {
      messages: messages,
    },
    {
      responseType: "stream",
    }
  );


I can read the stream, but I'm not sure how should I use the AIStream module in this case to send a return new StreamingTextResponse(stream); from /api/chat/route.ts route.

Can anyone give any pointers on how to make this happen?

0 Replies