Skip to content

Commit

Permalink
Add support for CORS options for AzureSearch (#14305)
Browse files Browse the repository at this point in the history
- **Description:** Add support for setting the CORS options when using
AzureSearch indexes
  • Loading branch information
jalagus authored Dec 6, 2023
1 parent 9401539 commit 667ad6a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/langchain/langchain/vectorstores/azuresearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
if TYPE_CHECKING:
from azure.search.documents import SearchClient
from azure.search.documents.indexes.models import (
CorsOptions,
ScoringProfile,
SearchField,
VectorSearch,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 667ad6a

Please sign in to comment.