diff --git a/bindings/python/src/pre_tokenizers.rs b/bindings/python/src/pre_tokenizers.rs index ead265c9d..3758bb423 100644 --- a/bindings/python/src/pre_tokenizers.rs +++ b/bindings/python/src/pre_tokenizers.rs @@ -494,30 +494,30 @@ impl PyMetaspace { // Assuming Metaspace has a method to get the prepend_scheme as a string let scheme: PrependScheme = getter!(self_, Metaspace, get_prepend_scheme()); match scheme { - PrependScheme::First => "First", - PrependScheme::Never => "Never", - PrependScheme::Always => "Always", + PrependScheme::First => "first", + PrependScheme::Never => "never", + PrependScheme::Always => "always", } .to_string() } - const UNKNOWN_VARIANT_ERROR_MESSAGE: &str = - "is an unknown variant, should be one of ['First', 'Never', 'Always']"; - #[setter] - fn set_prepend_scheme(self_: PyRef, prepend_scheme: &str) -> PyResult<()> { - // Assuming Metaspace has a method to set the prepend_scheme from a string + from_string(string: String) -> Result{ let scheme = match prepend_scheme { - "First" => PrependScheme::First, - "Never" => PrependScheme::Never, - "Always" => PrependScheme::Always, + "first" => PrependScheme::First, + "never" => PrependScheme::Never, + "always" => PrependScheme::Always, _ => { return Err(exceptions::PyValueError::new_err(format!( - "{} {}", - prepend_scheme, - Self::UNKNOWN_VARIANT_ERROR_MESSAGE, + "{} is an unknown variant, should be one of ['first', 'never', 'always']", ))); } }; + } + + #[setter] + fn set_prepend_scheme(self_: PyRef, prepend_scheme: &str) -> PyResult<()> { + // Assuming Metaspace has a method to set the prepend_scheme from a string + setter!(self_, Metaspace, @set_prepend_scheme, scheme); Ok(()) }