Facing an issue in azure search index

132 Views Asked by At
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
    SearchField,
    SearchFieldDataType,
    VectorSearch,
    HnswAlgorithmConfiguration,
    HnswParameters,
    VectorSearchAlgorithmMetric,
    ExhaustiveKnnAlgorithmConfiguration,
    ExhaustiveKnnParameters,
    VectorSearchProfile,
    AzureOpenAIVectorizer,
    AzureOpenAIParameters,
    SemanticConfiguration,
    SemanticSearch,
    SemanticPrioritizedFields,
    SemanticField,
    SearchIndex
)

...

cannot import name 'AzureOpenAIVectorizer' from 'azure.search.documents.indexes.models' (C:\Users\subramaniann\AppData\Local\anaconda3\Lib\site-packages\azure\search\documents\indexes\models\__init__.py)
version using azure-search-documents==11.6.0b1

...

I tried doing: !pip install azure-core --pre --upgrade and !pip install azure-search-documents --pre --upgrade still it is showing error

1

There are 1 best solutions below

0
Naveen Sharma On

The issue with importing the AzureOpenAIVectorizer class from the azure.search.documents.indexes.models module occurs due to an installation problem.

pip uninstall azure-search-documents pip install azure-search-documents==11.6.0b1

enter image description here

The command python -m venv myenv creates a virtual environment named "myenv" in your current directory.

python -m venv myenv

myenv\Scripts\activate is used to activate the virtual environment. Once activated, your terminal or command prompt session will use the Python interpreter and packages installed within the virtual environment rather than the global Python environment. myenv\Scripts\activate

Install the below packages:

pip install python-dotenv azure-search-documents==11.6.0b1 azure-storage-blob azure-identity

The code for azure-search-vector-samples for azure-search-integrate is taken from git and requirements.txt.


from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
    SearchField,
    SearchFieldDataType,
    VectorSearch,
    HnswAlgorithmConfiguration,
    HnswParameters,
    VectorSearchAlgorithmMetric,
    ExhaustiveKnnAlgorithmConfiguration,
    ExhaustiveKnnParameters,
    VectorSearchProfile,
    AzureOpenAIVectorizer,
    AzureOpenAIParameters,
    SemanticConfiguration,
    SemanticSearch,
    SemanticPrioritizedFields,
    SemanticField,
    SearchIndex
)

Output:

enter image description here