Skip to main content
The .vector_db accessor provides methods for managing a pgvector database instance:
Vector database functionality is only supported by the ai-navigator and anaconda-desktop backends. The ai-catalyst backend does not support vector database operations.

Example usage

from anaconda_ai import AnacondaAIClient

client = AnacondaAIClient(backend='anaconda-desktop')

# Start the vector database
db_info = client.vector_db.create()
print(f"Database running at: {db_info.uri}")

# Create a table for embeddings
schema = VectorDbTableSchema(columns=[
    VectorDbTableColumn(name="id", type="SERIAL", constraints=["PRIMARY KEY"]),
    VectorDbTableColumn(name="embedding", type="vector(384)")
])
client.vector_db.create_table("my_embeddings", schema)

# List tables
tables = client.vector_db.get_tables()
for table in tables:
    print(f"Table: {table.name}, Rows: {table.numRows}")

# Clean up
client.vector_db.drop_table("my_embeddings")
client.vector_db.stop()