catch broken embedding models

This commit is contained in:
MaxRobinsonTheGreat 2025-02-17 16:55:36 -06:00
parent f8278c8a46
commit 7a9faca7c3
3 changed files with 13 additions and 10 deletions

View file

@ -13,13 +13,18 @@ export class SkillLibrary {
const skillDocs = getSkillDocs();
this.skill_docs = skillDocs;
if (this.embedding_model) {
const embeddingPromises = skillDocs.map((doc) => {
return (async () => {
let func_name_desc = doc.split('\n').slice(0, 2).join('');
this.skill_docs_embeddings[doc] = await this.embedding_model.embed(func_name_desc);
})();
});
await Promise.all(embeddingPromises);
try {
const embeddingPromises = skillDocs.map((doc) => {
return (async () => {
let func_name_desc = doc.split('\n').slice(0, 2).join('');
this.skill_docs_embeddings[doc] = await this.embedding_model.embed(func_name_desc);
})();
});
await Promise.all(embeddingPromises);
} catch (error) {
console.warn('Error with embedding model, using word-overlap instead.');
this.embedding_model = null;
}
}
}

View file

@ -93,8 +93,6 @@ export class Prompter {
this.embedding_model = new Mistral(embedding.model, embedding.url);
else if (embedding.api === 'huggingface')
this.embedding_model = new HuggingFace(embedding.model, embedding.url);
else if (embedding.api === 'groq')
this.embedding_model = new GroqCloudAPI(embedding.model, embedding.url);
else if (embedding.api === 'novita')
this.embedding_model = new Novita(embedding.model, embedding.url);
else {

View file

@ -38,7 +38,7 @@ export class Examples {
// Wait for all embeddings to complete
await Promise.all(embeddingPromises);
} catch (err) {
console.warn('Error with embedding model, using word overlap instead:', err);
console.warn('Error with embedding model, using word-overlap instead.');
this.model = null;
}
}