27 lines
659 B
TypeScript
27 lines
659 B
TypeScript
import {
|
|
CopilotRuntime,
|
|
ExperimentalEmptyAdapter,
|
|
copilotRuntimeNextJSAppRouterEndpoint,
|
|
} from "@copilotkit/runtime";
|
|
import { HttpAgent } from "@ag-ui/client";
|
|
import type { NextRequest } from "next/server";
|
|
|
|
const serviceAdapter = new ExperimentalEmptyAdapter();
|
|
|
|
const runtime = new CopilotRuntime({
|
|
agents: {
|
|
strands_agent: new HttpAgent({
|
|
url: process.env.AGENT_URL ?? "http://localhost:8000",
|
|
}),
|
|
},
|
|
});
|
|
|
|
export const POST = async (req: NextRequest) => {
|
|
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
|
|
runtime,
|
|
serviceAdapter,
|
|
endpoint: "/api/copilotkit",
|
|
});
|
|
return handleRequest(req);
|
|
};
|