From f4dd73ec8ce6e29d23e3c86ca40de57fb935dcbd Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 2 May 2024 15:39:36 +0200 Subject: [PATCH 1/2] Destructure EmbedderOptions so we don't miss some options --- milli/src/vector/settings.rs | 51 ++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/milli/src/vector/settings.rs b/milli/src/vector/settings.rs index 5707f9533..e786a7164 100644 --- a/milli/src/vector/settings.rs +++ b/milli/src/vector/settings.rs @@ -301,10 +301,14 @@ impl From for EmbeddingSettings { fn from(value: EmbeddingConfig) -> Self { let EmbeddingConfig { embedder_options, prompt } = value; match embedder_options { - super::EmbedderOptions::HuggingFace(options) => Self { + super::EmbedderOptions::HuggingFace(super::hf::EmbedderOptions { + model, + revision, + distribution, + }) => Self { source: Setting::Set(EmbedderSource::HuggingFace), - model: Setting::Set(options.model), - revision: options.revision.map(Setting::Set).unwrap_or_default(), + model: Setting::Set(model), + revision: revision.map(Setting::Set).unwrap_or_default(), api_key: Setting::NotSet, dimensions: Setting::NotSet, document_template: Setting::Set(prompt.template), @@ -314,14 +318,19 @@ impl From for EmbeddingSettings { path_to_embeddings: Setting::NotSet, embedding_object: Setting::NotSet, input_type: Setting::NotSet, - distribution: options.distribution.map(Setting::Set).unwrap_or_default(), + distribution: distribution.map(Setting::Set).unwrap_or_default(), }, - super::EmbedderOptions::OpenAi(options) => Self { + super::EmbedderOptions::OpenAi(super::openai::EmbedderOptions { + api_key, + embedding_model, + dimensions, + distribution, + }) => Self { source: Setting::Set(EmbedderSource::OpenAi), - model: Setting::Set(options.embedding_model.name().to_owned()), + model: Setting::Set(embedding_model.name().to_owned()), revision: Setting::NotSet, - api_key: options.api_key.map(Setting::Set).unwrap_or_default(), - dimensions: options.dimensions.map(Setting::Set).unwrap_or_default(), + api_key: api_key.map(Setting::Set).unwrap_or_default(), + dimensions: dimensions.map(Setting::Set).unwrap_or_default(), document_template: Setting::Set(prompt.template), url: Setting::NotSet, query: Setting::NotSet, @@ -329,29 +338,37 @@ impl From for EmbeddingSettings { path_to_embeddings: Setting::NotSet, embedding_object: Setting::NotSet, input_type: Setting::NotSet, - distribution: options.distribution.map(Setting::Set).unwrap_or_default(), + distribution: distribution.map(Setting::Set).unwrap_or_default(), }, - super::EmbedderOptions::Ollama(options) => Self { + super::EmbedderOptions::Ollama(super::ollama::EmbedderOptions { + embedding_model, + url, + api_key, + distribution, + }) => Self { source: Setting::Set(EmbedderSource::Ollama), - model: Setting::Set(options.embedding_model.to_owned()), + model: Setting::Set(embedding_model), revision: Setting::NotSet, - api_key: options.api_key.map(Setting::Set).unwrap_or_default(), + api_key: api_key.map(Setting::Set).unwrap_or_default(), dimensions: Setting::NotSet, document_template: Setting::Set(prompt.template), - url: Setting::NotSet, + url: url.map(Setting::Set).unwrap_or_default(), query: Setting::NotSet, input_field: Setting::NotSet, path_to_embeddings: Setting::NotSet, embedding_object: Setting::NotSet, input_type: Setting::NotSet, - distribution: options.distribution.map(Setting::Set).unwrap_or_default(), + distribution: distribution.map(Setting::Set).unwrap_or_default(), }, - super::EmbedderOptions::UserProvided(options) => Self { + super::EmbedderOptions::UserProvided(super::manual::EmbedderOptions { + dimensions, + distribution, + }) => Self { source: Setting::Set(EmbedderSource::UserProvided), model: Setting::NotSet, revision: Setting::NotSet, api_key: Setting::NotSet, - dimensions: Setting::Set(options.dimensions), + dimensions: Setting::Set(dimensions), document_template: Setting::NotSet, url: Setting::NotSet, query: Setting::NotSet, @@ -359,7 +376,7 @@ impl From for EmbeddingSettings { path_to_embeddings: Setting::NotSet, embedding_object: Setting::NotSet, input_type: Setting::NotSet, - distribution: options.distribution.map(Setting::Set).unwrap_or_default(), + distribution: distribution.map(Setting::Set).unwrap_or_default(), }, super::EmbedderOptions::Rest(super::rest::EmbedderOptions { api_key, From 5a305bfdea0ec1e47e406797c0d4ca81da377060 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 2 May 2024 16:14:37 +0200 Subject: [PATCH 2/2] Remove unused struct --- meilisearch/src/routes/mod.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/meilisearch/src/routes/mod.rs b/meilisearch/src/routes/mod.rs index 0e6ab7765..c25aeee70 100644 --- a/meilisearch/src/routes/mod.rs +++ b/meilisearch/src/routes/mod.rs @@ -367,12 +367,6 @@ async fn get_version( }) } -#[derive(Serialize)] -struct KeysResponse { - private: Option, - public: Option, -} - pub async fn get_health( index_scheduler: Data, auth_controller: Data,