diff --git a/apps/docs/app/api/entelligence/route.ts b/apps/docs/app/api/entelligence/route.ts index abf3135e0..5248a9e44 100644 --- a/apps/docs/app/api/entelligence/route.ts +++ b/apps/docs/app/api/entelligence/route.ts @@ -7,16 +7,24 @@ export const POST = async (req: Request) => { const { content: question, role } = messages.pop()!; if (role !== "user" || !question) throw new Error("No question provided"); + const history = messages.reduce( + (pairs, msg, i, arr) => { + const next = arr[i + 1]; + if (msg.role === "user" && next?.role === "assistant") { + pairs.push([msg.content, next.content]); + } + return pairs; + }, + [] as [string, string][], + ); + return fetch(process.env["ENTELLIGENCE_API_URL"]!, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ - history: messages.map((m) => ({ - role: m.role, - content: m.content, - })), + history, question, vectorDBUrl: "Yonom&assistant-ui", advancedAgent: false,