@@ -265,15 +265,27 @@ def get_conversation_logger(self):
265
265
),
266
266
]
267
267
268
- return AzureSearch (
269
- azure_search_endpoint = self .env_helper .AZURE_SEARCH_SERVICE ,
270
- azure_search_key = (
271
- self .env_helper .AZURE_SEARCH_KEY
272
- if self .env_helper .is_auth_type_keys ()
273
- else None
274
- ),
275
- index_name = self .env_helper .AZURE_SEARCH_CONVERSATIONS_LOG_INDEX ,
276
- embedding_function = self .llm_helper .get_embedding_model ().embed_query ,
277
- fields = fields ,
278
- user_agent = "langchain chatwithyourdata-sa" ,
279
- )
268
+ if self .env_helper .AZURE_AUTH_TYPE == "rbac" :
269
+ credential = DefaultAzureCredential ()
270
+ return AzureSearch (
271
+ azure_search_endpoint = self .env_helper .AZURE_SEARCH_SERVICE ,
272
+ azure_search_key = None , # Remove API key
273
+ index_name = self .env_helper .AZURE_SEARCH_CONVERSATIONS_LOG_INDEX ,
274
+ embedding_function = self .llm_helper .get_embedding_model ().embed_query ,
275
+ fields = fields ,
276
+ user_agent = "langchain chatwithyourdata-sa" ,
277
+ credential = credential # Add token credential or send none so it is auto handled by AzureSearch library
278
+ )
279
+ else :
280
+ return AzureSearch (
281
+ azure_search_endpoint = self .env_helper .AZURE_SEARCH_SERVICE ,
282
+ azure_search_key = (
283
+ self .env_helper .AZURE_SEARCH_KEY
284
+ if self .env_helper .is_auth_type_keys ()
285
+ else None
286
+ ),
287
+ index_name = self .env_helper .AZURE_SEARCH_CONVERSATIONS_LOG_INDEX ,
288
+ embedding_function = self .llm_helper .get_embedding_model ().embed_query ,
289
+ fields = fields ,
290
+ user_agent = "langchain chatwithyourdata-sa" ,
291
+ )
0 commit comments