-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
index.ts
29 lines (26 loc) · 1.1 KB
/
index.ts
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
import { Tool, ToolInterface } from "@langchain/core/tools";
import { Toolkit } from "../base.js";
import { ConneryService } from "../../../tools/connery.js";
/**
* ConneryToolkit provides access to all the available actions from the Connery Runner.
* @extends Toolkit
*/
export class ConneryToolkit extends Toolkit {
tools: ToolInterface[];
/**
* Creates a ConneryToolkit instance based on the provided ConneryService instance.
* It populates the tools property of the ConneryToolkit instance with the list of
* available tools from the Connery Runner.
* @param conneryService The ConneryService instance.
* @returns A Promise that resolves to a ConneryToolkit instance.
*/
static async createInstance(
conneryService: ConneryService
): Promise<ConneryToolkit> {
const toolkit = new ConneryToolkit();
toolkit.tools = [];
const actions = await conneryService.listActions();
toolkit.tools.push(...(actions as unknown as Tool[])); // This is a hack to make TypeScript happy, as TypeScript doesn't know that ConneryAction (StructuredTool) extends Tool.
return toolkit;
}
}