mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Fixes #5669 - Enable chatCompletions
experimental feature via CLI and ENV
https://www.meilisearch.com/docs/reference/api/chats#chat-completions-workspace-object Currently the new `chatCompletions` feature could be enabled only via ``` curl \ -X PATCH 'MEILISEARCH_URL/experimental-features/' \ -H 'Content-Type: application/json' \ --data-binary '{ "chatCompletions": true }' ``` Now it will be possible to use 1) command line argument: `--experimental_chat_completions` 2) or environment variable: `export MEILI_EXPERIMENTAL_CHAT_COMPLETIONS=true` Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
This commit is contained in:
parent
fc6cc80705
commit
eb7230c2f6
4 changed files with 41 additions and 11 deletions
|
@ -45,6 +45,9 @@ 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;
|
||||
pub use error::Error;
|
||||
pub use features::RoFeatures;
|
||||
|
@ -71,9 +74,6 @@ use scheduler::Scheduler;
|
|||
use time::OffsetDateTime;
|
||||
use versioning::Versioning;
|
||||
|
||||
use crate::index_mapper::IndexMapper;
|
||||
use crate::utils::clamp_to_page_size;
|
||||
|
||||
pub(crate) type BEI128 = I128<BE>;
|
||||
|
||||
const TASK_SCHEDULER_SIZE_THRESHOLD_PERCENT_INT: u64 = 40;
|
||||
|
@ -136,6 +136,8 @@ 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
|
||||
|
@ -273,7 +275,7 @@ impl IndexScheduler {
|
|||
.open(&options.tasks_path)
|
||||
}?;
|
||||
|
||||
// We **must** starts by upgrading the version because it'll also upgrade the required database before we can open them
|
||||
// We **must** start by upgrading the version because it'll also upgrade the required database before we can open them
|
||||
let version = versioning::Versioning::new(&env, from_db_version)?;
|
||||
|
||||
let mut wtxn = env.write_txn()?;
|
||||
|
@ -281,8 +283,11 @@ 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())),
|
||||
|
@ -922,6 +927,22 @@ 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`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue