Skip to content

ChatVertexAI has no property max_tokens. #596

Closed
@daniel-deychakiwsky

Description

@daniel-deychakiwsky

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions