diff options
| author | bobzel <zzzman@gmail.com> | 2025-03-10 16:13:04 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2025-03-10 16:13:04 -0400 |
| commit | b7989dded8bb001876de6cbca59bf77935f0daf7 (patch) | |
| tree | 0dba0665674db7bb84770833df0a4100d0520701 /src/client/views/nodes/chatbot/tools/BaseTool.ts | |
| parent | 4979415d4604d280e81a162bf9a9d39c731d3738 (diff) | |
| parent | 5bf944035c0ba94ad15245416f51ca0329a51bde (diff) | |
Merge branch 'master' into alyssa-starter
Diffstat (limited to 'src/client/views/nodes/chatbot/tools/BaseTool.ts')
| -rw-r--r-- | src/client/views/nodes/chatbot/tools/BaseTool.ts | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/client/views/nodes/chatbot/tools/BaseTool.ts b/src/client/views/nodes/chatbot/tools/BaseTool.ts index 58cd514d9..8800e2238 100644 --- a/src/client/views/nodes/chatbot/tools/BaseTool.ts +++ b/src/client/views/nodes/chatbot/tools/BaseTool.ts @@ -1,5 +1,5 @@ import { Observation } from '../types/types'; -import { Parameter, Tool, ParametersType } from './ToolTypes'; +import { Parameter, ParametersType, ToolInfo } from '../types/tool_types'; /** * @file BaseTool.ts @@ -14,7 +14,7 @@ import { Parameter, Tool, ParametersType } from './ToolTypes'; * It is generic over a type parameter `P`, which extends `ReadonlyArray<Parameter>`. * This means `P` is a readonly array of `Parameter` objects that cannot be modified (immutable). */ -export abstract class BaseTool<P extends ReadonlyArray<Parameter>> implements Tool<P> { +export abstract class BaseTool<P extends ReadonlyArray<Parameter>> { // The name of the tool (e.g., "calculate", "searchTool") name: string; // A description of the tool's functionality @@ -23,8 +23,6 @@ export abstract class BaseTool<P extends ReadonlyArray<Parameter>> implements To parameterRules: P; // Guidelines for how to handle citations when using the tool citationRules: string; - // A brief summary of the tool's purpose - briefSummary: string; /** * Constructs a new `BaseTool` instance. @@ -32,14 +30,12 @@ export abstract class BaseTool<P extends ReadonlyArray<Parameter>> implements To * @param description - A detailed description of what the tool does. * @param parameterRules - A readonly array of parameter definitions (`ReadonlyArray<Parameter>`). * @param citationRules - Rules or guidelines for citations. - * @param briefSummary - A short summary of the tool. */ - constructor(name: string, description: string, parameterRules: P, citationRules: string, briefSummary: string) { - this.name = name; - this.description = description; - this.parameterRules = parameterRules; - this.citationRules = citationRules; - this.briefSummary = briefSummary; + constructor(toolInfo: ToolInfo<P>) { + this.name = toolInfo.name; + this.description = toolInfo.description; + this.parameterRules = toolInfo.parameterRules; + this.citationRules = toolInfo.citationRules; } /** @@ -51,6 +47,18 @@ export abstract class BaseTool<P extends ReadonlyArray<Parameter>> implements To abstract execute(args: ParametersType<P>): Promise<Observation[]>; /** + * This is a hacky way for a tool to ignore required parameter errors. + * Used by crateDocTool to allow processing of simple arrays of Documents + * where the array doesn't conform to a normal Doc structure. + * @param inputParam + * @returns + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + inputValidator(inputParam: ParametersType<readonly Parameter[]>) { + return false; + } + + /** * Generates an action rule object that describes the tool's usage. * This is useful for dynamically generating documentation or for tools that need to expose their parameters at runtime. * @returns An object containing the tool's name, description, and parameter definitions. @@ -59,6 +67,7 @@ export abstract class BaseTool<P extends ReadonlyArray<Parameter>> implements To return { tool: this.name, description: this.description, + citationRules: this.citationRules, parameters: this.parameterRules.reduce( (acc, param) => { // Build an object for each parameter without the 'name' property, since it's used as the key |
