aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/tools/BaseTool.ts
blob: b57f1c8e48c562a99e3d9f8d8451acae0955f236 (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/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 citationRules: string,
        public briefSummary: string
    ) {}

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

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