mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
Use constants instead of raw strings in set_*set()
This commit is contained in:
parent
58972f35cb
commit
4136630ea5
@ -1225,14 +1225,24 @@ pub fn validate_embedding_settings(
|
|||||||
};
|
};
|
||||||
match inferred_source {
|
match inferred_source {
|
||||||
EmbedderSource::OpenAi => {
|
EmbedderSource::OpenAi => {
|
||||||
check_unset(&revision, "revision", inferred_source, name)?;
|
check_unset(&revision, EmbeddingSettings::REVISION, inferred_source, name)?;
|
||||||
|
|
||||||
check_unset(&url, "url", inferred_source, name)?;
|
check_unset(&url, EmbeddingSettings::URL, inferred_source, name)?;
|
||||||
check_unset(&query, "query", inferred_source, name)?;
|
check_unset(&query, EmbeddingSettings::QUERY, inferred_source, name)?;
|
||||||
check_unset(&input_field, "inputField", inferred_source, name)?;
|
check_unset(&input_field, EmbeddingSettings::INPUT_FIELD, inferred_source, name)?;
|
||||||
check_unset(&path_to_embeddings, "pathToEmbeddings", inferred_source, name)?;
|
check_unset(
|
||||||
check_unset(&embedding_object, "embeddingObject", inferred_source, name)?;
|
&path_to_embeddings,
|
||||||
check_unset(&input_type, "inputType", inferred_source, name)?;
|
EmbeddingSettings::PATH_TO_EMBEDDINGS,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_unset(
|
||||||
|
&embedding_object,
|
||||||
|
EmbeddingSettings::EMBEDDING_OBJECT,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_unset(&input_type, EmbeddingSettings::INPUT_TYPE, inferred_source, name)?;
|
||||||
|
|
||||||
if let Setting::Set(model) = &model {
|
if let Setting::Set(model) = &model {
|
||||||
let model = crate::vector::openai::EmbeddingModel::from_name(model.as_str())
|
let model = crate::vector::openai::EmbeddingModel::from_name(model.as_str())
|
||||||
@ -1266,46 +1276,81 @@ pub fn validate_embedding_settings(
|
|||||||
}
|
}
|
||||||
EmbedderSource::Ollama => {
|
EmbedderSource::Ollama => {
|
||||||
// Dimensions get inferred, only model name is required
|
// Dimensions get inferred, only model name is required
|
||||||
check_unset(&dimensions, "dimensions", inferred_source, name)?;
|
check_unset(&dimensions, EmbeddingSettings::DIMENSIONS, inferred_source, name)?;
|
||||||
check_set(&model, "model", inferred_source, name)?;
|
check_set(&model, EmbeddingSettings::MODEL, inferred_source, name)?;
|
||||||
check_unset(&api_key, "apiKey", inferred_source, name)?;
|
check_unset(&api_key, EmbeddingSettings::API_KEY, inferred_source, name)?;
|
||||||
check_unset(&revision, "revision", inferred_source, name)?;
|
check_unset(&revision, EmbeddingSettings::REVISION, inferred_source, name)?;
|
||||||
|
|
||||||
check_unset(&query, "query", inferred_source, name)?;
|
check_unset(&query, EmbeddingSettings::QUERY, inferred_source, name)?;
|
||||||
check_unset(&input_field, "inputField", inferred_source, name)?;
|
check_unset(&input_field, EmbeddingSettings::INPUT_FIELD, inferred_source, name)?;
|
||||||
check_unset(&path_to_embeddings, "pathToEmbeddings", inferred_source, name)?;
|
check_unset(
|
||||||
check_unset(&embedding_object, "embeddingObject", inferred_source, name)?;
|
&path_to_embeddings,
|
||||||
check_unset(&input_type, "inputType", inferred_source, name)?;
|
EmbeddingSettings::PATH_TO_EMBEDDINGS,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_unset(
|
||||||
|
&embedding_object,
|
||||||
|
EmbeddingSettings::EMBEDDING_OBJECT,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_unset(&input_type, EmbeddingSettings::INPUT_TYPE, inferred_source, name)?;
|
||||||
}
|
}
|
||||||
EmbedderSource::HuggingFace => {
|
EmbedderSource::HuggingFace => {
|
||||||
check_unset(&api_key, "apiKey", inferred_source, name)?;
|
check_unset(&api_key, EmbeddingSettings::API_KEY, inferred_source, name)?;
|
||||||
check_unset(&dimensions, "dimensions", inferred_source, name)?;
|
check_unset(&dimensions, EmbeddingSettings::DIMENSIONS, inferred_source, name)?;
|
||||||
|
|
||||||
check_unset(&url, "url", inferred_source, name)?;
|
check_unset(&url, EmbeddingSettings::URL, inferred_source, name)?;
|
||||||
check_unset(&query, "query", inferred_source, name)?;
|
check_unset(&query, EmbeddingSettings::QUERY, inferred_source, name)?;
|
||||||
check_unset(&input_field, "inputField", inferred_source, name)?;
|
check_unset(&input_field, EmbeddingSettings::INPUT_FIELD, inferred_source, name)?;
|
||||||
check_unset(&path_to_embeddings, "pathToEmbeddings", inferred_source, name)?;
|
check_unset(
|
||||||
check_unset(&embedding_object, "embeddingObject", inferred_source, name)?;
|
&path_to_embeddings,
|
||||||
check_unset(&input_type, "inputType", inferred_source, name)?;
|
EmbeddingSettings::PATH_TO_EMBEDDINGS,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_unset(
|
||||||
|
&embedding_object,
|
||||||
|
EmbeddingSettings::EMBEDDING_OBJECT,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_unset(&input_type, EmbeddingSettings::INPUT_TYPE, inferred_source, name)?;
|
||||||
}
|
}
|
||||||
EmbedderSource::UserProvided => {
|
EmbedderSource::UserProvided => {
|
||||||
check_unset(&model, "model", inferred_source, name)?;
|
check_unset(&model, EmbeddingSettings::MODEL, inferred_source, name)?;
|
||||||
check_unset(&revision, "revision", inferred_source, name)?;
|
check_unset(&revision, EmbeddingSettings::REVISION, inferred_source, name)?;
|
||||||
check_unset(&api_key, "apiKey", inferred_source, name)?;
|
check_unset(&api_key, EmbeddingSettings::API_KEY, inferred_source, name)?;
|
||||||
check_unset(&document_template, "documentTemplate", inferred_source, name)?;
|
check_unset(
|
||||||
check_set(&dimensions, "dimensions", inferred_source, name)?;
|
&document_template,
|
||||||
|
EmbeddingSettings::DOCUMENT_TEMPLATE,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_set(&dimensions, EmbeddingSettings::DIMENSIONS, inferred_source, name)?;
|
||||||
|
|
||||||
check_unset(&url, "url", inferred_source, name)?;
|
check_unset(&url, EmbeddingSettings::URL, inferred_source, name)?;
|
||||||
check_unset(&query, "query", inferred_source, name)?;
|
check_unset(&query, EmbeddingSettings::QUERY, inferred_source, name)?;
|
||||||
check_unset(&input_field, "inputField", inferred_source, name)?;
|
check_unset(&input_field, EmbeddingSettings::INPUT_FIELD, inferred_source, name)?;
|
||||||
check_unset(&path_to_embeddings, "pathToEmbeddings", inferred_source, name)?;
|
check_unset(
|
||||||
check_unset(&embedding_object, "embeddingObject", inferred_source, name)?;
|
&path_to_embeddings,
|
||||||
check_unset(&input_type, "inputType", inferred_source, name)?;
|
EmbeddingSettings::PATH_TO_EMBEDDINGS,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_unset(
|
||||||
|
&embedding_object,
|
||||||
|
EmbeddingSettings::EMBEDDING_OBJECT,
|
||||||
|
inferred_source,
|
||||||
|
name,
|
||||||
|
)?;
|
||||||
|
check_unset(&input_type, EmbeddingSettings::INPUT_TYPE, inferred_source, name)?;
|
||||||
}
|
}
|
||||||
EmbedderSource::Rest => {
|
EmbedderSource::Rest => {
|
||||||
check_unset(&model, "model", inferred_source, name)?;
|
check_unset(&model, EmbeddingSettings::MODEL, inferred_source, name)?;
|
||||||
check_unset(&revision, "revision", inferred_source, name)?;
|
check_unset(&revision, EmbeddingSettings::REVISION, inferred_source, name)?;
|
||||||
check_set(&url, "url", inferred_source, name)?;
|
check_set(&url, EmbeddingSettings::URL, inferred_source, name)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(Setting::Set(EmbeddingSettings {
|
Ok(Setting::Set(EmbeddingSettings {
|
||||||
|
Loading…
Reference in New Issue
Block a user