diff --git a/src/agent/agent.js b/src/agent/agent.js index 35ba7fe..d7f36d6 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -77,7 +77,7 @@ export class Agent { }, 30000); this.bot.once('error', (error) => { - clearTimeout(timeout); + clearTimeout(spawnTimeout); console.error('Bot encountered error:', error); reject(error); }); diff --git a/src/agent/prompter.js b/src/agent/prompter.js index 68af6d3..107019a 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -84,19 +84,26 @@ export class Prompter { console.log('Using embedding settings:', embedding); - if (embedding.api === 'google') - this.embedding_model = new Gemini(embedding.model, embedding.url); - else if (embedding.api === 'openai') - this.embedding_model = new GPT(embedding.model, embedding.url); - else if (embedding.api === 'replicate') - this.embedding_model = new ReplicateAPI(embedding.model, embedding.url); - else if (embedding.api === 'ollama') - this.embedding_model = new Local(embedding.model, embedding.url); - else if (embedding.api === 'qwen') - this.embedding_model = new Qwen(embedding.model, embedding.url); - else { + try { + if (embedding.api === 'google') + this.embedding_model = new Gemini(embedding.model, embedding.url); + else if (embedding.api === 'openai') + this.embedding_model = new GPT(embedding.model, embedding.url); + else if (embedding.api === 'replicate') + this.embedding_model = new ReplicateAPI(embedding.model, embedding.url); + else if (embedding.api === 'ollama') + this.embedding_model = new Local(embedding.model, embedding.url); + else if (embedding.api === 'qwen') + this.embedding_model = new Qwen(embedding.model, embedding.url); + else { + this.embedding_model = null; + console.log('Unknown embedding: ', embedding ? embedding.api : '[NOT SPECIFIED]', '. Using word overlap.'); + } + } + catch (err) { + console.log('Warning: Failed to initialize embedding model:', err.message); + console.log('Continuing anyway, using word overlap instead.'); this.embedding_model = null; - console.log('Unknown embedding: ', embedding ? embedding.api : '[NOT SPECIFIED]', '. Using word overlap.'); } mkdirSync(`./bots/${name}`, { recursive: true });