๐ Setup dev environment
๐ฆน If you are doing this lab as part of a MongoDB GenAI Developer Day, you can continue in the environment you previously created.
- Instruqt
- GitHub Codespaces
- Local
Navigate to the Instruqt lab using this link. Click Continue to continue in the sandbox you created previously.

In the Explorer menu, navigate to genai-devday-notebooks
> notebooks
> ai-agents-lab.ipynb
This is the Jupyter Notebook you will be using throughout this lab.

Notice that this documentation website is also linked in the Agents Lab Instructions
tab of your Instruqt sandbox. Feel free to access the documentation from there instead for the rest of the lab.
Navigate to this link. Click the Resume this codespace button to resume the codespace you created previously.

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

Open the browser tab where your Jupyter Server from before is running and open the file named ai-agents-lab.ipynb
.

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.
- Instruqt
- GitHub Codespaces
- Local
Instruqt is a lab platform that provides cloud-based sandboxes which come pre-configured with all the tools you need to run this lab.
Navigate to the Instruqt lab using this link. Fill out the form that appears and click Submit and access.

Click Start to launch the lab environment.

You should see a screen with a purple progress bar indicating that Instruqt is preparing a sandbox with all the required libraries for this lab and a MongoDB cluster.
Once this is done, you should see a Start button at the bottom right of the screen. Click this to enter the lab.

Connect to the MongoDB clusterโ
Let's first connect to the MongoDB cluster that was created for you. This will allow you to view data we import into the cluster later in the lab, directly from the VSCode IDE.
To do this, click the leaf icon in the left navigation bar of the IDE. This is MongoDB's VSCode extension.

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

If the connection was successful, you should see a green leaf and a "connected" message appear around the Local MongoDB Atlas connection.
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 sandbox, click on the files icon in the left navigation bar of the IDE. In the Explorer menu, navigate to genai-devday-notebooks
> notebooks
> ai-agents-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!
Notice that this documentation website is also linked in the Agents Lab Instructions
tab of your Instruqt sandbox. Feel free to access the documentation from there instead for the rest of the lab.
A codespace is a cloud-hosted development environment from GitHub, that comes pre-configured with all the tools you need to run this lab.
To create a codespace, 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โ
Let's first connect to the MongoDB cluster that was created for you. This will allow you to view data we import into the cluster later in the lab, directly from the VSCode IDE.
To do this, click the leaf icon in the left navigation bar of the IDE. This is MongoDB's VSCode extension.

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

If the connection was successful, you should see a green leaf and a "connected" message appear around the Local MongoDB Atlas connection.
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-agents-lab.ipynb
to open the Jupyter Notebook for this lab.

That's it! You're ready for the lab!
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-agents-lab
source ai-agents-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-agents-lab.ipynb
.
