Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
cceeb8e3
Unverified
Commit
cceeb8e3
authored
Dec 30, 2025
by
Neelay Shah
Committed by
GitHub
Dec 31, 2025
Browse files
fix: add chat_template_kwargs alias for compatibility (#5112)
Co-authored-by:
Claude
<
noreply@anthropic.com
>
parent
2fa3627a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
9 deletions
+73
-9
lib/llm/src/http/service/openai.rs
lib/llm/src/http/service/openai.rs
+1
-8
lib/llm/src/protocols/openai/chat_completions.rs
lib/llm/src/protocols/openai/chat_completions.rs
+6
-1
lib/llm/tests/test_chat_template_args.rs
lib/llm/tests/test_chat_template_args.rs
+66
-0
No files found.
lib/llm/src/http/service/openai.rs
View file @
cceeb8e3
...
...
@@ -2191,8 +2191,7 @@ mod tests {
"model": "test-model",
"add_special_tokens": true,
"documents": ["doc1"],
"chat_template": "custom",
"chat_template_kwargs": {"key": "val"}
"chat_template": "custom"
}"#
;
let
request
:
NvCreateChatCompletionRequest
=
serde_json
::
from_str
(
json
)
.unwrap
();
...
...
@@ -2205,11 +2204,6 @@ mod tests {
);
assert
!
(
request
.unsupported_fields
.contains_key
(
"documents"
));
assert
!
(
request
.unsupported_fields
.contains_key
(
"chat_template"
));
assert
!
(
request
.unsupported_fields
.contains_key
(
"chat_template_kwargs"
)
);
let
result
=
validate_chat_completion_fields_generic
(
&
request
);
assert
!
(
result
.is_err
());
...
...
@@ -2221,7 +2215,6 @@ mod tests {
assert
!
(
msg
.contains
(
"add_special_tokens"
));
assert
!
(
msg
.contains
(
"documents"
));
assert
!
(
msg
.contains
(
"chat_template"
));
assert
!
(
msg
.contains
(
"chat_template_kwargs"
));
}
}
...
...
lib/llm/src/protocols/openai/chat_completions.rs
View file @
cceeb8e3
...
...
@@ -44,7 +44,12 @@ pub struct NvCreateChatCompletionRequest {
pub
nvext
:
Option
<
NvExt
>
,
/// Extra args to pass to the chat template rendering context
#[serde(default,
skip_serializing_if
=
"Option::is_none"
)]
/// Also accepts "chat_template_kwargs" as an alias for compatibility
#[serde(
default,
skip_serializing_if
=
"Option::is_none"
,
alias
=
"chat_template_kwargs"
)]
pub
chat_template_args
:
Option
<
std
::
collections
::
HashMap
<
String
,
serde_json
::
Value
>>
,
/// Runtime media decoding parameters.
...
...
lib/llm/tests/test_chat_template_args.rs
0 → 100644
View file @
cceeb8e3
// SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
use
dynamo_llm
::
protocols
::
openai
::
chat_completions
::
NvCreateChatCompletionRequest
;
#[test]
fn
test_both_fields_fails
()
{
// Test that when both are present, serde will fail with duplicate field error
// This test documents that behavior
let
json_with_both
=
r#"{
"model": "test-model",
"messages": [],
"chat_template_args": {
"enable_thinking": true
},
"chat_template_kwargs": {
"enable_thinking": false
}
}"#
;
// This will fail with duplicate field error
let
result
:
Result
<
NvCreateChatCompletionRequest
,
_
>
=
serde_json
::
from_str
(
json_with_both
);
assert
!
(
result
.is_err
());
}
#[test]
fn
test_chat_template_kwargs_alias
()
{
// Test that chat_template_kwargs is accepted as an alias for chat_template_args
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
()
{
// Test that chat_template_args still works as the primary field name
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
))
);
}
// TODO: Add template rendering test that verifies chat_template_args/chat_template_kwargs
// values are actually passed to the Jinja template context during rendering.
// This would require setting up PromptFormatter with ChatTemplate/ContextMixins.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment