mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 06:33:41 +00:00
add model property
This commit is contained in:
@@ -901,6 +901,10 @@ class BaseChatOpenAI(BaseChatModel):
|
||||
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
@property
|
||||
def model(self) -> str:
|
||||
return self.model_name
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def build_extra(cls, values: dict[str, Any]) -> Any:
|
||||
|
||||
@@ -86,8 +86,10 @@ from langchain_openai.chat_models.base import (
|
||||
def test_openai_model_param() -> None:
|
||||
llm = ChatOpenAI(model="foo")
|
||||
assert llm.model_name == "foo"
|
||||
assert llm.model == "foo"
|
||||
llm = ChatOpenAI(model_name="foo") # type: ignore[call-arg]
|
||||
assert llm.model_name == "foo"
|
||||
assert llm.model == "foo"
|
||||
|
||||
llm = ChatOpenAI(max_tokens=10) # type: ignore[call-arg]
|
||||
assert llm.max_tokens == 10
|
||||
|
||||
Reference in New Issue
Block a user