LangChain custom Toolkit from a couple of Tools

679 Views Asked by At

How can I combine a bunch of LangChain Tools into a Toolkit in TypeScript?

import { Toolkit } from 'langchain/agents';
import { DynamicTool, Tool } from 'langchain/tools';

export class CustomToolkit extends Toolkit {
  tools: Tool[];

  constructor() {
    super();
    this.tools = [
      new DynamicTool({
        name: 'FOO',
        description:
          'call this to get the value of foo. input should be an empty string.',
        func: async () => 'baz'
      }),
      new DynamicTool({
        name: 'BAR',
        description:
          'call this to get the value of bar. input should be an empty string.',
        func: async () => 'baz1'
      })
    ];
  }
}

When I load the Toolkit into the Agent, it tells me that:Type 'CustomToolkit' is missing the following properties from type 'Tool': schema, call, lc_namespace, _call, and 11 more.ts(2740)

0

There are 0 best solutions below