Skip to content

Commit a7b607e

Browse files
authored
Merge pull request #4 from mongodb-university/feat/attribute_huggingface
Add attributions to ai-agents readme
2 parents 648f9d7 + 4dcf8eb commit a7b607e

File tree

1 file changed

+40
-7
lines changed
  • AI-Agents-with-MongoDB/01-Building-AI-Agents-with-MongoDB

1 file changed

+40
-7
lines changed
Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# AI Agents with MongoDB Skill
22

33
This repository contains code for an AI Agent that can:
4+
45
- Answer questions about MongoDB using the MongoDB documentation as a knowledge base
56
- Summarize content from MongoDB documentation pages
67

78
## Project Structure
89

910
You can either:
11+
1012
- Run the completed agent in the root directory, or
1113
- Follow the step-by-step implementation in the `lessons` directory
1214

@@ -15,38 +17,44 @@ Each lesson builds upon the previous one, providing a gradual learning experienc
1517
## Prerequisites
1618

1719
- 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
1921
- 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
2224

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.
2427
2528
## Setup Instructions
2629

2730
1. Configure your API keys in `key_param.py`:
31+
2832
```python
2933
openai_api_key = "your_openai_api_key"
3034
voyage_api_key = "your_voyage_api_key"
3135
mongodb_uri = "your_mongodb_uri"
3236
```
3337

3438
2. Install the `uv` package manager:
39+
3540
```bash
3641
curl -LsSf https://astral.sh/uv/install.sh | sh
3742
```
3843

3944
3. Create and initialize a `uv` environment:
45+
4046
```bash
4147
uv init
4248
```
4349

4450
4. Install the required dependencies:
51+
4552
```bash
4653
uv add langchain==0.3.24 langchain-openai==0.3.14 langgraph==0.3.31 langgraph-checkpoint-mongodb==0.1.3 pymongo==4.11.3 voyageai==0.3.2
4754
```
4855

49-
> **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.
5058
5159
## Loading the Dataset
5260

@@ -56,9 +64,12 @@ Before using the agent, you must load the MongoDB documentation data into your d
5664
uv run data.py
5765
```
5866

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+
5969
## Running the Agent
6070

6171
1. In main.py, customize the queries for your agent. Examples:
72+
6273
```python
6374
# Ask a specific question about MongoDB
6475
execute_graph(app, "1", "What are some best practices for data backups in MongoDB?")
@@ -68,13 +79,35 @@ uv run data.py
6879
```
6980

7081
2. Run the agent:
82+
7183
```bash
7284
uv run main.py
7385
```
7486

7587
## Troubleshooting
7688

7789
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`
7992
- 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
94+
95+
## Attribution
96+
97+
### Datasets
98+
99+
- **MongoDB/mongodb-docs** by MongoDB, Inc.
100+
License: CC BY 3.0
101+
<https://huggingface.co/datasets/MongoDB/mongodb-docs>
102+
- **MongoDB/mongodb-docs-embedded** by MongoDB, Inc.
103+
License: CC BY 3.0
104+
<https://huggingface.co/datasets/MongoDB/mongodb-docs-embedded>
105+
106+
### Models & APIs
107+
108+
- **VoyageAI** (`voyage-3-lite` embeddings)
109+
<https://voyageai.com/>
110+
- **OpenAI** (GPT-4o via langchain-openai)
111+
<https://openai.com>
112+
- **MongoDB Atlas** (for database hosting)
113+
<https://www.mongodb.com/cloud/atlas>

0 commit comments

Comments
 (0)