Add chat_completions to InstanceTogglableFeatures

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This commit is contained in:
Martin Tzvetanov Grigorov 2025-06-25 09:44:49 +03:00
parent da5f0de153
commit fe7245af20
No known key found for this signature in database
GPG key ID: 3194FD8C1AE300EF
6 changed files with 5 additions and 25 deletions

View file

@ -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
}));

View file

@ -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<WithoutTls>,
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`.

View file

@ -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)