vanna-ai / vanna

🤖 Chat with your SQL database 📊. Accurate Text-to-SQL Generation via LLMs using RAG 🔄.
https://vanna.ai/docs/
MIT License
12.06k stars 967 forks source link

Feature/azuresearch vector support #598

Closed lucaordronneau closed 3 months ago

lucaordronneau commented 3 months ago

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

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

zainhoda commented 3 months ago

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