Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/azuresearch vector support #598

Merged

Conversation

lucaordronneau
Copy link
Contributor

Added Support for Azure AI Search as a Vector Store

Summary

This update introduces a Python module (azuresearch_vector.py) for interacting with Azure’s search services.

Key features include

  • Utilization of fastembed for embedding.
  • Leveraging Azure AI Search to manage metadata by setting a single vector database with a metadata type that can be ddl, documentation, or sql. This approach maintains interaction consistency and easily adapts to the existing logic.

Example with Documentation

def add_documentation(self, doc: str) -> str:
    id = deterministic_uuid(doc) + "-doc"
    document = {
        "id": id,
        "document": doc,
        "type": "doc",
        "document_vector": self.generate_embedding(doc)
    }
    self.search_client.upload_documents(documents=[document])
    return id

def get_related_documentation(self, text: str) -> List[str]:
    result = []
    vector_query = VectorizedQuery(vector=self.generate_embedding(text), fields="document_vector")

    df = pd.DataFrame(
        self.search_client.search(
            top=self.n_results_documentation,
            vector_queries=[vector_query],
            select=["id", "document", "type"],
            filter=f"type eq 'doc'",
            vector_filter_mode=VectorFilterMode.PRE_FILTER
        )
    )

    if len(df):
        result = df["document"].tolist()
    return result

Pre-PR Actions

  • Tests conducted in test_vanna.py.
  • Pre-commit checks completed.

@lucaordronneau lucaordronneau force-pushed the feature/azuresearch-vector-support branch from 928e7dc to 727c218 Compare August 19, 2024 13:38
@zainhoda
Copy link
Contributor

Thank you @lucaordronneau ! I had to comment out the integration test until we can set up Azure AI Search on our Azure account.

@zainhoda zainhoda merged commit f854616 into vanna-ai:main Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants