mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-05 20:26:31 +00:00
feat: add experimental_personalization_api_key feature to RoFeatures
- Add MEILI_EXPERIMENTAL_PERSONALIZATION_API_KEY environment variable - Add experimental_personalization_api_key field to Opt struct with CLI and env support - Add experimental_personalization_api_key field to InstanceTogglableFeatures - Store personalization API key in FeatureData for access through IndexScheduler - Add experimental_personalization_api_key() method to IndexScheduler - Update analytics destructuring to include new field - Maintain RoFeatures Copy trait while properly handling Option<String>
This commit is contained in:
@ -24,6 +24,7 @@ pub(crate) struct FeatureData {
|
|||||||
persisted: Database<Str, SerdeJson<RuntimeTogglableFeatures>>,
|
persisted: Database<Str, SerdeJson<RuntimeTogglableFeatures>>,
|
||||||
runtime: Arc<RwLock<RuntimeTogglableFeatures>>,
|
runtime: Arc<RwLock<RuntimeTogglableFeatures>>,
|
||||||
network: Arc<RwLock<Network>>,
|
network: Arc<RwLock<Network>>,
|
||||||
|
experimental_personalization_api_key: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
@ -174,7 +175,12 @@ impl FeatureData {
|
|||||||
|
|
||||||
let persisted_features: RuntimeTogglableFeatures =
|
let persisted_features: RuntimeTogglableFeatures =
|
||||||
runtime_features_db.get(wtxn, db_keys::EXPERIMENTAL_FEATURES)?.unwrap_or_default();
|
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,
|
||||||
|
experimental_personalization_api_key,
|
||||||
|
} = instance_features;
|
||||||
let runtime = Arc::new(RwLock::new(RuntimeTogglableFeatures {
|
let runtime = Arc::new(RwLock::new(RuntimeTogglableFeatures {
|
||||||
metrics: metrics || persisted_features.metrics,
|
metrics: metrics || persisted_features.metrics,
|
||||||
logs_route: logs_route || persisted_features.logs_route,
|
logs_route: logs_route || persisted_features.logs_route,
|
||||||
@ -189,6 +195,7 @@ impl FeatureData {
|
|||||||
persisted: runtime_features_db,
|
persisted: runtime_features_db,
|
||||||
runtime,
|
runtime,
|
||||||
network: Arc::new(RwLock::new(network)),
|
network: Arc::new(RwLock::new(network)),
|
||||||
|
experimental_personalization_api_key,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,6 +226,10 @@ impl FeatureData {
|
|||||||
RoFeatures::new(self)
|
RoFeatures::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn experimental_personalization_api_key(&self) -> Option<&String> {
|
||||||
|
self.experimental_personalization_api_key.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn put_network(&self, mut wtxn: RwTxn, new_network: Network) -> Result<()> {
|
pub fn put_network(&self, mut wtxn: RwTxn, new_network: Network) -> Result<()> {
|
||||||
self.persisted.remap_data_type::<SerdeJson<Network>>().put(
|
self.persisted.remap_data_type::<SerdeJson<Network>>().put(
|
||||||
&mut wtxn,
|
&mut wtxn,
|
||||||
|
@ -280,7 +280,8 @@ impl IndexScheduler {
|
|||||||
let version = versioning::Versioning::new(&env, from_db_version)?;
|
let version = versioning::Versioning::new(&env, from_db_version)?;
|
||||||
|
|
||||||
let mut wtxn = env.write_txn()?;
|
let mut wtxn = env.write_txn()?;
|
||||||
let features = features::FeatureData::new(&env, &mut wtxn, options.instance_features)?;
|
let features =
|
||||||
|
features::FeatureData::new(&env, &mut wtxn, options.instance_features.clone())?;
|
||||||
let queue = Queue::new(&env, &mut wtxn, &options)?;
|
let queue = Queue::new(&env, &mut wtxn, &options)?;
|
||||||
let index_mapper = IndexMapper::new(&env, &mut wtxn, &options, budget)?;
|
let index_mapper = IndexMapper::new(&env, &mut wtxn, &options, budget)?;
|
||||||
let chat_settings = env.create_database(&mut wtxn, Some(CHAT_SETTINGS_DB_NAME))?;
|
let chat_settings = env.create_database(&mut wtxn, Some(CHAT_SETTINGS_DB_NAME))?;
|
||||||
@ -834,6 +835,10 @@ impl IndexScheduler {
|
|||||||
self.features.features()
|
self.features.features()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn experimental_personalization_api_key(&self) -> Option<&String> {
|
||||||
|
self.features.experimental_personalization_api_key()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn put_runtime_features(&self, features: RuntimeTogglableFeatures) -> Result<()> {
|
pub fn put_runtime_features(&self, features: RuntimeTogglableFeatures) -> Result<()> {
|
||||||
let wtxn = self.env.write_txn().map_err(Error::HeedTransaction)?;
|
let wtxn = self.env.write_txn().map_err(Error::HeedTransaction)?;
|
||||||
self.features.put_runtime_features(wtxn, features)?;
|
self.features.put_runtime_features(wtxn, features)?;
|
||||||
|
@ -25,11 +25,12 @@ pub struct RuntimeTogglableFeatures {
|
|||||||
pub multimodal: bool,
|
pub multimodal: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Copy)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct InstanceTogglableFeatures {
|
pub struct InstanceTogglableFeatures {
|
||||||
pub metrics: bool,
|
pub metrics: bool,
|
||||||
pub logs_route: bool,
|
pub logs_route: bool,
|
||||||
pub contains_filter: bool,
|
pub contains_filter: bool,
|
||||||
|
pub experimental_personalization_api_key: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||||
|
@ -281,6 +281,7 @@ impl Infos {
|
|||||||
indexer_options,
|
indexer_options,
|
||||||
config_file_path,
|
config_file_path,
|
||||||
no_analytics: _,
|
no_analytics: _,
|
||||||
|
experimental_personalization_api_key: _,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
let schedule_snapshot = match schedule_snapshot {
|
let schedule_snapshot = match schedule_snapshot {
|
||||||
|
@ -68,6 +68,8 @@ const MEILI_EXPERIMENTAL_LIMIT_BATCHED_TASKS_TOTAL_SIZE: &str =
|
|||||||
const MEILI_EXPERIMENTAL_EMBEDDING_CACHE_ENTRIES: &str =
|
const MEILI_EXPERIMENTAL_EMBEDDING_CACHE_ENTRIES: &str =
|
||||||
"MEILI_EXPERIMENTAL_EMBEDDING_CACHE_ENTRIES";
|
"MEILI_EXPERIMENTAL_EMBEDDING_CACHE_ENTRIES";
|
||||||
const MEILI_EXPERIMENTAL_NO_SNAPSHOT_COMPACTION: &str = "MEILI_EXPERIMENTAL_NO_SNAPSHOT_COMPACTION";
|
const MEILI_EXPERIMENTAL_NO_SNAPSHOT_COMPACTION: &str = "MEILI_EXPERIMENTAL_NO_SNAPSHOT_COMPACTION";
|
||||||
|
const MEILI_EXPERIMENTAL_PERSONALIZATION_API_KEY: &str =
|
||||||
|
"MEILI_EXPERIMENTAL_PERSONALIZATION_API_KEY";
|
||||||
const DEFAULT_CONFIG_FILE_PATH: &str = "./config.toml";
|
const DEFAULT_CONFIG_FILE_PATH: &str = "./config.toml";
|
||||||
const DEFAULT_DB_PATH: &str = "./data.ms";
|
const DEFAULT_DB_PATH: &str = "./data.ms";
|
||||||
const DEFAULT_HTTP_ADDR: &str = "localhost:7700";
|
const DEFAULT_HTTP_ADDR: &str = "localhost:7700";
|
||||||
@ -467,6 +469,12 @@ pub struct Opt {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub experimental_no_snapshot_compaction: bool,
|
pub experimental_no_snapshot_compaction: bool,
|
||||||
|
|
||||||
|
/// Experimental personalization API key feature.
|
||||||
|
///
|
||||||
|
/// Sets the API key for personalization features.
|
||||||
|
#[clap(long, env = MEILI_EXPERIMENTAL_PERSONALIZATION_API_KEY)]
|
||||||
|
pub experimental_personalization_api_key: Option<String>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
pub indexer_options: IndexerOpts,
|
pub indexer_options: IndexerOpts,
|
||||||
@ -572,6 +580,7 @@ impl Opt {
|
|||||||
experimental_limit_batched_tasks_total_size,
|
experimental_limit_batched_tasks_total_size,
|
||||||
experimental_embedding_cache_entries,
|
experimental_embedding_cache_entries,
|
||||||
experimental_no_snapshot_compaction,
|
experimental_no_snapshot_compaction,
|
||||||
|
experimental_personalization_api_key,
|
||||||
} = self;
|
} = self;
|
||||||
export_to_env_if_not_present(MEILI_DB_PATH, db_path);
|
export_to_env_if_not_present(MEILI_DB_PATH, db_path);
|
||||||
export_to_env_if_not_present(MEILI_HTTP_ADDR, http_addr);
|
export_to_env_if_not_present(MEILI_HTTP_ADDR, http_addr);
|
||||||
@ -672,6 +681,12 @@ impl Opt {
|
|||||||
MEILI_EXPERIMENTAL_NO_SNAPSHOT_COMPACTION,
|
MEILI_EXPERIMENTAL_NO_SNAPSHOT_COMPACTION,
|
||||||
experimental_no_snapshot_compaction.to_string(),
|
experimental_no_snapshot_compaction.to_string(),
|
||||||
);
|
);
|
||||||
|
if let Some(experimental_personalization_api_key) = experimental_personalization_api_key {
|
||||||
|
export_to_env_if_not_present(
|
||||||
|
MEILI_EXPERIMENTAL_PERSONALIZATION_API_KEY,
|
||||||
|
experimental_personalization_api_key,
|
||||||
|
);
|
||||||
|
}
|
||||||
indexer_options.export_to_env();
|
indexer_options.export_to_env();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,6 +739,7 @@ impl Opt {
|
|||||||
metrics: self.experimental_enable_metrics,
|
metrics: self.experimental_enable_metrics,
|
||||||
logs_route: self.experimental_enable_logs_route,
|
logs_route: self.experimental_enable_logs_route,
|
||||||
contains_filter: self.experimental_contains_filter,
|
contains_filter: self.experimental_contains_filter,
|
||||||
|
experimental_personalization_api_key: self.experimental_personalization_api_key.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user