๐ Setup dev environment
๐ฆน If you are doing this lab as part of a MongoDB GenAI Developer Day, you can continue in the Codespace you previously created.
Navigate to this link. Click the Resume this codespace button to resume the code space you created previously.

Give the codespace a few seconds to restart. When files appear in the Explorer tab, click on the file named ai-rag-lab.ipynb
under notebooks
. This is the Jupyter Notebook you will be using throughout this lab.

In this lab, we will be using Jupyter Notebooks, which is an interactive Python environment. If you are new to Jupyter Notebooks, use this guide to familiarize yourself with the environment.
Option 1: GitHub Codespacesโ
You will be working in GitHub Codespaces throughout this lab. A codespace is a cloud-hosted, containerized development environment that comes pre-configured with all the tools you need to run this lab.
Navigate to this link. You will be prompted to sign into GitHub if you haven't already. Once signed in, click the Create new codespace button to create a new codespace.

Let it run for a few seconds as it prepares a Docker container with all the required libraries and a MongoDB cluster.
Connect to the MongoDB clusterโ
Once the environment is built, you will be prompted to connect to the MongoDB cluster via MongoDB's VSCode extension. This will allow you to visualize the data that we will import into the cluster later in the lab, directly from the VSCode IDE.
To connect to the cluster, click the leaf icon in the left navigation bar of the IDE.

Under Connections, click the mongodb:27017 connection. This should automatically establish a connection to the local MongoDB cluster running on port 27017.

If the connection was successful, you should see the message Connected to: mongodb:27017 with a green indicator.
You will also see the default databases in the cluster appear under Connections. Any additional databases we create during the lab will also appear here.

Jupyter Notebook setupโ
You will be filling code in a Jupyter Notebook during this lab, so let's get set up with that next!
Within the codespace, click on the files icon in the left navigation bar of the IDE. In the Explorer menu, under notebooks
, click on the file named ai-rag-lab.ipynb
to open the Jupyter Notebook for this lab.

Next, select the Python interpreter by clicking Select Kernel at the top right of the IDE.

In the modal that appears, click Python environments... and select the interpreter that is marked as Recommended or Global Env.


That's it! You're ready for the lab!
Option 2: Run locallyโ
During the lab, we will use GitHub Codespaces. These instructions are here just in case you can't use Codespaces or if you really, really, really want a local installation.
To run the lab locally, follow the steps below:
- Clone the GitHub repo for this lab by executing the following command from the terminal:
git clone https://github.com/mongodb-developer/genai-devday-notebooks.git
cd
into thenotebooks
directory of the cloned repository:
cd genai-devday-notebooks/notebooks
- Create and activate a Python virtual environment:
python -m venv ai-rag-lab
source ai-rag-lab/bin/activate
- Install the dependencies for this lab:
pip install -r requirements.txt
- Install and launch Jupyter Notebook:
pip install notebook
jupyter notebook
- In the browser tab that pops up, open the file named
ai-rag-lab.ipynb
.
