Skip to content

Commit 8a7e84c

Browse files
Python: Update Azure Cognitive Search Class Change VectorSearchAlgorithmConfi… (#2435)
…guration to HnswVectorSearchAlgorithmConfiguration ### Motivation and Context Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? Azure Cognitive Search SDK Change VectorSearchAlgorithmConfiguration to HwsnVectorSearchAlgorithmConfiguration 2. What problem does it solve? ImportError: cannot import name 'VectorSearchAlgorithmConfiguration' from 'azure.search.documents.indexes.models' 3. What scenario does it contribute to? Python SDK Vector DB Change 5. If it fixes an open issue, please link to the issue here. https://github.com/Azure/cognitive-search-vector-pr/blob/main/demo-python/code/azure-search-vector-python-sample.ipynb ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Lee Miller <lemiller@microsoft.com>
1 parent fce878c commit 8a7e84c

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

python/poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ psycopg = "^3.1.9"
5656
psycopg-binary = "^3.1.9"
5757

5858
[tool.poetry.group.azure_cognitive_search.dependencies]
59-
azure-search-documents = {version = "11.4.0b6", allow-prereleases = true}
59+
azure-search-documents = {version = "11.4.0b8", allow-prereleases = true}
6060
azure-core = "^1.28.0"
6161
azure-identity = "^1.13.0"
6262

python/semantic_kernel/connectors/memory/azure_cognitive_search/azure_cognitive_search_memory_store.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from azure.core.exceptions import ResourceNotFoundError
99
from azure.search.documents.indexes.aio import SearchIndexClient
1010
from azure.search.documents.indexes.models import (
11+
HnswVectorSearchAlgorithmConfiguration,
1112
SearchIndex,
1213
VectorSearch,
13-
VectorSearchAlgorithmConfiguration,
1414
)
1515
from numpy import ndarray
1616

@@ -58,7 +58,6 @@ def __init__(
5858
Instantiate using Async Context Manager:
5959
async with AzureCognitiveSearchMemoryStore(<...>) as memory:
6060
await memory.<...>
61-
6261
"""
6362
try:
6463
pass
@@ -82,14 +81,14 @@ async def close_async(self):
8281
async def create_collection_async(
8382
self,
8483
collection_name: str,
85-
vector_config: Optional[VectorSearchAlgorithmConfiguration] = None,
84+
vector_config: Optional[HnswVectorSearchAlgorithmConfiguration] = None,
8685
) -> None:
8786
"""Creates a new collection if it does not exist.
8887
8988
Arguments:
9089
collection_name {str} -- The name of the collection to create.
91-
vector_config {VectorSearchAlgorithmConfiguration} -- Optional search algorithm configuration
92-
(default: {None}).
90+
vector_config {HnswVectorSearchAlgorithmConfiguration} -- Optional search algorithm configuration
91+
(default: {None}).
9392
semantic_config {SemanticConfiguration} -- Optional search index configuration (default: {None}).
9493
Returns:
9594
None
@@ -100,7 +99,7 @@ async def create_collection_async(
10099
else:
101100
vector_search = VectorSearch(
102101
algorithm_configurations=[
103-
VectorSearchAlgorithmConfiguration(
102+
HnswVectorSearchAlgorithmConfiguration(
104103
name="az-vector-config",
105104
kind="hnsw",
106105
hnsw_parameters={

0 commit comments

Comments
 (0)