mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
milli: refactor getting embedder and embedder name
This commit is contained in:
parent
190933f6e1
commit
00c4ed3bc2
@ -143,7 +143,7 @@ impl EmbeddingConfigs {
|
|||||||
|
|
||||||
/// Get the default embedder configuration, if any.
|
/// Get the default embedder configuration, if any.
|
||||||
pub fn get_default(&self) -> Option<(Arc<Embedder>, Arc<Prompt>)> {
|
pub fn get_default(&self) -> Option<(Arc<Embedder>, Arc<Prompt>)> {
|
||||||
self.get_default_embedder_name().and_then(|default| self.get(&default))
|
self.get(self.get_default_embedder_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the name of the default embedder configuration.
|
/// Get the name of the default embedder configuration.
|
||||||
@ -153,14 +153,14 @@ impl EmbeddingConfigs {
|
|||||||
/// - If there is only one embedder, it is always the default.
|
/// - If there is only one embedder, it is always the default.
|
||||||
/// - If there are multiple embedders and one of them is called `default`, then that one is the default embedder.
|
/// - If there are multiple embedders and one of them is called `default`, then that one is the default embedder.
|
||||||
/// - In all other cases, there is no default embedder.
|
/// - In all other cases, there is no default embedder.
|
||||||
pub fn get_default_embedder_name(&self) -> Option<String> {
|
pub fn get_default_embedder_name(&self) -> &str {
|
||||||
let mut it = self.0.keys();
|
let mut it = self.0.keys();
|
||||||
let first_name = it.next();
|
let first_name = it.next();
|
||||||
let second_name = it.next();
|
let second_name = it.next();
|
||||||
match (first_name, second_name) {
|
match (first_name, second_name) {
|
||||||
(None, _) => None,
|
(None, _) => "default",
|
||||||
(Some(first), None) => Some(first.to_owned()),
|
(Some(first), None) => first,
|
||||||
(Some(_), Some(_)) => Some("default".to_owned()),
|
(Some(_), Some(_)) => "default",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user