mirror of
https://github.com/run-llama/create-llama.git
synced 2026-07-15 05:08:15 -04:00
Results are not streaming in. #124
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @izakfilmalter on GitHub (Feb 26, 2025).
Originally assigned to: @thucpn on GitHub.
Looks like
StreamDatais deprecated in theaisdk now. It's causing the results to no longer stream in, but appear once fully generated.@marcusschiesser commented on GitHub (Feb 27, 2025):
@izakfilmalter Thanks for reporting, we're working on updating our streaming code
@marcusschiesser commented on GitHub (Mar 2, 2025):
@izakfilmalter this is fixed in LlamaIndex 0.9.5 which is automatically pulled by the current create-llama code
@Gllidan commented on GitHub (Mar 20, 2025):
@marcusschiesser
Hello, I have upgraded to "ai": "4.0.3", "llamaindex": "0.9.11", but I still cannot support streaming output. Do I need to make adjustments to my code? Please help me with this.
`
import { initObservability } from "@/app/observability";
import { LlamaIndexAdapter, Message, StreamData } from "ai";
import { ChatMessage, Settings } from "llamaindex";
import { NextRequest, NextResponse } from "next/server";
import { createChatEngine } from "./engine/chat";
import { initSettings } from "./engine/settings";
import {
isValidMessages,
retrieveDocumentIds,
retrieveMessageContent,
} from "./llamaindex/streaming/annotations";
import { createCallbackManager } from "./llamaindex/streaming/events";
import { generateNextQuestions } from "./llamaindex/streaming/suggestion";
initObservability();
initSettings();
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function POST(request: NextRequest) {
// Init Vercel AI StreamData and timeout
const vercelStreamData = new StreamData();
try {
const body = await request.json();
const { messages, data }: { messages: Message[]; data?: any } = body;
if (!isValidMessages(messages)) {
return NextResponse.json(
{
error:
"messages are required in the request body and the last message must be from the user",
},
{ status: 400 },
);
}
} catch (error) {
console.error("[LlamaIndex]", error);
return NextResponse.json(
{
detail: (error as Error).message,
},
{
status: 500,
},
);
}
}
`