diff --git a/templates/types/streaming/express/src/controllers/chat.controller.ts b/templates/types/streaming/express/src/controllers/chat.controller.ts index 9d1eb0c6..1d9cd56a 100644 --- a/templates/types/streaming/express/src/controllers/chat.controller.ts +++ b/templates/types/streaming/express/src/controllers/chat.controller.ts @@ -1,7 +1,7 @@ import { streamToResponse } from "ai"; import { Request, Response } from "express"; import { ChatMessage, MessageContent, OpenAI } from "llamaindex"; -import { createChatEngine } from "./engine"; +import { createChatEngine } from "./engine/chat"; import { LlamaIndexStream } from "./llamaindex-stream"; const convertMessageContent = ( diff --git a/templates/types/streaming/express/src/controllers/llamaindex-stream.ts b/templates/types/streaming/express/src/controllers/llamaindex-stream.ts index 6ddd8eae..a57934c2 100644 --- a/templates/types/streaming/express/src/controllers/llamaindex-stream.ts +++ b/templates/types/streaming/express/src/controllers/llamaindex-stream.ts @@ -6,7 +6,7 @@ import { trimStartOfStreamHelper, type AIStreamCallbacksAndOptions, } from "ai"; -import { Response } from "llamaindex"; +import { Response, StreamingAgentChatResponse } from "llamaindex"; type ParserOptions = { image_url?: string; @@ -52,13 +52,14 @@ function createParser( } export function LlamaIndexStream( - res: AsyncIterable, + response: StreamingAgentChatResponse | AsyncIterable, opts?: { callbacks?: AIStreamCallbacksAndOptions; parserOptions?: ParserOptions; }, ): { stream: ReadableStream; data: experimental_StreamData } { const data = new experimental_StreamData(); + const res = response instanceof StreamingAgentChatResponse ? response.response : response; return { stream: createParser(res, data, opts?.parserOptions) .pipeThrough(createCallbacksTransformer(opts?.callbacks))