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