add model property

This commit is contained in:
Chester Curme
2026-02-16 16:48:07 -05:00
parent fb0233c9b9
commit 8471175009
2 changed files with 6 additions and 0 deletions

View File

@@ -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:

View File

@@ -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