llm-to-agent/src/tools/registry.ts
2026-06-05 17:16:33 +08:00

24 lines
566 B
TypeScript

import { weatherTool } from './weather.js';
import { calculatorTool } from './calculator.js';
import { Tool } from '../types/index.js';
const tools: Tool[] = [weatherTool, calculatorTool];
export function getTools(): Tool[] {
return tools;
}
export function getOpenAITools() {
return tools.map((t) => ({
type: 'function' as const,
function: {
name: t.name,
description: t.description,
parameters: t.parameters,
},
}));
}
export function findTool(name: string): Tool | undefined {
return tools.find((t) => t.name === name);
}