Notes/src/services/llm/tools/tool_interfaces.ts
2025-04-14 19:13:53 +00:00

63 lines
1.2 KiB
TypeScript

/**
* Tool Interfaces
*
* This file defines the interfaces for the LLM tool calling system.
*/
/**
* Interface for a tool definition to be sent to the LLM
*/
export interface Tool {
type: 'function';
function: {
name: string;
description: string;
parameters: {
type: 'object';
properties: Record<string, ToolParameter>;
required: string[];
};
};
}
/**
* Interface for a tool parameter
*/
export interface ToolParameter {
type: string;
description: string;
enum?: string[];
items?: ToolParameter | {
type: string;
properties?: Record<string, ToolParameter>;
required?: string[];
};
}
/**
* Interface for a tool call from the LLM
*/
export interface ToolCall {
id?: string;
type?: string;
function: {
name: string;
arguments: Record<string, any> | string;
};
}
/**
* Interface for a tool handler that executes a tool
*/
export interface ToolHandler {
/**
* Tool definition to be sent to the LLM
*/
definition: Tool;
/**
* Execute the tool with the given arguments
*/
execute(args: Record<string, any>): Promise<string | object>;
}