UNPKG

contaigents

Version:

Modular AI Content Ecosystem with Audio Generation

41 lines (40 loc) 1.44 kB
import { FileService } from "./fileService"; import { LLMFactory } from "./llm/LLMFactory"; export class AgentService { constructor() { this.configPath = "reviewer-config.json"; this.fileService = new FileService(); } async loadConfig() { try { const configStr = await this.fileService.readFile(this.configPath); return JSON.parse(configStr); } catch (error) { throw new Error("Failed to load LLM configuration"); } } async generateResponse(agent_name, prompt) { const config = await this.loadConfig(); console.log("Loaded config: ", config); const llm = LLMFactory.getProvider(config.llm); if (!llm) { throw new Error("No provider configured"); } let agentConfig; try { const agentConfigStr = await this.fileService.readFile(`${agent_name}-config.json`); agentConfig = JSON.parse(agentConfigStr); console.log("Agent config: ", agentConfig); if (!agentConfig) { throw new Error("Invalid agent configuration"); } } catch (error) { throw new Error("Failed to load agent configuration"); } const response = await llm.executePrompt(prompt, agentConfig.systemPrompt); console.log("Response: ", response); return response.content; } }