mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 12:54:26 +01:00
Introduce Setting::some_or_not_set
This commit is contained in:
parent
7a347966da
commit
553440632e
@ -67,6 +67,13 @@ impl<T> Setting<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn some_or_not_set(option: Option<T>) -> Self {
|
||||
match option {
|
||||
Some(value) => Setting::Set(value),
|
||||
None => Setting::NotSet,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn as_ref(&self) -> Setting<&T> {
|
||||
match *self {
|
||||
Self::Set(ref value) => Setting::Set(value),
|
||||
|
@ -467,7 +467,7 @@ impl From<EmbeddingConfig> for EmbeddingSettings {
|
||||
}) => Self {
|
||||
source: Setting::Set(EmbedderSource::HuggingFace),
|
||||
model: Setting::Set(model),
|
||||
revision: revision.map(Setting::Set).unwrap_or_default(),
|
||||
revision: Setting::some_or_not_set(revision),
|
||||
api_key: Setting::NotSet,
|
||||
dimensions: Setting::NotSet,
|
||||
document_template: Setting::Set(prompt.template),
|
||||
@ -475,7 +475,7 @@ impl From<EmbeddingConfig> for EmbeddingSettings {
|
||||
request: Setting::NotSet,
|
||||
response: Setting::NotSet,
|
||||
headers: Setting::NotSet,
|
||||
distribution: distribution.map(Setting::Set).unwrap_or_default(),
|
||||
distribution: Setting::some_or_not_set(distribution),
|
||||
},
|
||||
super::EmbedderOptions::OpenAi(super::openai::EmbedderOptions {
|
||||
url,
|
||||
@ -487,14 +487,14 @@ impl From<EmbeddingConfig> for EmbeddingSettings {
|
||||
source: Setting::Set(EmbedderSource::OpenAi),
|
||||
model: Setting::Set(embedding_model.name().to_owned()),
|
||||
revision: Setting::NotSet,
|
||||
api_key: api_key.map(Setting::Set).unwrap_or_default(),
|
||||
dimensions: dimensions.map(Setting::Set).unwrap_or_default(),
|
||||
api_key: Setting::some_or_not_set(api_key),
|
||||
dimensions: Setting::some_or_not_set(dimensions),
|
||||
document_template: Setting::Set(prompt.template),
|
||||
url: url.map(Setting::Set).unwrap_or_default(),
|
||||
url: Setting::some_or_not_set(url),
|
||||
request: Setting::NotSet,
|
||||
response: Setting::NotSet,
|
||||
headers: Setting::NotSet,
|
||||
distribution: distribution.map(Setting::Set).unwrap_or_default(),
|
||||
distribution: Setting::some_or_not_set(distribution),
|
||||
},
|
||||
super::EmbedderOptions::Ollama(super::ollama::EmbedderOptions {
|
||||
embedding_model,
|
||||
@ -506,14 +506,14 @@ impl From<EmbeddingConfig> for EmbeddingSettings {
|
||||
source: Setting::Set(EmbedderSource::Ollama),
|
||||
model: Setting::Set(embedding_model),
|
||||
revision: Setting::NotSet,
|
||||
api_key: api_key.map(Setting::Set).unwrap_or_default(),
|
||||
dimensions: dimensions.map(Setting::Set).unwrap_or_default(),
|
||||
api_key: Setting::some_or_not_set(api_key),
|
||||
dimensions: Setting::some_or_not_set(dimensions),
|
||||
document_template: Setting::Set(prompt.template),
|
||||
url: url.map(Setting::Set).unwrap_or_default(),
|
||||
url: Setting::some_or_not_set(url),
|
||||
request: Setting::NotSet,
|
||||
response: Setting::NotSet,
|
||||
headers: Setting::NotSet,
|
||||
distribution: distribution.map(Setting::Set).unwrap_or_default(),
|
||||
distribution: Setting::some_or_not_set(distribution),
|
||||
},
|
||||
super::EmbedderOptions::UserProvided(super::manual::EmbedderOptions {
|
||||
dimensions,
|
||||
@ -529,7 +529,7 @@ impl From<EmbeddingConfig> for EmbeddingSettings {
|
||||
request: Setting::NotSet,
|
||||
response: Setting::NotSet,
|
||||
headers: Setting::NotSet,
|
||||
distribution: distribution.map(Setting::Set).unwrap_or_default(),
|
||||
distribution: Setting::some_or_not_set(distribution),
|
||||
},
|
||||
super::EmbedderOptions::Rest(super::rest::EmbedderOptions {
|
||||
api_key,
|
||||
@ -543,13 +543,13 @@ impl From<EmbeddingConfig> for EmbeddingSettings {
|
||||
source: Setting::Set(EmbedderSource::Rest),
|
||||
model: Setting::NotSet,
|
||||
revision: Setting::NotSet,
|
||||
api_key: api_key.map(Setting::Set).unwrap_or_default(),
|
||||
dimensions: dimensions.map(Setting::Set).unwrap_or_default(),
|
||||
api_key: Setting::some_or_not_set(api_key),
|
||||
dimensions: Setting::some_or_not_set(dimensions),
|
||||
document_template: Setting::Set(prompt.template),
|
||||
url: Setting::Set(url),
|
||||
request: Setting::Set(request),
|
||||
response: Setting::Set(response),
|
||||
distribution: distribution.map(Setting::Set).unwrap_or_default(),
|
||||
distribution: Setting::some_or_not_set(distribution),
|
||||
headers: Setting::Set(headers),
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user