adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
69 lines (68 loc) • 2.04 kB
TypeScript
import { BaseTool, BaseToolOptions } from '../BaseTool';
import { ToolContext } from '../ToolContext';
/**
* Options for creating a retrieval tool
*/
export interface RetrievalToolOptions extends BaseToolOptions {
/**
* Maximum number of results to return (default: 5)
*/
maxResults?: number;
}
/**
* Base class for retrieval tools that search for information
*/
export declare abstract class BaseRetrievalTool extends BaseTool {
/**
* Maximum number of results to return
*/
protected maxResults: number;
/**
* Create a new retrieval tool
*
* @param options Options for the retrieval tool
*/
constructor(options: RetrievalToolOptions);
/**
* Get the function declaration for retrieval tools
*
* @returns The function declaration
*/
protected _getDeclaration(): {
name: string;
description: string;
parameters: {
type: string;
properties: {
query: {
type: string;
description: string;
};
maxResults: {
type: string;
description: string;
};
};
required: string[];
};
};
/**
* Execute the retrieval tool
*
* @param params The parameters for the tool execution
* @param context The context for the tool execution
* @returns The result of the tool execution
*/
execute(params: Record<string, any>, context: ToolContext): Promise<any>;
/**
* Retrieve information based on the query
*
* This method must be implemented by subclasses.
*
* @param query The query to retrieve information for
* @param maxResults Maximum number of results to return
* @param context The context for the retrieval
* @returns The retrieved information
*/
protected abstract retrieve(query: string, maxResults: number, context: ToolContext): Promise<any>;
}