aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/ChatBox/tools/BaseTool.ts
blob: 2e22676532d7678fb72eea7d7164b325b645e0bc (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 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,
            },
        };
    }
}