langchain-ai / langchain-google

MIT License
117 stars 147 forks source link

ChatVertexAI has no property max_tokens. #596

Open daniel-deychakiwsky opened 1 week ago

daniel-deychakiwsky commented 1 week ago

ChatVertexAI inherits from BaseChatModel which accepts a standard property, max_tokens, from the documentation.

When initializing a ChatVertexAI instance with this standard property, it is not available on the instance and throws an error upon accessing. It is instead available under max_output_tokens.

It should be made available on the instance as the other chat model integrations (ChatOpenAI, ChatAnthropic, ...) all have this property available on the instance.

model = ChatVertexAI(
    model="gemini-1.5-pro-002",
    temperature=0.0,
    max_tokens=500,
    top_p=1.0,
)

print(model.max_output_tokens)  # 500
print(model.max_tokens).  # AttributeError: 'ChatVertexAI' object has no attribute 'max_tokens'

LangChain package versions:

langchain-core==0.3.15 langchain-google-vertexai==2.0.7

lkuligin commented 2 days ago

good point, would you be open to send a PR (please, create an alias for the pydantic field - in the same way we do it for model/model_name).