AgentVectorDB: The Cognitive Core for Your AI Agents. A lightweight, embeddable vector database for Agentic AI systems, built on LanceDB.
Project description
🧠 AgentVectorDB
AgentVectorDB: The Cognitive Core for Your AI Agents
AgentVectorDB is a lightweight, embeddable vector database designed for agentic AI systems. It empowers your agents with persistent memory, semantic search, and tools for internal reasoning and learning. Built on the performance and simplicity of LanceDB, AgentVectorDB is the default memory layer for sophisticated AI agents, offering a familiar "collection-based" API.
🚀 Why AgentVectorDB?
- Familiar API: Uses a
Store -> Collectionmodel, similar to other popular vector databases. - Lightweight & Embeddable: Runs directly within your agent's process using LanceDB. No separate server, minimal dependencies.
- Agent-Centric Schema: Default schema includes fields like
type(observation, thought, goal),source,importance_score, andlast_accessed_atto provide a cognitive framework for each memory entry. - Temporal Dynamics: Built-in support for recency, memory decay (
prune_memories), and tracking when memories were last accessed. - Rich Querying: Powerful semantic search combined with SQL filtering (
filter_sql) for maximum flexibility. - Seamless Embedding Integration: Works with LanceDB's embedding functions or your custom embedding models, configurable per collection.
- Asynchronous API: Provides
AsyncAgentVectorDBStoreandAsyncAgentMemoryCollectionfor integration with async-first agent frameworks. - Open Source & Extensible: Built with best practices, ready for community contributions.
✨ Features at a Glance
- Persistent Storage: File-based, no server required.
- Vector Search: Efficient ANN search.
- Metadata Filtering: Use
filter_sqlfor powerful filtering. - CRUD Operations: Add, retrieve, update, and delete memories.
- Batch Operations: Efficiently add multiple memories.
- Memory Pruning:
prune_memoriesmethod for memory decay strategies. - Dynamic Schema: Flexible Pydantic-based schemas per collection.
- Timestamp Tracking: Automatic
created_atand optionallast_accessed_atupdates. - Async Support: Fully asynchronous API available.
📦 Installation
pip install agentvectordb
Or for the latest development version:
pip install git+https://github.com/superagenticai/agentvectordb.git
To install locally for development:
git clone https://github.com/superagenticai/agentvectordb.git
cd agentvectordb
pip install -e .[dev]
🏁 Quickstart
import asyncio
import os
import shutil
from agentvectordb import AgentVectorDBStore, AsyncAgentVectorDBStore
from agentvectordb.embeddings import DefaultTextEmbeddingFunction
print("\033[1;36m")
print("🧠🚀 Welcome to AgentVectorDB Quickstart! 🚀🧠")
print("A lightweight, embeddable vector database for agentic AI systems, built on LanceDB.\n")
print("\033[0m")
DB_DIR = "./_agentvectordb_mvp_quickstart_db"
ef = DefaultTextEmbeddingFunction(dimension=64)
def cleanup_db_dir(db_directory):
if os.path.exists(db_directory):
shutil.rmtree(db_directory)
os.makedirs(db_directory, exist_ok=True)
cleanup_db_dir(DB_DIR)
# --- Synchronous API ---
print("\033[1;34m🔹 [SYNC] Episodic Memory Demo\033[0m")
store = AgentVectorDBStore(db_path=DB_DIR)
episodic_memories = store.get_or_create_collection(
name="episodic_stream",
embedding_function=ef,
update_last_accessed_on_query=True,
recreate=True
)
episodic_memories.add(
content="User inquired about AgentVectorDB's collection feature.",
type="user_interaction",
source="chat_interface",
tags=["agentvectordb_feature", "collections_api"]
)
episodic_memories.add(
content="Agent decided to use the 'episodic_stream' collection for observations.",
type="internal_decision",
source="agent_reasoner",
importance_score=0.7
)
query_results = episodic_memories.query(
query_text="AgentVectorDB collection feature",
k=1,
filter_sql="type = 'user_interaction'"
)
print("\033[1;32m\n🌟 Sync Query Results:\033[0m")
for res in query_results:
print(f"\033[1;33m • {res.get('content', 'N/A')} \033[0m\033[0;35m(Type: {res.get('type')})\033[0m")
# --- Asynchronous API ---
async def async_example_main():
print("\n\033[1;34m🔹 [ASYNC] Agent Thoughts Log Demo\033[0m")
async_store = AsyncAgentVectorDBStore(db_path=DB_DIR)
agent_thoughts = await async_store.get_or_create_collection(
name="agent_thoughts_log",
embedding_function=ef,
update_last_accessed_on_query=True,
recreate=True
)
await agent_thoughts.add(
content="Async thought: Need to plan next steps for Project Nebula.",
type="planning_thought",
importance_score=0.85,
metadata={"project": "Nebula", "status": "pending_review"}
)
async_results = await agent_thoughts.query(
query_text="Project Nebula planning",
k=1,
filter_sql="metadata.extra LIKE '%Nebula%'"
)
print("\033[1;32m\n🌟 Async Query Results:\033[0m")
for res in async_results:
print(f"\033[1;33m • {res.get('content', 'N/A')} \033[0m\033[0;35m(Importance: {res.get('importance_score')})\033[0m")
collections = await async_store.list_collections()
print("\n\033[1;36m📚 Collections in the async store:\033[0m")
for coll_name in collections:
print(f" - {coll_name}")
print("\n\033[1;36m🎉 Quickstart complete! Explore more with AgentVectorDB.\033[0m")
if __name__ == "__main__":
asyncio.run(async_example_main())
🛠️ API Overview
AgentVectorDBStore(db_path: str)
- db_path: Directory where LanceDB database files are stored.
Methods:
get_or_create_collection(...)– Create or open a collection.list_collections()– List all collections.delete_collection(name: str)– Delete a collection.
AgentMemoryCollection
- Properties:
name,embedding_function,schema - Methods:
add,add_batch,query,get_by_id,delete,count,prune_memories,__len__
Asynchronous API
AsyncAgentVectorDBStoreAsyncAgentMemoryCollection- All methods of their synchronous counterparts are available as
asyncmethods.
- All methods of their synchronous counterparts are available as
📚 Advanced Usage
Multiple Collections
store = AgentVectorDBStore(db_path="./my_multi_agent_db")
kb_ef = DefaultTextEmbeddingFunction(dimension=128)
knowledge_base = store.get_or_create_collection(
name="knowledge_base",
embedding_function=kb_ef
)
knowledge_base.add(content="The Earth revolves around the Sun.", type="astronomy_fact")
Filtering with filter_sql
results = my_collection.query(
query_text="relevant topic",
k=5,
filter_sql="type = 'log_entry' AND importance_score > 0.5 AND metadata.extra LIKE '%user123%'"
)
Memory Pruning
pruned_count = observations.prune_memories(
max_age_seconds=86400 * 7,
min_importance_score=0.3,
filter_logic="AND",
dry_run=False
)
print(f"Pruned {pruned_count} old/unimportant observations.")
🧑💻 More Examples
See the examples/ directory for:
quickstart.py– Full sync & async demosync_basic_usage.py– Minimal synchronous usageasync_batch_add.py– Async batch add/querymetadata_filtering.py– Metadata and SQL filteringprune_and_count.py– Pruning and countingasync_delete.py– Async deletion
🛤️ Roadmap & Contributing
AgentVectorDB is actively evolving. Planned features include:
- More sophisticated filter builders
- Reflection/summarization helpers
- Schema evolution helpers
- Community-driven extensions
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
📄 License
This project is licensed under the Apache-2.0 License.
AgentVectorDB: Give your AI agents a memory!
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentvectordb-0.0.1.tar.gz.
File metadata
- Download URL: agentvectordb-0.0.1.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff99fb97785667c4297ea179438ba7344c455e70c3dfbad9b169b6e2cbb7e664
|
|
| MD5 |
4bc7a27ca9240202eab1bdc0a5e8f067
|
|
| BLAKE2b-256 |
5fe20371c327c5f81877d8b70d41e24da97e2d161c00929b7467f48a107ad7ab
|
File details
Details for the file agentvectordb-0.0.1-py3-none-any.whl.
File metadata
- Download URL: agentvectordb-0.0.1-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47466079b5503a9d2b2068b3862134d58a4bb7258c1a5ec56b71e9a57b0910b9
|
|
| MD5 |
ee338db7a4c54eb1131328cde85600fb
|
|
| BLAKE2b-256 |
3fbefd3b153a47e3f763af289c41a703b54d8b901286ca038d8813ff235126f2
|