Add Ollama dimension inference and add clearer errors

Instead of the user manually specifying the model dimensions it will now automatically get determined
Just like with hf.rs the word "test" gets embedded to determine the dimensions of the output
Add a dedicated error type for if the model doesn't exist (don't automatically pull it though) and set the fault of that error to be the user
This commit is contained in:
Jakob Klemm 2024-03-12 19:59:11 +01:00
parent d3004d8040
commit 88bc9556a9
No known key found for this signature in database
GPG key ID: D91BAB52F26F2A75
4 changed files with 96 additions and 36 deletions

View file

@ -1179,8 +1179,8 @@ pub fn validate_embedding_settings(
}
}
EmbedderSource::Ollama => {
// Existence & corrent dimensions of models cannot easily be checked here.
check_set(&dimensions, "dimensions", inferred_source, name)?;
// Dimensions get inferred, only model name is required
check_unset(&dimensions, "dimensions", inferred_source, name)?;
check_set(&model, "model", inferred_source, name)?;
check_unset(&api_key, "apiKey", inferred_source, name)?;
check_unset(&revision, "revision", inferred_source, name)?;