fix: chat completions should use empty stop words (#626)
parent
2a40d36e20
commit
4c6f4b159a
|
|
@ -36,6 +36,11 @@ pub struct Language {
|
|||
|
||||
impl Language {
|
||||
pub fn get_stop_words(&self) -> Vec<String> {
|
||||
// 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())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
(
|
||||
|
|
|
|||
Loading…
Reference in New Issue