catch embedding model init error

This commit is contained in:
MaxRobinsonTheGreat 2024-11-07 11:35:09 -06:00
parent 5fb52e6d73
commit ae341bfdf4
2 changed files with 20 additions and 13 deletions

View file

@ -77,7 +77,7 @@ export class Agent {
}, 30000); }, 30000);
this.bot.once('error', (error) => { this.bot.once('error', (error) => {
clearTimeout(timeout); clearTimeout(spawnTimeout);
console.error('Bot encountered error:', error); console.error('Bot encountered error:', error);
reject(error); reject(error);
}); });

View file

@ -84,6 +84,7 @@ export class Prompter {
console.log('Using embedding settings:', embedding); console.log('Using embedding settings:', embedding);
try {
if (embedding.api === 'google') if (embedding.api === 'google')
this.embedding_model = new Gemini(embedding.model, embedding.url); this.embedding_model = new Gemini(embedding.model, embedding.url);
else if (embedding.api === 'openai') else if (embedding.api === 'openai')
@ -98,6 +99,12 @@ export class Prompter {
this.embedding_model = null; this.embedding_model = null;
console.log('Unknown embedding: ', embedding ? embedding.api : '[NOT SPECIFIED]', '. Using word overlap.'); 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;
}
mkdirSync(`./bots/${name}`, { recursive: true }); mkdirSync(`./bots/${name}`, { recursive: true });
writeFileSync(`./bots/${name}/last_profile.json`, JSON.stringify(this.profile, null, 4), (err) => { writeFileSync(`./bots/${name}/last_profile.json`, JSON.stringify(this.profile, null, 4), (err) => {