Add support for OpenAI API o1 model (#3363)

Co-authored-by: Shan Yu <shanyu1@g.ucla.edu>
This commit is contained in:
Chuyue Sun
2025-02-14 11:43:00 +08:00
committed by GitHub
co-authored by Shan Yu
parent 31eec35ba8
commit 6cc309557a
3 changed files with 63 additions and 0 deletions
+5
View File
@@ -161,6 +161,10 @@ class OpenAI(BaseBackend):
prompt = s.text_
kwargs = sampling_params.to_openai_kwargs()
if self.model_name.startswith("o1") or self.model_name.startswith("o3"):
kwargs.pop("max_tokens", None)
else:
kwargs.pop("max_completion_tokens", None)
comp = openai_completion(
client=self.client,
token_usage=self.token_usage,
@@ -175,6 +179,7 @@ class OpenAI(BaseBackend):
), "constrained type not supported on chat model"
kwargs = sampling_params.to_openai_kwargs()
kwargs.pop("stop")
comp = openai_completion(
client=self.client,
token_usage=self.token_usage,