UNPKG

@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;" />

33 lines (31 loc) 995 B
import "reflect-metadata"; import { parseSSEResponse } from "./middleware-sse-parser.mjs"; import { logger } from "@copilotkit/shared"; //#region src/v2/runtime/core/middleware.ts async function callBeforeRequestMiddleware({ runtime, request, path }) { const mw = runtime.beforeRequestMiddleware; if (!mw) return; if (typeof mw === "function") return mw({ runtime, request, path }); logger.warn({ mw }, "Unsupported beforeRequestMiddleware value – skipped"); } async function callAfterRequestMiddleware({ runtime, response, path }) { const mw = runtime.afterRequestMiddleware; if (!mw) return; const { messages, threadId, runId } = await parseSSEResponse(response); if (typeof mw === "function") return mw({ runtime, response, path, messages, threadId, runId }); logger.warn({ mw }, "Unsupported afterRequestMiddleware value – skipped"); } //#endregion export { callAfterRequestMiddleware, callBeforeRequestMiddleware }; //# sourceMappingURL=middleware.mjs.map