Skip to main content

AI framework integrations for Azure Database for PostgreSQL

Project description

llama-index-vector-stores-azurepostgresql

Azure PostgreSQL Vector Store integration for LlamaIndex.

This package provides an integration for using Azure Database for PostgreSQL as a vector store backend with LlamaIndex, supporting advanced vector search capabilities (including pgvector, DiskANN, and hybrid search).

Features

  • Store and query vector embeddings in Azure PostgreSQL
  • Support for pgvector and DiskANN extensions
  • Metadata filtering
  • Seamless integration with LlamaIndex's core abstractions

Installation

You can install the package and its dependencies using uv, pip, or poetry:

uv pip install .
# or
pip install .
# or
poetry install

Dependencies:

  • llama-index
  • psycopg (PostgreSQL driver)
  • azure-identity (for Azure authentication)

Usage Example

import sys

sys.path.insert(0, "/path/to/llama-index-vector-stores-azurepostgresql")

from llama_index.vector_stores.azurepostgresql.base import AzurePGVectorStore
from llama_index.core import (
    SimpleDirectoryReader,
    StorageContext,
    VectorStoreIndex,
)
from llama_index.llms.azure_openai import AzureOpenAI
from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding

# Set up your Azure OpenAI and PostgreSQL connection details
llm = AzureOpenAI(...)
embed_model = AzureOpenAIEmbedding(...)

vector_store = AzurePGVectorStore.from_params(
    database="postgres",
    host="<your-host>.postgres.database.azure.com",
    port=5432,
    table_name="my_table",
    embed_dim=1536,
    pg_diskann_kwargs={
        "pg_diskann_operator_class": "vector_cosine_ops",
        "pg_diskann_max_neighbors": 32,
        "pg_diskann_l_value_ib": 100,
        "pg_diskann_l_value_is": 100,
        "pg_diskann_iterative_search": True,
    },
)

storage_context = StorageContext.from_defaults(vector_store=vector_store)
documents = SimpleDirectoryReader("./data").load_data()
index = VectorStoreIndex.from_documents(
    documents, storage_context=storage_context
)
query_engine = index.as_query_engine()
response = query_engine.query("Your query here")
print(response)

Development

  • To run tests:
    make test
    
  • To build the package:
    uv build
    

License

This project is licensed under the terms of the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_vector_stores_azurepostgres-0.2.0-py2.py3-none-any.whl (22.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file llama_index_vector_stores_azurepostgres-0.2.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_vector_stores_azurepostgres-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d10fd1022b16876b7f2899700cbedbc2b6dac2e45ae5b85b603c0eb0508da14e
MD5 07305aafa7eeaa6e2dbee2032091ed9e
BLAKE2b-256 0888f720a508400e84df909a2cdaebcedc72999ac197d3b1d818fee181998724

See more details on using hashes here.

File details

Details for the file llama_index_vector_stores_azurepostgres-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_vector_stores_azurepostgres-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0841514303cb4838d384028ee3572478288d7c708e995a9f3eef95c622e22d12
MD5 a4d9a07639a3e96a858330069b382ea2
BLAKE2b-256 6616d42ad8df3814bfbbb2cfeb2d6ab84a7b8eb4fdd22c6cc6a801a96ce2a6ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page