use dynamo_llm::protocols::openai::chat_completions::NvCreateChatCompletionRequest;
#[test]
fn test_both_fields_fails() {
let json_with_both = r#"{
"model": "test-model",
"messages": [],
"chat_template_args": {
"enable_thinking": true
},
"chat_template_kwargs": {
"enable_thinking": false
}
}"#;
let result: Result<NvCreateChatCompletionRequest, _> = serde_json::from_str(json_with_both);
assert!(result.is_err());
}
#[test]
fn test_chat_template_kwargs_alias() {
let json_with_kwargs = r#"{
"model": "test-model",
"messages": [],
"chat_template_kwargs": {
"enable_thinking": false
}
}"#;
let request: NvCreateChatCompletionRequest = serde_json::from_str(json_with_kwargs).unwrap();
assert!(request.chat_template_args.is_some());
assert_eq!(
request.chat_template_args.unwrap().get("enable_thinking"),
Some(&serde_json::json!(false))
);
}
#[test]
fn test_chat_template_args() {
let json_with_args = r#"{
"model": "test-model",
"messages": [],
"chat_template_args": {
"enable_thinking": true
}
}"#;
let request: NvCreateChatCompletionRequest = serde_json::from_str(json_with_args).unwrap();
assert!(request.chat_template_args.is_some());
assert_eq!(
request.chat_template_args.unwrap().get("enable_thinking"),
Some(&serde_json::json!(true))
);
}