From fe7245af20f74b7a797cf200a553f73691b8fdff Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Wed, 25 Jun 2025 09:44:49 +0300 Subject: [PATCH] Add chat_completions to InstanceTogglableFeatures Signed-off-by: Martin Tzvetanov Grigorov --- crates/index-scheduler/src/features.rs | 4 +++- crates/index-scheduler/src/lib.rs | 22 ---------------------- crates/index-scheduler/src/test_utils.rs | 1 - crates/meilisearch-types/src/features.rs | 1 + crates/meilisearch/src/lib.rs | 1 - crates/meilisearch/src/option.rs | 1 + 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/crates/index-scheduler/src/features.rs b/crates/index-scheduler/src/features.rs index 78ffc0766..89495264c 100644 --- a/crates/index-scheduler/src/features.rs +++ b/crates/index-scheduler/src/features.rs @@ -161,11 +161,13 @@ impl FeatureData { let persisted_features: RuntimeTogglableFeatures = runtime_features_db.get(wtxn, db_keys::EXPERIMENTAL_FEATURES)?.unwrap_or_default(); - let InstanceTogglableFeatures { metrics, logs_route, contains_filter } = instance_features; + let InstanceTogglableFeatures { metrics, logs_route, contains_filter, chat_completions } = + instance_features; let runtime = Arc::new(RwLock::new(RuntimeTogglableFeatures { metrics: metrics || persisted_features.metrics, logs_route: logs_route || persisted_features.logs_route, contains_filter: contains_filter || persisted_features.contains_filter, + chat_completions: chat_completions || persisted_features.chat_completions, ..persisted_features })); diff --git a/crates/index-scheduler/src/lib.rs b/crates/index-scheduler/src/lib.rs index eed847662..e9d0b2374 100644 --- a/crates/index-scheduler/src/lib.rs +++ b/crates/index-scheduler/src/lib.rs @@ -45,7 +45,6 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock}; use std::time::Duration; -use crate::features::FeatureData; use crate::index_mapper::IndexMapper; use crate::utils::clamp_to_page_size; use dump::Dump; @@ -136,8 +135,6 @@ pub struct IndexSchedulerOptions { pub embedding_cache_cap: usize, /// Snapshot compaction status. pub experimental_no_snapshot_compaction: bool, - /// Whether the chat completions are enabled or not. - pub experimental_chat_completions: bool, } /// Structure which holds meilisearch's indexes and schedules the tasks @@ -283,11 +280,8 @@ impl IndexScheduler { let queue = Queue::new(&env, &mut wtxn, &options)?; let index_mapper = IndexMapper::new(&env, &mut wtxn, &options, budget)?; let chat_settings = env.create_database(&mut wtxn, Some(CHAT_SETTINGS_DB_NAME))?; - wtxn.commit()?; - configure_experimental_features(&env, &features, &options)?; - // allow unreachable_code to get rids of the warning in the case of a test build. let this = Self { processing_tasks: Arc::new(RwLock::new(ProcessingTasks::new())), @@ -927,22 +921,6 @@ impl IndexScheduler { } } -fn configure_experimental_features( - env: &Env, - features: &FeatureData, - options: &IndexSchedulerOptions, -) -> Result<()> { - let current_features = features.features().runtime_features(); - - let new_features = RuntimeTogglableFeatures { - chat_completions: options.experimental_chat_completions, - ..current_features - }; - - let wtxn = env.write_txn().map_err(Error::HeedTransaction)?; - features.put_runtime_features(wtxn, new_features) -} - /// The outcome of calling the [`IndexScheduler::tick`] function. pub enum TickOutcome { /// The scheduler should immediately attempt another `tick`. diff --git a/crates/index-scheduler/src/test_utils.rs b/crates/index-scheduler/src/test_utils.rs index 2382db041..5f206b55c 100644 --- a/crates/index-scheduler/src/test_utils.rs +++ b/crates/index-scheduler/src/test_utils.rs @@ -114,7 +114,6 @@ impl IndexScheduler { auto_upgrade: true, // Don't cost much and will ensure the happy path works embedding_cache_cap: 10, experimental_no_snapshot_compaction: false, - experimental_chat_completions: false, }; let version = configuration(&mut options).unwrap_or({ (versioning::VERSION_MAJOR, versioning::VERSION_MINOR, versioning::VERSION_PATCH) diff --git a/crates/meilisearch-types/src/features.rs b/crates/meilisearch-types/src/features.rs index 83054e784..21ee0e53c 100644 --- a/crates/meilisearch-types/src/features.rs +++ b/crates/meilisearch-types/src/features.rs @@ -28,6 +28,7 @@ pub struct InstanceTogglableFeatures { pub metrics: bool, pub logs_route: bool, pub contains_filter: bool, + pub chat_completions: bool, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] diff --git a/crates/meilisearch/src/lib.rs b/crates/meilisearch/src/lib.rs index b376a967e..1e0c205d0 100644 --- a/crates/meilisearch/src/lib.rs +++ b/crates/meilisearch/src/lib.rs @@ -237,7 +237,6 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(Arc, Arc< auto_upgrade: opt.experimental_dumpless_upgrade, embedding_cache_cap: opt.experimental_embedding_cache_entries, experimental_no_snapshot_compaction: opt.experimental_no_snapshot_compaction, - experimental_chat_completions: opt.experimental_chat_completions, }; let binary_version = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH); diff --git a/crates/meilisearch/src/option.rs b/crates/meilisearch/src/option.rs index 36704b712..7aa34e801 100644 --- a/crates/meilisearch/src/option.rs +++ b/crates/meilisearch/src/option.rs @@ -729,6 +729,7 @@ impl Opt { metrics: self.experimental_enable_metrics, logs_route: self.experimental_enable_logs_route, contains_filter: self.experimental_contains_filter, + chat_completions: self.experimental_chat_completions, } } }