mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-03-28 14:56:24 +01:00
catch broken embedding models
This commit is contained in:
parent
f8278c8a46
commit
7a9faca7c3
3 changed files with 13 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue