From 667ad6a5def90421fd036078578b869a26b0d0e3 Mon Sep 17 00:00:00 2001 From: Jarkko Lagus Date: Wed, 6 Dec 2023 02:05:40 +0200 Subject: [PATCH] Add support for CORS options for AzureSearch (#14305) - **Description:** Add support for setting the CORS options when using AzureSearch indexes --- libs/langchain/langchain/vectorstores/azuresearch.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/langchain/langchain/vectorstores/azuresearch.py b/libs/langchain/langchain/vectorstores/azuresearch.py index b818dc71fd59a..a0e48741c1abf 100644 --- a/libs/langchain/langchain/vectorstores/azuresearch.py +++ b/libs/langchain/langchain/vectorstores/azuresearch.py @@ -35,6 +35,7 @@ if TYPE_CHECKING: from azure.search.documents import SearchClient from azure.search.documents.indexes.models import ( + CorsOptions, ScoringProfile, SearchField, VectorSearch, @@ -78,6 +79,7 @@ def _get_search_client( default_scoring_profile: Optional[str] = None, default_fields: Optional[List[SearchField]] = None, user_agent: Optional[str] = "langchain", + cors_options: Optional[CorsOptions] = None, ) -> SearchClient: from azure.core.credentials import AzureKeyCredential from azure.core.exceptions import ResourceNotFoundError @@ -227,6 +229,7 @@ def fmt_err(x: str) -> str: semantic_settings=semantic_settings, scoring_profiles=scoring_profiles, default_scoring_profile=default_scoring_profile, + cors_options=cors_options, ) index_client.create_index(index) # Create the search client @@ -255,6 +258,7 @@ def __init__( semantic_settings: Optional[Union[SemanticSearch, SemanticSettings]] = None, scoring_profiles: Optional[List[ScoringProfile]] = None, default_scoring_profile: Optional[str] = None, + cors_options: Optional[CorsOptions] = None, **kwargs: Any, ): from azure.search.documents.indexes.models import ( @@ -305,6 +309,7 @@ def __init__( default_scoring_profile=default_scoring_profile, default_fields=default_fields, user_agent=user_agent, + cors_options=cors_options, ) self.search_type = search_type self.semantic_configuration_name = semantic_configuration_name