Skip to content

Commit

Permalink
Added support for max_tokens attribute in ChatVertexAI (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
SauravP97 authored Jan 28, 2025
1 parent 106872f commit c3d4061
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libs/vertexai/langchain_google_vertexai/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ def _is_gemini_model(self) -> bool:
def _llm_type(self) -> str:
return "vertexai"

@property
def max_tokens(self) -> int | None:
return self.max_output_tokens

@property
def _identifying_params(self) -> Dict[str, Any]:
"""Gets the identifying parameters."""
Expand Down
3 changes: 3 additions & 0 deletions libs/vertexai/tests/unit_tests/test_chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@ def test_tuned_model_name() -> None:
model_name="gemini-pro",
project="test-project",
tuned_model_name="projects/123/locations/europe-west4/endpoints/456",
max_tokens=500,
)
assert llm.model_name == "gemini-pro"
assert llm.tuned_model_name == "projects/123/locations/europe-west4/endpoints/456"
assert llm.full_model_name == "projects/123/locations/europe-west4/endpoints/456"
assert llm.max_output_tokens == 500
assert llm.max_tokens == 500


def test_parse_examples_correct() -> None:
Expand Down

0 comments on commit c3d4061

Please sign in to comment.