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
21 changes: 18 additions & 3 deletions crates/lingua/src/providers/openai/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const MODEL_TRANSFORM_RULES: &[(&str, &[ModelTransform])] = &[
"gpt-5",
&[StripTemperature, StripTopP, ForceMaxCompletionTokens],
),
(
"gpt-6",
&[StripTemperature, StripTopP, ForceMaxCompletionTokens],
),
// TODO: would be nice if we could apply these rules by provider instead of model name, and
// apply these to all Mistral models
("mistral", &[ForceMaxTokens]),
Expand All @@ -58,9 +62,9 @@ const MODEL_TRANSFORM_RULES: &[(&str, &[ModelTransform])] = &[

/// Get the transforms required for a model.
pub fn get_model_transforms(model: &str) -> &'static [ModelTransform] {
let lower = model.to_ascii_lowercase();
let normalized = normalize_openai_model_name(model);
for (prefix, transforms) in MODEL_TRANSFORM_RULES {
if lower.starts_with(prefix) {
if normalized.starts_with(prefix) {
return transforms;
}
}
Expand Down Expand Up @@ -155,7 +159,10 @@ impl EffortFamily {

fn normalize_openai_model_name(model: &str) -> String {
let lower = model.to_ascii_lowercase();
if let Some(stripped) = lower.strip_prefix("openai/") {
if let Some(stripped) = lower
.strip_prefix("openai/")
.or_else(|| lower.strip_prefix("openai."))
{
stripped.to_string()
} else {
lower
Expand Down Expand Up @@ -368,6 +375,14 @@ mod tests {
"gpt-5-mini",
&[StripTemperature, StripTopP, ForceMaxCompletionTokens][..],
),
(
"openai.gpt-6-astra",
&[StripTemperature, StripTopP, ForceMaxCompletionTokens][..],
),
(
"openai/gpt-6-astra",
&[StripTemperature, StripTopP, ForceMaxCompletionTokens][..],
),
("gpt-4", &[][..]),
("gpt-4o", &[][..]),
("claude-3", &[][..]),
Expand Down
Loading