@jackhua/mini-langchain
Version:
A lightweight TypeScript implementation of LangChain with cost optimization features
71 lines • 1.5 kB
TypeScript
/**
* Base tool interface and implementations
*/
/**
* Tool interface that agents can use
*/
export interface Tool {
name: string;
description: string;
/**
* Execute the tool with given input
*/
execute(input: string): Promise<string>;
/**
* Optional schema for structured input
*/
inputSchema?: Record<string, any>;
}
/**
* Base class for tools
*/
export declare abstract class BaseTool implements Tool {
abstract name: string;
abstract description: string;
abstract execute(input: string): Promise<string>;
/**
* Format the tool for prompt inclusion
*/
formatForPrompt(): string;
}
/**
* Tool execution result
*/
export interface ToolExecutionResult {
tool: string;
input: string;
output: string;
error?: string;
executionTime?: number;
}
/**
* Tool manager for agent use
*/
export declare class ToolManager {
private tools;
/**
* Register a tool
*/
registerTool(tool: Tool): void;
/**
* Register multiple tools
*/
registerTools(tools: Tool[]): void;
/**
* Get a tool by name
*/
getTool(name: string): Tool | undefined;
/**
* Get all available tools
*/
getAllTools(): Tool[];
/**
* Execute a tool
*/
executeTool(toolName: string, input: string): Promise<ToolExecutionResult>;
/**
* Format all tools for prompt
*/
formatToolsForPrompt(): string;
}
//# sourceMappingURL=base.d.ts.map