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) --- src/client/openai.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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