Azure / azure-search-vector-samples

A repository of code samples for Vector search capabilities in Azure AI Search.
https://azure.microsoft.com/products/search
MIT License
761 stars 325 forks source link

VectorSearchAlgorithmConfiguration import error #89

Closed sgautam666 closed 1 year ago

sgautam666 commented 1 year ago

I am trying to use this approach to use embeddings in Azure. For this, I am using langchain framework as well. While trying to create a vector store using AzureSearch(), I get this error:

ImportError: cannot import name 'VectorSearchAlgorithmConfiguration' from 'azure.search.documents.indexes.models' (/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/azure/search/documents/indexes/models/init.py)

Code for langchain:

embeddings: OpenAIEmbeddings = OpenAIEmbeddings(openai_api_key=os.getenv('OPENAI_API_KEY'),
                                                deployment=openai_embedding_deployment_name, 
                                                chunk_size=1)
vector_store: AzureSearch = AzureSearch(
    azure_search_endpoint=os.environ["AZURE_COGNITIVE_SEARCH_ENDPOINT"],
    azure_search_key=os.environ["AZURE_COGNITIVE_SEARCH_API_KEY"],
    index_name=index_name,
    embedding_function=embeddings.embed_query,
)

I am using 'azure-search-documents==11.4.0b8' version. Please advise Thank you

farzad528 commented 1 year ago

Hiya @sgautam666! There was a recent update in the Python SDK. I don't believe that LangChain has been updated yet.

Please see the below sample if you want to use the latest version: https://github.com/Azure/cognitive-search-vector-pr/blob/main/demo-python/code/azure-search-vector-python-sample.ipynb

sgautam666 commented 1 year ago

Thanks @farzad528