mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-01 20:49:17 +00:00
x
This commit is contained in:
parent
3b441f312a
commit
07b1ccb230
@ -440,7 +440,7 @@ class BaseChatOpenAI(BaseChatModel):
|
|||||||
async_client: Any = Field(default=None, exclude=True) #: :meta private:
|
async_client: Any = Field(default=None, exclude=True) #: :meta private:
|
||||||
root_client: Any = Field(default=None, exclude=True) #: :meta private:
|
root_client: Any = Field(default=None, exclude=True) #: :meta private:
|
||||||
root_async_client: Any = Field(default=None, exclude=True) #: :meta private:
|
root_async_client: Any = Field(default=None, exclude=True) #: :meta private:
|
||||||
model_name: str = Field(default="gpt-3.5-turbo", alias="model")
|
model: str = Field(default="gpt-3.5-turbo", alias="model_name")
|
||||||
"""Model name to use."""
|
"""Model name to use."""
|
||||||
temperature: Optional[float] = None
|
temperature: Optional[float] = None
|
||||||
"""What sampling temperature to use."""
|
"""What sampling temperature to use."""
|
||||||
@ -545,6 +545,10 @@ class BaseChatOpenAI(BaseChatModel):
|
|||||||
|
|
||||||
model_config = ConfigDict(populate_by_name=True)
|
model_config = ConfigDict(populate_by_name=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def model_name(self) -> str:
|
||||||
|
return self.model
|
||||||
|
|
||||||
@model_validator(mode="before")
|
@model_validator(mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def build_extra(cls, values: Dict[str, Any]) -> Any:
|
def build_extra(cls, values: Dict[str, Any]) -> Any:
|
||||||
|
@ -534,6 +534,22 @@ class ChatModelUnitTests(ChatModelTests):
|
|||||||
If this test fails, ensure that the model can be initialized with a
|
If this test fails, ensure that the model can be initialized with a
|
||||||
``model`` parameter, and that the model parameter can be accessed as
|
``model`` parameter, and that the model parameter can be accessed as
|
||||||
``.model``.
|
``.model``.
|
||||||
|
|
||||||
|
If not, the easiest way to configure this is likely to add
|
||||||
|
``from pydantic import ConfigDict`` at the top of your file, and add a
|
||||||
|
``model_config`` class attribute to your model class:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
class MyChatModel(BaseChatModel):
|
||||||
|
model: str = Field(alias="model_name")
|
||||||
|
model_config = ConfigDict(populate_by_name=True)
|
||||||
|
|
||||||
|
# optional property for backwards-compatibility
|
||||||
|
# for folks accessing chat_model.model_name
|
||||||
|
@property
|
||||||
|
def model_name(self) -> str:
|
||||||
|
return self.model
|
||||||
"""
|
"""
|
||||||
params = {
|
params = {
|
||||||
**self.standard_chat_model_params,
|
**self.standard_chat_model_params,
|
||||||
|
Loading…
Reference in New Issue
Block a user