mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-06-15 20:42:24 +02:00
Report an error when the document template max bytes is zero
This commit is contained in:
parent
34d572e3e5
commit
5ceb3c6a10
@ -447,6 +447,7 @@ impl ErrorCode for milli::Error {
|
|||||||
| UserError::InvalidSettingsDimensions { .. }
|
| UserError::InvalidSettingsDimensions { .. }
|
||||||
| UserError::InvalidUrl { .. }
|
| UserError::InvalidUrl { .. }
|
||||||
| UserError::InvalidSettingsDocumentTemplateMaxBytes { .. }
|
| UserError::InvalidSettingsDocumentTemplateMaxBytes { .. }
|
||||||
|
| UserError::InvalidChatSettingsDocumentTemplateMaxBytes
|
||||||
| UserError::InvalidPrompt(_)
|
| UserError::InvalidPrompt(_)
|
||||||
| UserError::InvalidDisableBinaryQuantization { .. }
|
| UserError::InvalidDisableBinaryQuantization { .. }
|
||||||
| UserError::InvalidSourceForNested { .. }
|
| UserError::InvalidSourceForNested { .. }
|
||||||
|
@ -386,6 +386,8 @@ and can not be more than 511 bytes.", .document_id.to_string()
|
|||||||
DocumentEditionRuntimeError(Box<EvalAltResult>),
|
DocumentEditionRuntimeError(Box<EvalAltResult>),
|
||||||
#[error("Document edition runtime error encountered while compiling the function: {0}")]
|
#[error("Document edition runtime error encountered while compiling the function: {0}")]
|
||||||
DocumentEditionCompilationError(rhai::ParseError),
|
DocumentEditionCompilationError(rhai::ParseError),
|
||||||
|
#[error("`.chat.documentTemplateMaxBytes`: `documentTemplateMaxBytes` cannot be zero")]
|
||||||
|
InvalidChatSettingsDocumentTemplateMaxBytes,
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
DocumentEmbeddingError(String),
|
DocumentEmbeddingError(String),
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ use crate::attribute_patterns::PatternMatch;
|
|||||||
use crate::constants::RESERVED_GEO_FIELD_NAME;
|
use crate::constants::RESERVED_GEO_FIELD_NAME;
|
||||||
use crate::criterion::Criterion;
|
use crate::criterion::Criterion;
|
||||||
use crate::disabled_typos_terms::DisabledTyposTerms;
|
use crate::disabled_typos_terms::DisabledTyposTerms;
|
||||||
use crate::error::UserError;
|
use crate::error::UserError::{self, InvalidChatSettingsDocumentTemplateMaxBytes};
|
||||||
use crate::fields_ids_map::metadata::{FieldIdMapWithMetadata, MetadataBuilder};
|
use crate::fields_ids_map::metadata::{FieldIdMapWithMetadata, MetadataBuilder};
|
||||||
use crate::filterable_attributes_rules::match_faceted_field;
|
use crate::filterable_attributes_rules::match_faceted_field;
|
||||||
use crate::index::{
|
use crate::index::{
|
||||||
@ -1249,7 +1249,7 @@ impl<'a, 't, 'i> Settings<'a, 't, 'i> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_chat_config(&mut self) -> heed::Result<bool> {
|
fn update_chat_config(&mut self) -> Result<bool> {
|
||||||
match &mut self.chat {
|
match &mut self.chat {
|
||||||
Setting::Set(ChatSettings {
|
Setting::Set(ChatSettings {
|
||||||
description: new_description,
|
description: new_description,
|
||||||
@ -1273,7 +1273,10 @@ impl<'a, 't, 'i> Settings<'a, 't, 'i> {
|
|||||||
Setting::NotSet => prompt.template.clone(),
|
Setting::NotSet => prompt.template.clone(),
|
||||||
},
|
},
|
||||||
max_bytes: match new_document_template_max_bytes {
|
max_bytes: match new_document_template_max_bytes {
|
||||||
Setting::Set(m) => NonZeroUsize::new(*m),
|
Setting::Set(m) => Some(
|
||||||
|
NonZeroUsize::new(*m)
|
||||||
|
.ok_or(InvalidChatSettingsDocumentTemplateMaxBytes)?,
|
||||||
|
),
|
||||||
Setting::Reset => Some(default_max_bytes()),
|
Setting::Reset => Some(default_max_bytes()),
|
||||||
Setting::NotSet => prompt.max_bytes,
|
Setting::NotSet => prompt.max_bytes,
|
||||||
},
|
},
|
||||||
@ -1347,7 +1350,7 @@ impl<'a, 't, 'i> Settings<'a, 't, 'i> {
|
|||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
Setting::Reset => self.index.delete_chat_config(self.wtxn),
|
Setting::Reset => self.index.delete_chat_config(self.wtxn).map_err(Into::into),
|
||||||
Setting::NotSet => Ok(false),
|
Setting::NotSet => Ok(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user