fix(openai): add model property (#35284)

This commit is contained in:
ccurme
2026-02-17 10:46:49 -05:00
committed by GitHub
parent 4150bb513f
commit 32c6ab3033
2 changed files with 7 additions and 0 deletions

View File

@@ -901,6 +901,11 @@ class BaseChatOpenAI(BaseChatModel):
model_config = ConfigDict(populate_by_name=True)
@property
def model(self) -> str:
"""Same as model_name."""
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