wip - preparing for o1 models
This commit is contained in:
parent
281abdf01b
commit
62957e80ca
1 changed files with 13 additions and 9 deletions
|
|
@ -254,6 +254,13 @@ class OpenAILanguageModel(LanguageModel):
|
|||
"""
|
||||
Convert the language model to a LangChain chat model.
|
||||
"""
|
||||
|
||||
data = {
|
||||
"model": self.model_name,
|
||||
"top_p": self.top_p,
|
||||
"temperature": self.temperature,
|
||||
}
|
||||
|
||||
kwargs = self.kwargs.copy() # Make a copy to avoid modifying the original
|
||||
if self.json:
|
||||
kwargs["response_format"] = {"type": "json_object"}
|
||||
|
|
@ -261,17 +268,14 @@ class OpenAILanguageModel(LanguageModel):
|
|||
# Set the token limit in kwargs with the appropriate key
|
||||
if self.model_name in ["o1-mini", "o1-preview"]:
|
||||
kwargs["max_completion_tokens"] = self.max_tokens
|
||||
top_p = 1
|
||||
streaming = False
|
||||
data["top_p"] = 1
|
||||
data["streaming"] = False
|
||||
else:
|
||||
kwargs["max_tokens"] = self.max_tokens
|
||||
top_p = self.top_p
|
||||
streaming = self.streaming
|
||||
data["max_tokens"] = self.max_tokens
|
||||
data["top_p"] = self.top_p
|
||||
data["streaming"] = self.streaming
|
||||
|
||||
return ChatOpenAI(
|
||||
model=self.model_name,
|
||||
temperature=self.temperature or 0.5,
|
||||
**data,
|
||||
model_kwargs=kwargs,
|
||||
streaming=streaming,
|
||||
top_p=top_p,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue