langchain-ai / langchain-google

MIT License
76 stars 79 forks source link

ChatAnthropicVertex param `credentials` appears to to not work. #210

Closed dvideby0 closed 2 months ago

dvideby0 commented 2 months ago

It appears that credentials are not passed/working when using ChatAnthropicVertex. They appear to work correctly with ChatVertexAI.

Working code

    encoded_json_credentials = get_secret("GOOGLE_VERTEX_SERVICE_ACCOUNT_CREDENTIALS")
    decoded_json_credentials = json.loads(base64.b64decode(encoded_json_credentials).decode("utf-8"))
    credentials = service_account.Credentials.from_service_account_info(decoded_json_credentials)
    return ChatVertexAI(
        model=model,
        location="us-central1",
        credentials=credentials,
        project=get_secret("GOOGLE_VERTEX_PROJECT_ID"),
        **kwargs
    )

Not working code

    encoded_json_credentials = get_secret("GOOGLE_VERTEX_SERVICE_ACCOUNT_CREDENTIALS")
    decoded_json_credentials = json.loads(base64.b64decode(encoded_json_credentials).decode("utf-8"))
    credentials = service_account.Credentials.from_service_account_info(decoded_json_credentials)
    return ChatAnthropicVertex(
        model=model,
        location="us-central1",
        credentials=credentials,
        project=get_secret("GOOGLE_VERTEX_PROJECT_ID"),
        **kwargs
    )

The following error message occurs when trying to use ChatAnthropicVertex


ERROR:root:Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.