mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-06-07 04:35:37 +00:00
Do a first clippy pass
This commit is contained in:
parent
3c218cc3a0
commit
8fdcdee0cc
@ -119,7 +119,7 @@ fn setup_search_tool(
|
||||
prompts: &DbChatCompletionPrompts,
|
||||
) -> Result<FunctionSupport, ResponseError> {
|
||||
let tools = chat_completion.tools.get_or_insert_default();
|
||||
if tools.iter().find(|t| t.function.name == MEILI_SEARCH_IN_INDEX_FUNCTION_NAME).is_some() {
|
||||
if tools.iter().any(|t| t.function.name == MEILI_SEARCH_IN_INDEX_FUNCTION_NAME) {
|
||||
panic!("{MEILI_SEARCH_IN_INDEX_FUNCTION_NAME} function already set");
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ fn setup_search_tool(
|
||||
let mut function_description = prompts.search_description.clone();
|
||||
index_scheduler.try_for_each_index::<_, ()>(|name, index| {
|
||||
// Make sure to skip unauthorized indexes
|
||||
if !filters.is_index_authorized(&name) {
|
||||
if !filters.is_index_authorized(name) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ async fn non_streamed_chat(
|
||||
&index_scheduler,
|
||||
auth_ctrl.clone(),
|
||||
&search_queue,
|
||||
&auth_token,
|
||||
auth_token,
|
||||
index_uid,
|
||||
q,
|
||||
)
|
||||
@ -461,6 +461,7 @@ async fn streamed_chat(
|
||||
|
||||
/// Updates the chat completion with the new messages, streams the LLM tokens,
|
||||
/// and report progress and errors.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn run_conversation<C: Config>(
|
||||
index_scheduler: &GuardedData<ActionPolicy<{ actions::CHAT }>, Data<IndexScheduler>>,
|
||||
auth_ctrl: &web::Data<AuthController>,
|
||||
@ -515,7 +516,7 @@ async fn run_conversation<C: Config>(
|
||||
}
|
||||
});
|
||||
|
||||
if global_tool_calls.get(index).map_or(false, Call::is_external) {
|
||||
if global_tool_calls.get(index).is_some_and(Call::is_external) {
|
||||
todo!("Support forwarding external tool calls");
|
||||
}
|
||||
}
|
||||
@ -553,10 +554,10 @@ async fn run_conversation<C: Config>(
|
||||
);
|
||||
|
||||
handle_meili_tools(
|
||||
&index_scheduler,
|
||||
&auth_ctrl,
|
||||
&search_queue,
|
||||
&auth_token,
|
||||
index_scheduler,
|
||||
auth_ctrl,
|
||||
search_queue,
|
||||
auth_token,
|
||||
chat_settings,
|
||||
tx,
|
||||
meili_calls,
|
||||
@ -586,6 +587,7 @@ async fn run_conversation<C: Config>(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn handle_meili_tools(
|
||||
index_scheduler: &GuardedData<ActionPolicy<{ actions::CHAT }>, Data<IndexScheduler>>,
|
||||
auth_ctrl: &web::Data<AuthController>,
|
||||
@ -621,10 +623,10 @@ async fn handle_meili_tools(
|
||||
|
||||
let result = match serde_json::from_str(&call.function.arguments) {
|
||||
Ok(SearchInIndexParameters { index_uid, q }) => process_search_request(
|
||||
&index_scheduler,
|
||||
index_scheduler,
|
||||
auth_ctrl.clone(),
|
||||
&search_queue,
|
||||
&auth_token,
|
||||
search_queue,
|
||||
auth_token,
|
||||
index_uid,
|
||||
q,
|
||||
)
|
||||
|
@ -16,12 +16,11 @@ use meilisearch_types::milli::update::Setting;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use super::ChatsParam;
|
||||
use crate::extractors::authentication::policies::ActionPolicy;
|
||||
use crate::extractors::authentication::GuardedData;
|
||||
use crate::extractors::sequential_extractor::SeqHandler;
|
||||
|
||||
use super::ChatsParam;
|
||||
|
||||
pub fn configure(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
web::resource("")
|
||||
@ -70,8 +69,7 @@ async fn patch_settings(
|
||||
|
||||
// TODO do a spawn_blocking here
|
||||
let mut wtxn = index_scheduler.write_txn()?;
|
||||
let old_settings =
|
||||
index_scheduler.chat_settings(&mut wtxn, &workspace_uid)?.unwrap_or_default();
|
||||
let old_settings = index_scheduler.chat_settings(&wtxn, &workspace_uid)?.unwrap_or_default();
|
||||
|
||||
let prompts = match new.prompts {
|
||||
Setting::Set(new_prompts) => DbChatCompletionPrompts {
|
||||
|
@ -208,8 +208,8 @@ impl SseEventSender {
|
||||
/// Format documents based on the provided template and maximum bytes.
|
||||
///
|
||||
/// This formatting function is usually used to generate a summary of the documents for LLMs.
|
||||
pub fn format_documents<'t, 'doc>(
|
||||
rtxn: &RoTxn<'t>,
|
||||
pub fn format_documents<'doc>(
|
||||
rtxn: &RoTxn<'_>,
|
||||
index: &Index,
|
||||
doc_alloc: &'doc Bump,
|
||||
internal_docids: Vec<DocumentId>,
|
||||
|
@ -204,7 +204,7 @@ impl std::convert::TryFrom<f64> for RankingScoreThreshold {
|
||||
impl From<index::RankingScoreThreshold> for RankingScoreThreshold {
|
||||
fn from(threshold: index::RankingScoreThreshold) -> Self {
|
||||
let threshold = threshold.as_f64();
|
||||
assert!(threshold >= 0.0 && threshold <= 1.0);
|
||||
assert!((0.0..=1.0).contains(&threshold));
|
||||
RankingScoreThreshold(threshold)
|
||||
}
|
||||
}
|
||||
|
@ -1984,7 +1984,7 @@ impl TryFrom<f64> for RankingScoreThreshold {
|
||||
type Error = InvalidSearchRankingScoreThreshold;
|
||||
|
||||
fn try_from(value: f64) -> StdResult<Self, Self::Error> {
|
||||
if value < 0.0 || value > 1.0 {
|
||||
if !(0.0..=1.0).contains(&value) {
|
||||
Err(InvalidSearchRankingScoreThreshold)
|
||||
} else {
|
||||
Ok(RankingScoreThreshold(value))
|
||||
|
@ -69,11 +69,6 @@ impl From<ChatConfig> for ChatSettings {
|
||||
HybridQuery { semantic_ratio: SemanticRatio(semantic_ratio), embedder }
|
||||
});
|
||||
|
||||
let matching_strategy = matching_strategy.map(MatchingStrategy::from);
|
||||
|
||||
let ranking_score_threshold =
|
||||
ranking_score_threshold.map(RankingScoreThreshold::from);
|
||||
|
||||
ChatSearchParams {
|
||||
hybrid: Setting::some_or_not_set(hybrid),
|
||||
limit: Setting::some_or_not_set(limit),
|
||||
|
@ -23,7 +23,7 @@ use crate::error::UserError;
|
||||
use crate::fields_ids_map::metadata::{FieldIdMapWithMetadata, MetadataBuilder};
|
||||
use crate::filterable_attributes_rules::match_faceted_field;
|
||||
use crate::index::{
|
||||
ChatConfig, IndexEmbeddingConfig, MatchingStrategy, PrefixSearch, RankingScoreThreshold,
|
||||
ChatConfig, IndexEmbeddingConfig, PrefixSearch,
|
||||
SearchParameters, DEFAULT_MIN_WORD_LEN_ONE_TYPO, DEFAULT_MIN_WORD_LEN_TWO_TYPOS,
|
||||
};
|
||||
use crate::order_by_map::OrderByMap;
|
||||
@ -1326,7 +1326,7 @@ impl<'a, 't, 'i> Settings<'a, 't, 'i> {
|
||||
},
|
||||
matching_strategy: match matching_strategy {
|
||||
Setting::Set(matching_strategy) => {
|
||||
Some(MatchingStrategy::from(*matching_strategy))
|
||||
Some(*matching_strategy)
|
||||
}
|
||||
Setting::Reset => None,
|
||||
Setting::NotSet => search_parameters.matching_strategy,
|
||||
@ -1341,7 +1341,7 @@ impl<'a, 't, 'i> Settings<'a, 't, 'i> {
|
||||
}
|
||||
},
|
||||
ranking_score_threshold: match ranking_score_threshold {
|
||||
Setting::Set(rst) => Some(RankingScoreThreshold::from(*rst)),
|
||||
Setting::Set(rst) => Some(*rst),
|
||||
Setting::Reset => None,
|
||||
Setting::NotSet => search_parameters.ranking_score_threshold,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user