mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-06-07 12:45:40 +00:00
Fix the chat completions feature gate
This commit is contained in:
parent
c4e1407e77
commit
28dc7b836b
@ -298,7 +298,7 @@ async fn non_streamed_chat(
|
|||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
mut chat_completion: CreateChatCompletionRequest,
|
mut chat_completion: CreateChatCompletionRequest,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
index_scheduler.features().check_chat_completions("Using the /chats chat completions route")?;
|
index_scheduler.features().check_chat_completions("using the /chats chat completions route")?;
|
||||||
let filters = index_scheduler.filters();
|
let filters = index_scheduler.filters();
|
||||||
|
|
||||||
let rtxn = index_scheduler.read_txn()?;
|
let rtxn = index_scheduler.read_txn()?;
|
||||||
@ -398,7 +398,7 @@ async fn streamed_chat(
|
|||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
mut chat_completion: CreateChatCompletionRequest,
|
mut chat_completion: CreateChatCompletionRequest,
|
||||||
) -> Result<impl Responder, ResponseError> {
|
) -> Result<impl Responder, ResponseError> {
|
||||||
index_scheduler.features().check_chat_completions("Using the /chats chat completions route")?;
|
index_scheduler.features().check_chat_completions("using the /chats chat completions route")?;
|
||||||
let filters = index_scheduler.filters();
|
let filters = index_scheduler.filters();
|
||||||
|
|
||||||
let rtxn = index_scheduler.read_txn()?;
|
let rtxn = index_scheduler.read_txn()?;
|
||||||
|
@ -75,7 +75,7 @@ pub async fn list_workspaces(
|
|||||||
index_scheduler: GuardedData<ActionPolicy<{ actions::CHATS_GET }>, Data<IndexScheduler>>,
|
index_scheduler: GuardedData<ActionPolicy<{ actions::CHATS_GET }>, Data<IndexScheduler>>,
|
||||||
paginate: AwebQueryParameter<ListChats, DeserrQueryParamError>,
|
paginate: AwebQueryParameter<ListChats, DeserrQueryParamError>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
index_scheduler.features().check_chat_completions("Using the /chats settings route")?;
|
index_scheduler.features().check_chat_completions("listing the chats")?;
|
||||||
|
|
||||||
debug!(parameters = ?paginate, "List chat workspaces");
|
debug!(parameters = ?paginate, "List chat workspaces");
|
||||||
let filters = index_scheduler.filters();
|
let filters = index_scheduler.filters();
|
||||||
|
@ -37,7 +37,7 @@ async fn get_settings(
|
|||||||
>,
|
>,
|
||||||
chats_param: web::Path<ChatsParam>,
|
chats_param: web::Path<ChatsParam>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
index_scheduler.features().check_chat_completions("Using the /chats settings route")?;
|
index_scheduler.features().check_chat_completions("using the /chats/settings route")?;
|
||||||
|
|
||||||
let ChatsParam { workspace_uid } = chats_param.into_inner();
|
let ChatsParam { workspace_uid } = chats_param.into_inner();
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ async fn patch_settings(
|
|||||||
chats_param: web::Path<ChatsParam>,
|
chats_param: web::Path<ChatsParam>,
|
||||||
web::Json(new): web::Json<GlobalChatSettings>,
|
web::Json(new): web::Json<GlobalChatSettings>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
index_scheduler.features().check_chat_completions("Using the /chats settings route")?;
|
index_scheduler.features().check_chat_completions("using the /chats/settings route")?;
|
||||||
let ChatsParam { workspace_uid } = chats_param.into_inner();
|
let ChatsParam { workspace_uid } = chats_param.into_inner();
|
||||||
|
|
||||||
// TODO do a spawn_blocking here
|
// TODO do a spawn_blocking here
|
||||||
@ -144,7 +144,7 @@ async fn delete_settings(
|
|||||||
>,
|
>,
|
||||||
chats_param: web::Path<ChatsParam>,
|
chats_param: web::Path<ChatsParam>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
index_scheduler.features().check_chat_completions("Using the /chats settings route")?;
|
index_scheduler.features().check_chat_completions("using the /chats/settings route")?;
|
||||||
|
|
||||||
let ChatsParam { workspace_uid } = chats_param.into_inner();
|
let ChatsParam { workspace_uid } = chats_param.into_inner();
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ use index_scheduler::IndexScheduler;
|
|||||||
use meilisearch_types::deserr::DeserrJsonError;
|
use meilisearch_types::deserr::DeserrJsonError;
|
||||||
use meilisearch_types::error::ResponseError;
|
use meilisearch_types::error::ResponseError;
|
||||||
use meilisearch_types::index_uid::IndexUid;
|
use meilisearch_types::index_uid::IndexUid;
|
||||||
|
use meilisearch_types::milli::update::Setting;
|
||||||
use meilisearch_types::settings::{
|
use meilisearch_types::settings::{
|
||||||
settings, ChatSettings, SecretPolicy, SettingEmbeddingSettings, Settings, Unchecked,
|
settings, ChatSettings, SecretPolicy, SettingEmbeddingSettings, Settings, Unchecked,
|
||||||
};
|
};
|
||||||
@ -568,6 +569,10 @@ pub async fn update_all(
|
|||||||
debug!(parameters = ?new_settings, "Update all settings");
|
debug!(parameters = ?new_settings, "Update all settings");
|
||||||
let new_settings = validate_settings(new_settings, &index_scheduler)?;
|
let new_settings = validate_settings(new_settings, &index_scheduler)?;
|
||||||
|
|
||||||
|
if !new_settings.chat.is_not_set() {
|
||||||
|
index_scheduler.features().check_chat_completions("setting `chat` in the index route")?;
|
||||||
|
}
|
||||||
|
|
||||||
analytics.publish(
|
analytics.publish(
|
||||||
SettingsAnalytics {
|
SettingsAnalytics {
|
||||||
ranking_rules: RankingRulesAnalytics::new(new_settings.ranking_rules.as_ref().set()),
|
ranking_rules: RankingRulesAnalytics::new(new_settings.ranking_rules.as_ref().set()),
|
||||||
@ -663,7 +668,11 @@ pub async fn get_all(
|
|||||||
|
|
||||||
let index = index_scheduler.index(&index_uid)?;
|
let index = index_scheduler.index(&index_uid)?;
|
||||||
let rtxn = index.read_txn()?;
|
let rtxn = index.read_txn()?;
|
||||||
let new_settings = settings(&index, &rtxn, SecretPolicy::HideSecrets)?;
|
let mut new_settings = settings(&index, &rtxn, SecretPolicy::HideSecrets)?;
|
||||||
|
if index_scheduler.features().check_chat_completions("showing index `chat` settings").is_err() {
|
||||||
|
new_settings.chat = Setting::NotSet;
|
||||||
|
}
|
||||||
|
|
||||||
debug!(returns = ?new_settings, "Get all settings");
|
debug!(returns = ?new_settings, "Get all settings");
|
||||||
Ok(HttpResponse::Ok().json(new_settings))
|
Ok(HttpResponse::Ok().json(new_settings))
|
||||||
}
|
}
|
||||||
@ -753,5 +762,9 @@ fn validate_settings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Setting::Set(_chat) = &settings.chat {
|
||||||
|
features.check_chat_completions("setting `chat` in the index settings")?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(settings.validate()?)
|
Ok(settings.validate()?)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user