Code
async_milvus_db.py
import asyncio
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.milvus import Milvus
vector_db = Milvus(
collection="recipes",
uri="/tmp/milvus.db",
)
knowledge = Knowledge(
vector_db=vector_db,
)
agent = Agent(knowledge=knowledge)
if __name__ == "__main__":
asyncio.run(
knowledge.ainsert(
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
)
)
asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True))
Usage
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U pymilvus pypdf openai agno
3
Set environment variables
export OPENAI_API_KEY=xxx
4
Run Agent
python async_milvus_db.py