jorel
Version:
A unified wrapper for working with LLMs from multiple providers, including streams, images, documents & automatic tool use.
45 lines (44 loc) • 1.59 kB
TypeScript
import { ZodObject } from "zod";
import { LlmFunction, LlmFunctionParameters, LlmToolExecutionInputs, LlmToolExecutionOutputs, LlmToolExecutor } from "../providers";
export type LLmToolContextSegment = Record<string, object | string | number | boolean | null>;
export interface LLmToolContext {
context: LLmToolContextSegment;
secureContext: LLmToolContextSegment;
}
export interface LlmToolConfiguration {
name: string;
description: string;
requiresConfirmation?: boolean;
executor?: LlmToolExecutor | "transfer" | "subTask";
params?: Partial<LlmFunctionParameters> | ZodObject<any>;
}
/**
* A tool that can be used in generations and task executions
*/
export declare class LlmTool {
readonly name: string;
readonly description: string;
requiresConfirmation: boolean;
constructor(config: LlmToolConfiguration);
/**
* Get the type of the tool
*/
get type(): "function" | "functionDefinition" | "transfer" | "subTask";
/**
* Return the tool as a llm function (e.g., for use inside tool-use messages)
*/
get asLLmFunction(): LlmFunction;
/**
* Execute the tool
* @param args Deserialized arguments
* @param env
* @param env.context Contextual data (included in logs)
* @param env.secureContext Secure contextual data (excluded from logs)
*/
execute(args: LlmToolExecutionInputs, env?: Partial<LLmToolContext>): Promise<LlmToolExecutionOutputs>;
/**
* Internal helper to validate and normalize parameters
* @param params
*/
private validateParams;
}