mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 22:35:35 +02:00
catch broken embedding models
This commit is contained in:
parent
f8278c8a46
commit
7a9faca7c3
3 changed files with 13 additions and 10 deletions
|
@ -13,6 +13,7 @@ export class SkillLibrary {
|
||||||
const skillDocs = getSkillDocs();
|
const skillDocs = getSkillDocs();
|
||||||
this.skill_docs = skillDocs;
|
this.skill_docs = skillDocs;
|
||||||
if (this.embedding_model) {
|
if (this.embedding_model) {
|
||||||
|
try {
|
||||||
const embeddingPromises = skillDocs.map((doc) => {
|
const embeddingPromises = skillDocs.map((doc) => {
|
||||||
return (async () => {
|
return (async () => {
|
||||||
let func_name_desc = doc.split('\n').slice(0, 2).join('');
|
let func_name_desc = doc.split('\n').slice(0, 2).join('');
|
||||||
|
@ -20,6 +21,10 @@ export class SkillLibrary {
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
await Promise.all(embeddingPromises);
|
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);
|
this.embedding_model = new Mistral(embedding.model, embedding.url);
|
||||||
else if (embedding.api === 'huggingface')
|
else if (embedding.api === 'huggingface')
|
||||||
this.embedding_model = new HuggingFace(embedding.model, embedding.url);
|
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')
|
else if (embedding.api === 'novita')
|
||||||
this.embedding_model = new Novita(embedding.model, embedding.url);
|
this.embedding_model = new Novita(embedding.model, embedding.url);
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -38,7 +38,7 @@ export class Examples {
|
||||||
// Wait for all embeddings to complete
|
// Wait for all embeddings to complete
|
||||||
await Promise.all(embeddingPromises);
|
await Promise.all(embeddingPromises);
|
||||||
} catch (err) {
|
} 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;
|
this.model = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue