aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ChatBox/tools/BaseTool.ts
blob: 903161bd53408d32d613a2798a4693bd344e58cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Tool } from '../types';

export abstract class BaseTool<T extends Record<string, any> = Record<string, any>> implements Tool<T> {
    constructor(
        public name: string,
        public description: string,
        public parameters: Record<string, any>,
        public useRules: string,
        public briefSummary: string
    ) {}

    abstract execute(args: T): Promise<any>;

    getActionRule(): Record<string, any> {
        return {
            [this.name]: {
                name: this.name,
                useRules: this.useRules,
                description: this.description,
                parameters: this.parameters,
            },
        };
    }
}