Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions crates/lingua/src/processing/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,10 +873,7 @@ fn request_model_needs_forced_translation(
override_model: Option<&str>,
target: ProviderFormat,
) -> bool {
if !matches!(
target,
ProviderFormat::ChatCompletions | ProviderFormat::Responses
) {
if target != ProviderFormat::ChatCompletions {
return false;
Comment on lines +876 to 877

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep applying model transforms to Responses requests

For native /v1/responses requests whose model is gpt-5*/reasoning, returning false here allows same-format passthrough before the ResponsesAdapter can run apply_model_transforms (which its own tests require for stripping fields like top_p/temperature). A Responses payload such as {"model":"gpt-5-mini","input":"hi","top_p":0.9} now goes upstream unchanged, while transformed Responses requests still omit that field, so same-format requests can be rejected by the provider for parameters the adapter already knows to remove.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is desired.

}

Expand All @@ -888,8 +885,7 @@ fn request_model_needs_forced_translation(
return true;
}

target == ProviderFormat::ChatCompletions
&& request_model.is_some_and(is_models_prefixed_gemini_model)
request_model.is_some_and(is_models_prefixed_gemini_model)
&& override_model.is_some_and(is_bare_gemini_model)
}

Expand Down Expand Up @@ -2167,7 +2163,7 @@ mod tests {

#[test]
#[cfg(feature = "openai")]
fn test_reasoning_responses_model_forces_translation() {
fn test_reasoning_responses_model_passthrough() {
let payload = json!({
"model": "gpt-5.1-mini",
"input": [{"role": "user", "content": "Hello"}],
Expand All @@ -2178,12 +2174,12 @@ mod tests {
let result = transform_request(input, ProviderFormat::Responses, None).unwrap();

assert!(
!result.is_passthrough(),
"Reasoning Responses models should force translation"
result.is_passthrough(),
"Responses requests should not force same-format translation"
);

let output: Value = crate::serde_json::from_slice(result.as_bytes()).unwrap();
assert!(output.get("top_p").is_none(), "Should not have top_p");
assert_eq!(output.get("top_p").and_then(Value::as_f64), Some(0.9));
}

#[test]
Expand All @@ -2210,8 +2206,8 @@ mod tests {
let result = transform_request(input, ProviderFormat::Responses, None).unwrap();

assert!(
!result.is_passthrough(),
"Reasoning Responses models should force translation"
result.is_passthrough(),
"Responses requests should not force same-format translation"
);

let output: Value = crate::serde_json::from_slice(result.as_bytes()).unwrap();
Expand Down
Loading