🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
import { type NextApiRequest, type NextApiResponse } from "next";
import { type ZodType } from "zod";
import {
createAuthedProjectAPIRoute,
type AuthedProjectAPIRouteConfig,
} from "@/src/features/public-api/server/createAuthedProjectAPIRoute";
import {
withMiddlewares,
type HttpMethod,
} from "@/src/features/public-api/server/withMiddlewares";
import { structuredPublicApiErrorContract } from "./structuredPublicApiErrorContract";
type UnstablePublicApiRouteConfig<
TQuery extends ZodType<any>,
TBody extends ZodType<any>,
TResponse extends ZodType<any>,
> = Omit<
AuthedProjectAPIRouteConfig<TQuery, TBody, TResponse>,
"errorContract"
>;
type UnstablePublicApiHandlers = {
[Method in HttpMethod]?: (
req: NextApiRequest,
res: NextApiResponse,
) => Promise<void>;
};
export const createUnstablePublicApiRoute = <
TQuery extends ZodType<any>,
TBody extends ZodType<any>,
TResponse extends ZodType<any>,
>(
routeConfig: UnstablePublicApiRouteConfig<TQuery, TBody, TResponse>,
) =>
createAuthedProjectAPIRoute({
...routeConfig,
errorContract: structuredPublicApiErrorContract,
});
export const withUnstablePublicApiMiddlewares = (
handlers: UnstablePublicApiHandlers,
) =>
withMiddlewares(handlers, {
errorContract: structuredPublicApiErrorContract,
});