import { type ChatCompletionRunner } from "./ChatCompletionRunner.js"; import { type ChatCompletionStreamingRunner } from "./ChatCompletionStreamingRunner.js"; import { JSONSchema } from "./jsonschema.js"; type PromiseOrValue = T | Promise; export type RunnableFunctionWithParse = { /** * @param args the return value from `parse`. * @param runner the runner evaluating this callback. * @returns a string to send back to OpenAI. */ function: (args: Args, runner: ChatCompletionRunner | ChatCompletionStreamingRunner) => PromiseOrValue; /** * @param input the raw args from the OpenAI function call. * @returns the parsed arguments to pass to `function` */ parse: (input: string) => PromiseOrValue; /** * The parameters the function accepts, describes as a JSON Schema object. */ parameters: JSONSchema; /** * A description of what the function does, used by the model to choose when and how to call the function. */ description: string; /** * The name of the function to be called. Will default to function.name if omitted. */ name?: string | undefined; }; export type RunnableFunctionWithoutParse = { /** * @param args the raw args from the OpenAI function call. * @returns a string to send back to OpenAI */ function: (args: string, runner: ChatCompletionRunner | ChatCompletionStreamingRunner) => PromiseOrValue; /** * The parameters the function accepts, describes as a JSON Schema object. */ parameters: JSONSchema; /** * A description of what the function does, used by the model to choose when and how to call the function. */ description: string; /** * The name of the function to be called. Will default to function.name if omitted. */ name?: string | undefined; }; export type RunnableFunction = Args extends string ? RunnableFunctionWithoutParse : Args extends object ? RunnableFunctionWithParse : never; export type RunnableToolFunction = Args extends string ? RunnableToolFunctionWithoutParse : Args extends object ? RunnableToolFunctionWithParse : never; export type RunnableToolFunctionWithoutParse = { type: 'function'; function: RunnableFunctionWithoutParse; }; export type RunnableToolFunctionWithParse = { type: 'function'; function: RunnableFunctionWithParse; }; export declare function isRunnableFunctionWithParse(fn: any): fn is RunnableFunctionWithParse; export type BaseFunctionsArgs = readonly (object | string)[]; export type RunnableFunctions = [ any[] ] extends [FunctionsArgs] ? readonly RunnableFunction[] : { [Index in keyof FunctionsArgs]: Index extends number ? RunnableFunction : FunctionsArgs[Index]; }; export type RunnableTools = [ any[] ] extends [FunctionsArgs] ? readonly RunnableToolFunction[] : { [Index in keyof FunctionsArgs]: Index extends number ? RunnableToolFunction : FunctionsArgs[Index]; }; /** * This is helper class for passing a `function` and `parse` where the `function` * argument type matches the `parse` return type. * * @deprecated - please use ParsingToolFunction instead. */ export declare class ParsingFunction { function: RunnableFunctionWithParse['function']; parse: RunnableFunctionWithParse['parse']; parameters: RunnableFunctionWithParse['parameters']; description: RunnableFunctionWithParse['description']; name?: RunnableFunctionWithParse['name']; constructor(input: RunnableFunctionWithParse); } /** * This is helper class for passing a `function` and `parse` where the `function` * argument type matches the `parse` return type. */ export declare class ParsingToolFunction { type: 'function'; function: RunnableFunctionWithParse; constructor(input: RunnableFunctionWithParse); } export {}; //# sourceMappingURL=RunnableFunction.d.ts.map