mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
68f9b8ad45
Example projects demonstrating the new fetch-based runtime adapters across six server frameworks/runtimes.
25 lines
595 B
TypeScript
25 lines
595 B
TypeScript
import express from "express";
|
|
import { CopilotRuntime, BuiltInAgent } from "@copilotkit/runtime/v2";
|
|
import { createCopilotExpressHandler } from "@copilotkit/runtime/v2/express";
|
|
|
|
const runtime = new CopilotRuntime({
|
|
agents: {
|
|
default: new BuiltInAgent({ model: "openai/gpt-5-mini" }),
|
|
},
|
|
});
|
|
|
|
const app = express();
|
|
app.use(
|
|
createCopilotExpressHandler({
|
|
runtime,
|
|
basePath: "/api/copilotkit",
|
|
}),
|
|
);
|
|
|
|
const port = Number(process.env.PORT ?? 4002);
|
|
app.listen(port, () => {
|
|
console.log(
|
|
`Express runtime listening on http://localhost:${port}/api/copilotkit`,
|
|
);
|
|
});
|