Skip to main content

Setup

Follow the instructions in the MongoDB Setup Guide to get your connection string. Install dependencies
The example uses OpenAI for embeddings and the agent model, so set your API key:

Example

agent_with_knowledge.py

Async Support ⚡

MongoDB also supports asynchronous operations, enabling concurrency and leading to better performance.

async_mongodb.py
Use ainsert() and aprint_response() methods with asyncio.run() for non-blocking operations in high-throughput applications.

MongoDB Params