[Bugfix][Rust Frontend] Omit unset sampling params in render output (#61220)

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
This commit is contained in:
Martin Hickey
2026-10-12 19:31:03 +00:00
committed by GitHub
parent 1bdd3fa2d5
commit 7039c7f17b
3 changed files with 71 additions and 0 deletions
+34
View File
@@ -1374,6 +1374,40 @@ async fn render_chat_returns_generate_request_with_header_request_id() {
assert!(json.get("mm_features").is_none());
}
#[tokio::test]
async fn render_chat_omits_unset_sampling_params() {
let mut app = test_render_app();
let response = app
.call(
Request::builder()
.method("POST")
.uri("/v1/chat/completions/render")
.header("content-type", "application/json")
.body(Body::from(
json!({
"model": "render-model",
"messages": [{"role": "user", "content": "hello"}],
"max_completion_tokens": 8
})
.to_string(),
))
.expect("build request"),
)
.await
.expect("call app");
assert_eq!(response.status(), StatusCode::OK);
let body = to_bytes(response.into_body(), usize::MAX).await.expect("read body");
let json: serde_json::Value = serde_json::from_slice(&body).expect("decode json");
let sampling_params = json["sampling_params"].as_object().expect("sampling_params object");
assert!(
sampling_params.values().all(|value| !value.is_null()),
"unexpected null in {sampling_params:?}"
);
assert_eq!(sampling_params["max_tokens"], 8);
}
#[tokio::test]
async fn render_chat_uses_processor_owned_parser_selections() {
let mut app = test_render_app_with_parser_selections(