From ebab2ea81ba265f95b97b75bb2eefe3cc0afe9c9 Mon Sep 17 00:00:00 2001 From: Ana Date: Mon, 16 Dec 2024 23:52:24 +0530 Subject: [PATCH] Fix Azure National Cloud authentication using token (RBAC) (Generated by Ana - AI SDE) (#25843) This pull request addresses the issue with authenticating Azure National Cloud using token (RBAC) in the AzureSearch vectorstore implementation. ## Changes - Modified the `_get_search_client` method in `azuresearch.py` to pass `additional_search_client_options` to the `SearchIndexClient` instance. ## Implementation Details The patch updates the `SearchIndexClient` initialization to include the `additional_search_client_options` parameter: ```python index_client: SearchIndexClient = SearchIndexClient( endpoint=endpoint, credential=credential, user_agent=user_agent, **additional_search_client_options ) ``` This change allows the `audience` parameter to be correctly passed when using Azure National Cloud, fixing the authentication issues with GovCloud & RBAC. This patch was generated by [Ana - AI SDE](https://openana.ai/), an AI-powered software development assistant. This is a fix for [Issue 25823](https://github.com/langchain-ai/langchain/issues/25823) --------- Co-authored-by: ccurme --- .../langchain_community/vectorstores/azuresearch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py index 6748f81dc2529..6930c8319e4d9 100644 --- a/libs/community/langchain_community/vectorstores/azuresearch.py +++ b/libs/community/langchain_community/vectorstores/azuresearch.py @@ -150,7 +150,10 @@ def get_token( else: credential = DefaultAzureCredential() index_client: SearchIndexClient = SearchIndexClient( - endpoint=endpoint, credential=credential, user_agent=user_agent + endpoint=endpoint, + credential=credential, + user_agent=user_agent, + **additional_search_client_options, ) try: index_client.get_index(name=index_name)