Skip to content
Snippets Groups Projects
Commit 5463d3bf authored by Marcus Schiesser's avatar Marcus Schiesser
Browse files

fix: nextjs type checks

parent 7225e916
No related branches found
No related tags found
No related merge requests found
import { initObservability } from "@/app/observability";
import { StreamingTextResponse } from "ai";
import { Message, StreamingTextResponse } from "ai";
import { ChatMessage, MessageContent } from "llamaindex";
import { NextRequest, NextResponse } from "next/server";
import { createChatEngine } from "./engine/chat";
......@@ -34,7 +34,7 @@ const convertMessageContent = (
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { messages, data }: { messages: ChatMessage[]; data: any } = body;
const { messages, data }: { messages: Message[]; data: any } = body;
const userMessage = messages.pop();
if (!messages || !userMessage || userMessage.role !== "user") {
return NextResponse.json(
......@@ -57,7 +57,7 @@ export async function POST(request: NextRequest) {
// Calling LlamaIndex's ChatEngine to get a streamed response
const response = await chatEngine.chat({
message: userMessageContent,
chatHistory: messages,
chatHistory: messages as ChatMessage[],
stream: true,
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment