Notes/src/services/llm/tools/tool_initializer.ts

48 lines
1.7 KiB
TypeScript
Raw Normal View History

/**
* Tool Initializer
2025-04-07 22:46:54 +00:00
*
* This module initializes all available tools for the LLM to use.
*/
import toolRegistry from './tool_registry.js';
import { SearchNotesTool } from './search_notes_tool.js';
import { ReadNoteTool } from './read_note_tool.js';
2025-04-07 22:46:54 +00:00
import { NoteCreationTool } from './note_creation_tool.js';
import { NoteUpdateTool } from './note_update_tool.js';
import { ContentExtractionTool } from './content_extraction_tool.js';
import { RelationshipTool } from './relationship_tool.js';
import log from '../../log.js';
/**
* Initialize all tools for the LLM
*/
export async function initializeTools(): Promise<void> {
try {
log.info('Initializing LLM tools...');
2025-04-07 22:46:54 +00:00
// Register basic note search and read tools
toolRegistry.registerTool(new SearchNotesTool());
toolRegistry.registerTool(new ReadNoteTool());
2025-04-07 22:46:54 +00:00
// Register note creation and manipulation tools
toolRegistry.registerTool(new NoteCreationTool());
toolRegistry.registerTool(new NoteUpdateTool());
// Register content analysis tools
toolRegistry.registerTool(new ContentExtractionTool());
toolRegistry.registerTool(new RelationshipTool());
// Log registered tools
const toolCount = toolRegistry.getAllTools().length;
2025-04-07 22:46:54 +00:00
const toolNames = toolRegistry.getAllTools().map(tool => tool.definition.function.name).join(', ');
log.info(`Successfully registered ${toolCount} LLM tools: ${toolNames}`);
} catch (error: any) {
log.error(`Error initializing LLM tools: ${error.message || String(error)}`);
// Don't throw, just log the error to prevent breaking the pipeline
}
}
export default {
initializeTools
};