Skip to content

Commit

Permalink
feat: add google credential support to ChatAnthropicVertex (langchain…
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaray-deshaw authored Jul 18, 2024
1 parent edae166 commit 429f5cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions libs/vertexai/langchain_google_vertexai/model_garden.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
Union,
)

from google.auth.credentials import Credentials
from langchain_core.callbacks.manager import (
AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun,
Expand Down Expand Up @@ -134,6 +135,7 @@ class ChatAnthropicVertex(_VertexAICommon, BaseChatModel):
max_output_tokens: int = Field(default=1024, alias="max_tokens")
access_token: Optional[str] = None
stream_usage: bool = True # Whether to include usage metadata in streaming output
credentials: Optional[Credentials] = None

class Config:
"""Configuration for this pydantic object."""
Expand All @@ -156,12 +158,14 @@ def validate_environment(cls, values: Dict) -> Dict:
region=values["location"],
max_retries=values["max_retries"],
access_token=values["access_token"],
credentials=values["credentials"],
)
values["async_client"] = AsyncAnthropicVertex(
project_id=values["project"],
region=values["location"],
max_retries=values["max_retries"],
access_token=values["access_token"],
credentials=values["credentials"],
)
return values

Expand Down
11 changes: 6 additions & 5 deletions libs/vertexai/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/vertexai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ langchain-core = ">=0.2.9,<0.3"
google-cloud-aiplatform = "^1.56.0"
google-cloud-storage = "^2.17.0"
# optional dependencies
anthropic = { extras = ["vertexai"], version = ">=0.29.0,<1", optional = true }
anthropic = { extras = ["vertexai"], version = ">=0.30.0,<1", optional = true }

[tool.poetry.group.test]
optional = true
Expand Down

0 comments on commit 429f5cf

Please sign in to comment.