summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2025-02-14 19:21:41 +0800
committerGitHub <noreply@github.com>2025-02-14 19:21:41 +0800
commit8b03cd087f5dc4da09d24766e6f0e6502c3780f0 (patch)
tree9dbd5ea263c6c59c3d203e18c65b3049bd8bcddc
parentebcf99f1d7ded70823ee8144f70e93f67b25129e (diff)
downloadaichat-8b03cd087f5dc4da09d24766e6f0e6502c3780f0.tar.gz
feat: add patch `max_tokens: null` to openai/github o* serial models (#1174)
-rw-r--r--models.yaml8
-rw-r--r--src/client/openai.rs6
2 files changed, 13 insertions, 1 deletions
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();