From 6568ca6e074cb286a5d41fd2f308e5c5a6ef5063 Mon Sep 17 00:00:00 2001 From: kubmichael <102899381+kubmichael@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:32:06 +0200 Subject: [PATCH 1/2] Fixing invalid_scope: Invalid OAuth scope or ID token audience provided (#618) --- .../langchain_google_vertexai/model_garden_maas/_base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/vertexai/langchain_google_vertexai/model_garden_maas/_base.py b/libs/vertexai/langchain_google_vertexai/model_garden_maas/_base.py index 256c5d1f1..ffc807228 100644 --- a/libs/vertexai/langchain_google_vertexai/model_garden_maas/_base.py +++ b/libs/vertexai/langchain_google_vertexai/model_garden_maas/_base.py @@ -44,7 +44,11 @@ def _get_token(credentials: Optional[Credentials] = None) -> str: """Returns a valid token for GCP auth.""" - credentials = auth.default()[0] if not credentials else credentials + credentials = ( + auth.default(scopes=["https://www.googleapis.com/auth/cloud-platform"])[0] + if not credentials + else credentials + ) request = auth_requests.Request() credentials.refresh(request) if not credentials.token: From 019d57874966e6d8692dd1d321d9c7f721eec4ea Mon Sep 17 00:00:00 2001 From: Yelin Zhang <30687616+Yelinz@users.noreply.github.com> Date: Tue, 3 Dec 2024 07:45:16 +0100 Subject: [PATCH 2/2] docs: fix google_genai typos (#614) Co-authored-by: Leonid Kuligin --- libs/genai/langchain_google_genai/chat_models.py | 6 +++--- libs/genai/langchain_google_genai/embeddings.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/genai/langchain_google_genai/chat_models.py b/libs/genai/langchain_google_genai/chat_models.py index 91a1cfa81..45ad1cec4 100644 --- a/libs/genai/langchain_google_genai/chat_models.py +++ b/libs/genai/langchain_google_genai/chat_models.py @@ -579,9 +579,9 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel): Instantiation: To use, you must have either: - 1. The ``GOOGLE_API_KEY``` environment variable set with your API key, or - 2. Pass your API key using the google_api_key kwarg to the ChatGoogle - constructor. + 1. The ``GOOGLE_API_KEY`` environment variable set with your API key, or + 2. Pass your API key using the google_api_key kwarg + to the ChatGoogleGenerativeAI constructor. .. code-block:: python diff --git a/libs/genai/langchain_google_genai/embeddings.py b/libs/genai/langchain_google_genai/embeddings.py index a920c7ffc..b79b95eb7 100644 --- a/libs/genai/langchain_google_genai/embeddings.py +++ b/libs/genai/langchain_google_genai/embeddings.py @@ -27,9 +27,9 @@ class GoogleGenerativeAIEmbeddings(BaseModel, Embeddings): To use, you must have either: - 1. The ``GOOGLE_API_KEY``` environment variable set with your API key, or - 2. Pass your API key using the google_api_key kwarg to the ChatGoogle - constructor. + 1. The ``GOOGLE_API_KEY`` environment variable set with your API key, or + 2. Pass your API key using the google_api_key kwarg + to the GoogleGenerativeAIEmbeddings constructor. Example: .. code-block:: python