Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Add support for access_token for ChatAnthropic Vertex (code included) #211

Closed
dvideby0 opened this issue May 3, 2024 · 3 comments

Comments

@dvideby0
Copy link
Contributor

dvideby0 commented May 3, 2024

Can you add the access_token parameter to the class and pass it to the Anthropic classes in libs/vertexai/langchain_google_vertexai/model_garden.py

    async_client: Any = None  #: :meta private:
    model_name: Optional[str] = Field(default=None, alias="model")  # type: ignore[assignment]
    "Underlying model name."
    max_output_tokens: int = Field(default=1024, alias="max_tokens")
    access_token: Optional[str] = None

    class Config:
        """Configuration for this pydantic object."""

        allow_population_by_field_name = True

    @root_validator()
    def validate_environment(cls, values: Dict) -> Dict:
        from anthropic import (  # type: ignore[import-not-found]
            AnthropicVertex,
            AsyncAnthropicVertex,
        )

        values["client"] = AnthropicVertex(
            project_id=values["project"],
            region=values["location"],
            max_retries=values["max_retries"],
            access_token=values["access_token"],
        )
        values["async_client"] = AsyncAnthropicVertex(
            project_id=values["project"],
            region=values["location"],
            max_retries=values["max_retries"],
            access_token=values["access_token"],
        )
        return values
@lkuligin
Copy link
Collaborator

lkuligin commented May 4, 2024

@dvideby0 thanks for the feature request and a code sample. Do you mind raising a PR, pleease?

@dvideby0
Copy link
Contributor Author

dvideby0 commented May 5, 2024

PR: #212

@lkuligin
Copy link
Collaborator

lkuligin commented May 7, 2024

thanks a lot for your contribution!

@lkuligin lkuligin closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants