langchain
Version:
Typescript bindings for langchain
33 lines • 1.48 kB
TypeScript
import { AgentMiddleware } from "../../types.js";
import { ModelChoice } from "../../modelRouter.js";
import { OpenAIDecisionsLike } from "./decisions.js";
import { z } from "zod/v4";
export interface OpenAIModelRouterMiddlewareOptions {
/** Named models and the criterion for choosing each. */
choices: Record<string, ModelChoice & {
criteria: string;
}>;
/** The routing question, e.g. "Choose the least costly model for the task." */
instructions: string;
/** An `OpenAIDecisions` instance from `@langchain/openai`. */
model: OpenAIDecisionsLike;
}
/**
* Routes each agent run to one of several models with the OpenAI Decisions API
* (beta).
*
* Classifies the latest human message once per run and stores the answer in
* `modelRoute`, then uses the chosen model for every model call in that run. With
* no human message, or a refusal, the agent's own model is used.
*/
export declare function openAIModelRouterMiddleware(options: OpenAIModelRouterMiddlewareOptions): AgentMiddleware<z.ZodObject<{
modelRoute: z.ZodOptional<z.ZodNullable<z.ZodObject<{
choice: z.ZodString;
confidence: z.ZodNumber;
probabilities: z.ZodArray<z.ZodObject<{
value: z.ZodString;
probability: z.ZodNumber;
}, z.core.$strip>>;
}, z.core.$strip>>>;
}, z.core.$strip>, undefined, unknown, readonly (import("@langchain/core/tools").ServerTool | import("@langchain/core/tools").ClientTool)[], readonly []>;
//# sourceMappingURL=modelRouter.d.ts.map