You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains code for an AI Agent that can:
4
+
4
5
- Answer questions about MongoDB using the MongoDB documentation as a knowledge base
5
6
- Summarize content from MongoDB documentation pages
6
7
7
8
## Project Structure
8
9
9
10
You can either:
11
+
10
12
- Run the completed agent in the root directory, or
11
13
- Follow the step-by-step implementation in the `lessons` directory
12
14
@@ -15,38 +17,44 @@ Each lesson builds upon the previous one, providing a gradual learning experienc
15
17
## Prerequisites
16
18
17
19
- Python 3.8 or higher
18
-
- MongoDB Atlas account with a cluster
20
+
-[MongoDB Atlas account](https://www.mongodb.com/cloud/atlas/register) with a cluster, or [self-managed](https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-deploy-local/) Atlas cluster
19
21
- API Keys:
20
-
- VoyageAI API key for embeddings
21
-
- OpenAI API key for the language model
22
+
-[VoyageAI API key](https://docs.voyageai.com/docs/api-key-and-installation) for embeddings
23
+
-[OpenAI API key](https://platform.openai.com/account/api-keys) for the language model
22
24
23
-
> **Note:** While this demo uses VoyageAI and OpenAI, you can modify the code to work with alternative providers.
25
+
> [!NOTE]
26
+
> While this demo uses VoyageAI and OpenAI, you can modify the code to work with alternative providers.
> **Note:** This project uses the `uv` package manager. If you prefer `pip` or `pipenv`, you'll need to adapt the installation commands.
56
+
> [!NOTE]
57
+
> This project uses the [`uv`](https://docs.astral.sh/uv/) package manager. If you prefer `pip` or `pipenv`, you'll need to adapt the installation commands.
50
58
51
59
## Loading the Dataset
52
60
@@ -56,9 +64,12 @@ Before using the agent, you must load the MongoDB documentation data into your d
56
64
uv run data.py
57
65
```
58
66
67
+
This script loads two Hugging Face datasets, [`mongodb-docs`](https://huggingface.co/datasets/MongoDB/mongodb-docs) (full docs) and [`mongodb-docs-embedded`](https://huggingface.co/datasets/MongoDB/mongodb-docs-embedded) (chunked docs), into your MongoDB instance. Full documents go into `full_docs`; chunked docs are embedded via VoyageAI ([`voyage-3-lite`](https://blog.voyageai.com/2024/09/18/voyage-3/)) and saved to `chunked_docs`. Finally, it creates a [`vector_index`](https://github.com/mongodb-university/curriculum/blob/main/AI-Agents-with-MongoDB/01-Building-AI-Agents-with-MongoDB/data.py#L41-L54) on the `embedding` field for semantic search. See [Attribution](#attribution) for more information.
68
+
59
69
## Running the Agent
60
70
61
71
1. In main.py, customize the queries for your agent. Examples:
72
+
62
73
```python
63
74
# Ask a specific question about MongoDB
64
75
execute_graph(app, "1", "What are some best practices for data backups in MongoDB?")
@@ -68,13 +79,35 @@ uv run data.py
68
79
```
69
80
70
81
2. Run the agent:
82
+
71
83
```bash
72
84
uv run main.py
73
85
```
74
86
75
87
## Troubleshooting
76
88
77
89
If you encounter any issues, ensure that:
78
-
- Your API keys are correctly set in key_param.py
90
+
91
+
- Your API keys are correctly set in `key_param.py`
79
92
- Your MongoDB Atlas cluster is accessible from your IP address
80
-
- You've loaded the data using data.py before running the agent
93
+
- You've loaded the data using `data.py` before running the agent
0 commit comments