Code
milvus_db_hybrid_search.py
Usage
1
Set up your virtual environment
2
Install dependencies
3
Set environment variables
4
Run Agent
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Combine dense embeddings and sparse keyword vectors in one Milvus search with SearchType.hybrid.
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.milvus import Milvus, SearchType
vector_db = Milvus(
collection="recipes", uri="/tmp/milvus_hybrid.db", search_type=SearchType.hybrid
)
knowledge = Knowledge(
vector_db=vector_db,
)
knowledge.insert(
url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
)
agent = Agent(knowledge=knowledge)
agent.print_response("How to make Tom Kha Gai", markdown=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U pymilvus pypdf openai agno
Set environment variables
export OPENAI_API_KEY=xxx
Run Agent
python milvus_db_hybrid_search.py
Was this page helpful?