Milvus Async

Code

1import asyncio
2from kern.agent import Agent
3from kern.knowledge.knowledge import Knowledge
4from kern.vectordb.milvus import Milvus
5
6vector_db = Milvus(
7 collection="recipes",
8 uri="tmp/milvus.db",
9)
10
11knowledge = Knowledge(
12 url="https://kern-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
13 vector_db=vector_db,
14)
15
16agent = Agent(knowledge=knowledge)
17
18if __name__ == "__main__":
19 asyncio.run(
20 knowledge.ainsert(
21 url="https://kern-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
22 )
23 )
24
25 asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True))

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Install dependencies

1uv pip install -U pymilvus pypdf openai kern-ai

Run Agent

1python cookbook/08_knowledge/vector_db/milvus_db/async_milvus_db.py