Vector DBs
Milvus Agent Knowledge
Setup
Initialize Milvus
Set the uri and token for your Milvus server.
- If you only need a local vector database for small scale data or prototyping, setting the uri as a local file, e.g.
./milvus.db
, is the most convenient method, as it automatically utilizes Milvus Lite to store all data in this file. - If you have large scale data, say more than a million vectors, you can set up a more performant Milvus server on Docker or Kubernetes.
In this setup, please use the server address and port as your uri, e.g.
http://localhost:19530
. If you enable the authentication feature on Milvus, useyour_username:your_password
as the token, otherwise don’t set the token. - If you use Zilliz Cloud, the fully managed cloud service for Milvus, adjust the
uri
andtoken
, which correspond to the Public Endpoint and API key in Zilliz Cloud.
Example
agent_with_knowledge.py
Async Support ⚡
Milvus now supports asynchronous operations for improved performance in production environments.
async_milvus_db.py
Use aload()
and aprint_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
Milvus Params
Parameter | Type | Description | Default |
---|---|---|---|
collection | str | Name of the Milvus collection | Required |
embedder | Optional[Embedder] | Embedder to use for embedding documents | OpenAIEmbedder() |
distance | Distance | Distance metric to use for vector similarity | Distance.cosine |
uri | str | URI of the Milvus server or path to local file | "http://localhost:19530" |
token | Optional[str] | Token for authentication with the Milvus server | None |
Advanced options can be passed as additional keyword arguments to the MilvusClient
constructor.
Developer Resources
- View Cookbook (Sync)
- View Cookbook (Async)