@copilotkit/runtime
Version:
<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />
44 lines (42 loc) • 1.36 kB
JavaScript
import "reflect-metadata";
import { createCopilotExpressHandler } from "./express.mjs";
//#region src/v2/runtime/endpoints/express-single.ts
/**
* Creates an Express router that serves the CopilotKit runtime as a single
* POST endpoint. Clients send a JSON envelope with `{ method, params, body }`
* to dispatch to the appropriate handler.
*
* This is a convenience wrapper around {@link createCopilotExpressHandler}
* with `mode: "single-route"` and `cors: true`.
*
* @example
* ```typescript
* import express from "express";
* import { CopilotRuntime } from "@copilotkit/runtime/v2";
* import { createCopilotEndpointSingleRouteExpress } from "@copilotkit/runtime/v2/express";
*
* const runtime = new CopilotRuntime({
* agents: { default: new BuiltInAgent({ model: "openai/gpt-4o-mini" }) },
* });
*
* const app = express();
* app.use(createCopilotEndpointSingleRouteExpress({
* runtime,
* basePath: "/api/copilotkit",
* }));
* app.listen(4000);
* ```
*/
/** @deprecated Use `createCopilotExpressHandler` with `mode: "single-route"` instead. */
function createCopilotEndpointSingleRouteExpress({ runtime, basePath, hooks }) {
return createCopilotExpressHandler({
runtime,
basePath,
mode: "single-route",
cors: true,
hooks
});
}
//#endregion
export { createCopilotEndpointSingleRouteExpress };
//# sourceMappingURL=express-single.mjs.map