From 09085c32e33f8feeaa81c9b612d57ac6e3f4077f Mon Sep 17 00:00:00 2001 From: Shota Terashita Date: Thu, 30 Mar 2023 05:04:44 +0900 Subject: [PATCH] Add `temperature` to ChatOpenAI (#2152) Just add `temperature` parameter to ChatOpenAI class. https://python.langchain.com/en/latest/getting_started/getting_started.html#building-a-language-model-application-chat-models There are descriptions like `chat = ChatOpenAI(temperature=0)` in the documents, but it is confusing because it is not supported as an explicit parameter. --- langchain/chat_models/openai.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/langchain/chat_models/openai.py b/langchain/chat_models/openai.py index df717211..c7ee4bd1 100644 --- a/langchain/chat_models/openai.py +++ b/langchain/chat_models/openai.py @@ -110,6 +110,8 @@ class ChatOpenAI(BaseChatModel, BaseModel): client: Any #: :meta private: model_name: str = "gpt-3.5-turbo" """Model name to use.""" + temperature: float = 0.7 + """What sampling temperature to use.""" model_kwargs: Dict[str, Any] = Field(default_factory=dict) """Holds any model parameters valid for `create` call not explicitly specified.""" openai_api_key: Optional[str] = None