mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-28 18:48:50 +00:00
added interactive login for azure cognitive search vector store (#11360)
**Description:** Previously if the access to Azure Cognitive Search was not done via an API key, the default credential was called which doesn't allow to use an interactive login. I simply added the option to use "INTERACTIVE" as a key name, and this will launch a login window upon initialization of the AzureSearch object.
This commit is contained in:
parent
53d4f1554a
commit
ca346011b7
@ -77,7 +77,7 @@ def _get_search_client(
|
||||
) -> SearchClient:
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
from azure.core.exceptions import ResourceNotFoundError
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
|
||||
from azure.search.documents import SearchClient
|
||||
from azure.search.documents.indexes import SearchIndexClient
|
||||
from azure.search.documents.indexes.models import (
|
||||
@ -93,6 +93,9 @@ def _get_search_client(
|
||||
default_fields = default_fields or []
|
||||
if key is None:
|
||||
credential = DefaultAzureCredential()
|
||||
elif key.upper() == "INTERACTIVE":
|
||||
credential = InteractiveBrowserCredential()
|
||||
credential.get_token("https://search.azure.com/.default")
|
||||
else:
|
||||
credential = AzureKeyCredential(key)
|
||||
index_client: SearchIndexClient = SearchIndexClient(
|
||||
|
Loading…
Reference in New Issue
Block a user