[router] Support complex assistant and tool messages in /chat/completions (#12860)

Co-authored-by: Chang Su <chang.s.su@oracle.com>
Co-authored-by: Simo Lin <linsimo.mark@gmail.com>
This commit is contained in:
Danylo Vashchilenko
2025-11-12 00:14:15 -08:00
committed by GitHub
co-authored by Chang Su Simo Lin
parent ad8d24c39e
commit d28caaf60a
13 changed files with 127 additions and 104 deletions
@@ -1,5 +1,5 @@
use sglang_router_rs::{
protocols::chat::{ChatMessage, UserMessageContent},
protocols::chat::{ChatMessage, MessageContent},
tokenizer::chat_template::{
detect_chat_template_content_format, ChatTemplateContentFormat, ChatTemplateParams,
ChatTemplateProcessor,
@@ -176,11 +176,11 @@ assistant:
let messages = [
ChatMessage::System {
content: "You are helpful".to_string(),
content: MessageContent::Text("You are helpful".to_string()),
name: None,
},
ChatMessage::User {
content: UserMessageContent::Text("Hello".to_string()),
content: MessageContent::Text("Hello".to_string()),
name: None,
},
];
@@ -216,7 +216,7 @@ fn test_chat_template_with_tokens_unit_test() {
let processor = ChatTemplateProcessor::new(template.to_string());
let messages = [ChatMessage::User {
content: UserMessageContent::Text("Test".to_string()),
content: MessageContent::Text("Test".to_string()),
name: None,
}];