feat: use GGUF chat template via apply_chat_template

- Replaced manual prompt building with LlamaModel::apply_chat_template
- Uses model's baked-in Jinja template (system/user/assistant/tool format)
- Added <think> trigger after template for thinking mode
- Clean_text strips only <|im_end|>, <|im_start|>, <think>, </think>
This commit is contained in:
Asep Haryana
2026-07-26 17:10:42 +07:00
parent 59c77108a5
commit 9a63ff1601
2 changed files with 58 additions and 99 deletions
+2 -1
View File
@@ -26,7 +26,8 @@ pub async fn chat_completions(
) -> Result<Response, AppError> {
let max_tokens = req.max_tokens.unwrap_or(256).min(1024);
let stop = req.stop.clone().unwrap_or_default();
let prompt = chat::build_prompt(&req.messages, &req.tools);
let prompt = chat::build_prompt(&state.engine.model, &req.messages, &req.tools)
.map_err(|e| AppError::LlmError(e))?;
// Tokenize
let input_tokens = state