server: add gpt-oss chat template for proper prompt formatting

The gpt-oss model requires a specific prompt format with <|start|>,
<|message|>, <|end|>, <|channel|> tokens. Without this, the model
produces degenerate output. Auto-detected via config.model_type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gahow Wang
2026-05-30 15:43:29 +08:00
parent 15c51f143e
commit 5cb3cf28f9
2 changed files with 35 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ use xserv_model::ModelConfig;
pub struct AppState {
pub model_name: String,
pub model_type: String,
pub engine_sender: Mutex<mpsc::Sender<GenerateRequest>>,
pub engine_tokenizer: Mutex<xserv_tokenizer::Tokenizer>,
pub max_seq_len: usize,
@@ -99,8 +100,10 @@ async fn main() {
}
});
let model_type = model_config.model_type.clone().unwrap_or_default();
let state = Arc::new(AppState {
model_name,
model_type,
engine_sender: Mutex::new(tx),
engine_tokenizer: Mutex::new(tokenizer),
max_seq_len,