Skip to content

Commit

Permalink
refactor: tool enum
Browse files Browse the repository at this point in the history
  • Loading branch information
thucpn committed Mar 22, 2024
1 parent 6e2fa20 commit 526de51
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/core/src/tools/ToolFactory.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { BaseTool } from "../types.js";
import { WikipediaTool } from "./WikipediaTool.js";

enum ExternalTool {
enum Tools {
Wikipedia = "wikipedia.WikipediaToolSpec",
}

type ToolConfig = { [key in ExternalTool]: Record<string, any> };
type ToolConfig = { [key in Tools]: Record<string, any> };

export class ToolFactory {
private static async createTool(
key: ExternalTool,
key: Tools,
options: Record<string, any>,
): Promise<BaseTool> {
if (key === ExternalTool.Wikipedia) {
if (key === Tools.Wikipedia) {
const tool = new WikipediaTool();
return tool;
}
Expand All @@ -25,7 +25,7 @@ export class ToolFactory {
public static async createTools(config: ToolConfig): Promise<BaseTool[]> {
const tools: BaseTool[] = [];
for (const [key, value] of Object.entries(config as ToolConfig)) {
const tool = await ToolFactory.createTool(key as ExternalTool, value);
const tool = await ToolFactory.createTool(key as Tools, value);
tools.push(tool);
}
return tools;
Expand Down

0 comments on commit 526de51

Please sign in to comment.