From 8b03cd087f5dc4da09d24766e6f0e6502c3780f0 Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 14 Feb 2025 19:21:41 +0800 Subject: feat: add patch `max_tokens: null` to openai/github o* serial models (#1174) --- models.yaml | 8 ++++++++ src/client/openai.rs | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/models.yaml b/models.yaml index 547081e..c79bc99 100644 --- a/models.yaml +++ b/models.yaml @@ -41,6 +41,7 @@ system_prompt_prefix: Formatting re-enabled patch: body: + max_tokens: null temperature: null top_p: null - name: o1 @@ -52,6 +53,7 @@ system_prompt_prefix: Formatting re-enabled patch: body: + max_tokens: null temperature: null top_p: null - name: o1-preview @@ -62,6 +64,7 @@ no_system_message: true patch: body: + max_tokens: null temperature: null top_p: null - name: o1-mini @@ -72,6 +75,7 @@ no_system_message: true patch: body: + max_tokens: null temperature: null top_p: null - name: gpt-3.5-turbo @@ -1469,6 +1473,7 @@ system_prompt_prefix: Formatting re-enabled patch: body: + max_tokens: null temperature: null top_p: null - name: o1 @@ -1478,6 +1483,7 @@ system_prompt_prefix: Formatting re-enabled patch: body: + max_tokens: null temperature: null top_p: null - name: o1-preview @@ -1486,6 +1492,7 @@ no_system_message: true patch: body: + max_tokens: null temperature: null top_p: null - name: o1-mini @@ -1494,6 +1501,7 @@ no_system_message: true patch: body: + max_tokens: null temperature: null top_p: null - name: text-embedding-3-large diff --git a/src/client/openai.rs b/src/client/openai.rs index 6d57d42..26c2dd3 100644 --- a/src/client/openai.rs +++ b/src/client/openai.rs @@ -299,7 +299,11 @@ pub fn openai_build_chat_completions_body(data: ChatCompletionsData, model: &Mod }); if let Some(v) = model.max_tokens_param() { - body["max_tokens"] = v.into(); + if model.patch().and_then(|v| v.get("body").and_then(|v| v.get("max_tokens"))) == Some(&Value::Null) { + body["max_completion_tokens"] = v.into(); + } else { + body["max_tokens"] = v.into(); + } } if let Some(v) = temperature { body["temperature"] = v.into(); -- cgit v1.2.3