diff --git a/code/backend/batch/utilities/helpers/azure_search_helper.py b/code/backend/batch/utilities/helpers/azure_search_helper.py index e6a7e94dd..140214fb6 100644 --- a/code/backend/batch/utilities/helpers/azure_search_helper.py +++ b/code/backend/batch/utilities/helpers/azure_search_helper.py @@ -265,15 +265,24 @@ def get_conversation_logger(self): ), ] - return AzureSearch( - azure_search_endpoint=self.env_helper.AZURE_SEARCH_SERVICE, - azure_search_key=( - self.env_helper.AZURE_SEARCH_KEY - if self.env_helper.is_auth_type_keys() - else None - ), - index_name=self.env_helper.AZURE_SEARCH_CONVERSATIONS_LOG_INDEX, - embedding_function=self.llm_helper.get_embedding_model().embed_query, - fields=fields, - user_agent="langchain chatwithyourdata-sa", - ) + if self.env_helper.AZURE_AUTH_TYPE == "rbac": + return SearchIndexClient( + endpoint=self.env_helper.AZURE_SEARCH_SERVICE, + index_name=self.env_helper.AZURE_SEARCH_CONVERSATIONS_LOG_INDEX, + credential=self._search_credential(), + ).get_search_client( + index_name=self.env_helper.AZURE_SEARCH_CONVERSATIONS_LOG_INDEX + ) + else: + return AzureSearch( + azure_search_endpoint=self.env_helper.AZURE_SEARCH_SERVICE, + azure_search_key=( + self.env_helper.AZURE_SEARCH_KEY + if self.env_helper.is_auth_type_keys() + else None + ), + index_name=self.env_helper.AZURE_SEARCH_CONVERSATIONS_LOG_INDEX, + embedding_function=self.llm_helper.get_embedding_model().embed_query, + fields=fields, + user_agent="langchain chatwithyourdata-sa", + )