diff --git a/crates/tabby-common/src/languages.rs b/crates/tabby-common/src/languages.rs index b5f9c8b..c6f177c 100644 --- a/crates/tabby-common/src/languages.rs +++ b/crates/tabby-common/src/languages.rs @@ -36,6 +36,11 @@ pub struct Language { impl Language { pub fn get_stop_words(&self) -> Vec { + // Special handling for empty languages - returns empty stop words. + if self.get_hashkey() == "empty" { + return vec![]; + } + let mut out = vec![]; out.push(format!("\n{}", self.line_comment)); for word in &self.top_level_keywords { @@ -62,6 +67,11 @@ lazy_static! { line_comment: "".to_owned(), top_level_keywords: vec![], }; + pub static ref EMPTY_LANGUAGE: Language = Language { + languages: vec!["empty".to_owned()], + line_comment: "".to_owned(), + top_level_keywords: vec![], + }; } pub fn get_language(language: &str) -> &'static Language { @@ -71,3 +81,10 @@ pub fn get_language(language: &str) -> &'static Language { .find(|c| c.languages.iter().any(|x| x == language)) .unwrap_or(&UNKNOWN_LANGUAGE) } + +mod tests { + #[test] + fn test_empty_language() { + assert!(super::EMPTY_LANGUAGE.get_stop_words().is_empty()) + } +} diff --git a/crates/tabby/src/serve/chat.rs b/crates/tabby/src/serve/chat.rs index 9bd98d1..2fb62a2 100644 --- a/crates/tabby/src/serve/chat.rs +++ b/crates/tabby/src/serve/chat.rs @@ -11,6 +11,7 @@ use axum::{ use axum_streams::StreamBodyAs; use prompt::ChatPromptBuilder; use serde::{Deserialize, Serialize}; +use tabby_common::languages::EMPTY_LANGUAGE; use tabby_inference::{TextGeneration, TextGenerationOptions, TextGenerationOptionsBuilder}; use tracing::{debug, instrument}; use utoipa::ToSchema; @@ -88,6 +89,7 @@ fn parse_request( builder .max_input_length(2048) .max_decoding_length(1920) + .language(&EMPTY_LANGUAGE) .sampling_temperature(0.1); (