1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/**
* @file BaseTool.ts
* @description This file defines the abstract BaseTool class, which serves as a blueprint
* for tool implementations in the AI assistant system. Each tool has a name, description,
* parameters, and citation rules. The BaseTool class provides a structure for executing actions
* and retrieving action rules for use within the assistant's workflow.
*/
import { Tool } from '../types/types';
export abstract class BaseTool<T extends Record<string, unknown> = Record<string, unknown>> implements Tool<T> {
constructor(
public name: string,
public description: string,
public parameters: Record<string, unknown>,
public citationRules: string,
public briefSummary: string
) {}
abstract execute(args: T): Promise<unknown>;
getActionRule(): Record<string, unknown> {
return {
[this.name]: {
name: this.name,
citationRules: this.citationRules,
description: this.description,
parameters: this.parameters,
},
};
}
}
|