Usage
SingleStore
Insert a PDF into a SingleStore knowledge base, query it with an agent, and delete content by name.
This local setup uses the SingleStore development image. Check its platform requirements before starting Docker. The named volume stores the database at /data.
Code
from os import getenv
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.singlestore import SingleStore
from sqlalchemy.engine import create_engine
USERNAME = getenv("SINGLESTORE_USERNAME")
PASSWORD = getenv("SINGLESTORE_PASSWORD")
HOST = getenv("SINGLESTORE_HOST")
PORT = getenv("SINGLESTORE_PORT")
DATABASE = getenv("SINGLESTORE_DATABASE")
SSL_CERT = getenv("SINGLESTORE_SSL_CERT", None)
db_url = (
f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4"
)
if SSL_CERT:
db_url += f"&ssl_ca={SSL_CERT}&ssl_verify_cert=true"
db_engine = create_engine(db_url)
vector_db = SingleStore(
collection="recipes",
db_engine=db_engine,
schema=DATABASE,
)
knowledge = Knowledge(name="My SingleStore Knowledge Base", vector_db=vector_db)
knowledge.insert(
name="Recipes",
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
metadata={"doc_type": "recipe_book"},
)
agent = Agent(
knowledge=knowledge,
search_knowledge=True,
read_chat_history=True,
)
agent.print_response("How do I make pad thai?", markdown=True)
vector_db.delete_by_name("Recipes")SingleStore delete_by_metadata compares the entire stored metadata JSON for equality, rather than matching a subset. URL-ingestion metadata is not merged into each vector document by this adapter. Use the demonstrated delete_by_name for these recipe chunks.
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U PyMySQL sqlalchemy pypdf openai agnoRun SingleStore
docker run -d --name singlestoredb \
--platform linux/amd64 \
-p 3306:3306 \
-p 8080:8080 \
-v agno-singlestore-data:/data \
-e ROOT_PASSWORD=admin \
ghcr.io/singlestore-labs/singlestoredb-dev:latest
Wait until docker inspect --format '{{.State.Health.Status}}' singlestoredb reports healthy. If it becomes unhealthy or exits, inspect docker logs singlestoredb before continuing. Then create the database:
docker exec singlestoredb singlestore -u root -padmin \
-e "CREATE DATABASE IF NOT EXISTS AGNO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"Set environment variables
export SINGLESTORE_HOST="localhost"
export SINGLESTORE_PORT="3306"
export SINGLESTORE_USERNAME="root"
export SINGLESTORE_PASSWORD="admin"
export SINGLESTORE_DATABASE="AGNO"
export OPENAI_API_KEY=xxxRun Agent
python singlestore_db.py