forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute.ts
More file actions
29 lines (23 loc) · 735 Bytes
/
Copy pathroute.ts
File metadata and controls
29 lines (23 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {
CopilotRuntime,
ExperimentalEmptyAdapter,
copilotRuntimeNextJSAppRouterEndpoint,
} from "@copilotkit/runtime";
import { HttpAgent } from "@ag-ui/client";
import { NextRequest } from "next/server";
export const POST = async (req: NextRequest) => {
const AGENTIC_CHAT_AGENT_URL = process.env.AGENTIC_CHAT_AGENT_URL;
const ag2Agent = new HttpAgent({
url: AGENTIC_CHAT_AGENT_URL!,
});
const runtime = new CopilotRuntime({
agents: { ag2Agent },
});
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
runtime,
serviceAdapter: new ExperimentalEmptyAdapter(),
endpoint: "/api/copilotkit",
});
// Use the original request for handleRequest
return handleRequest(req);
};