Skip to content

Commit 465a8c0

Browse files
authored
Merge pull request #12 from mongodb-developer/local_mongodb
Updating lab docs to reflect local MongoDB changes
2 parents 5175eab + 3938abe commit 465a8c0

File tree

56 files changed

+133
-288
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+133
-288
lines changed

docs/30-dev-env/1-dev-env-setup.mdx renamed to docs/20-dev-env/1-dev-env-setup.mdx

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import Screenshot from "@site/src/components/Screenshot";
77

88
Navigate to [this](https://github.com/codespaces/new/mongodb-developer/genai-devday-notebooks?quickstart=1) link. Click the **Resume this codespace** button to resume the code space you created previously.
99

10-
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/1-resume-codespace.png" alt="Resume codespace" />
10+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/1-resume-codespace.png" alt="Resume codespace" />
1111

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

14-
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/3-nav-notebook.png" alt="Navigate to the notebook" />
14+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/2-nav-notebook.png" alt="Navigate to the notebook" />
1515
</details>
1616

1717
:::tip
@@ -24,33 +24,56 @@ You will be working in a Jupyter Notebook in a GitHub Codespace throughout this
2424

2525
Navigate to [this](https://github.com/codespaces/new/mongodb-developer/genai-devday-notebooks?quickstart=1) 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.
2626

27-
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/2-create-codespace.png" alt="Start a codespace" />
27+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/3-create-codespace.png" alt="Start a codespace" />
2828

29-
Let it run for a few seconds as it prepares your environment. It will clone the repository, prepare the container, and run the installation scripts. Once the environment is built, you should see a list of files appear under the Explorer.
29+
Let it run for a few seconds as it prepares a Docker container with all the required libraries and a MongoDB cluster.
30+
31+
Once the environment is built, you should see a VS Code IDE with a list of files under the Explorer tab.
3032

3133
In the left navigation bar of the IDE, click on the file named `ai-rag-lab.ipynb` to open the Jupyter Notebook for this lab.
3234

33-
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/3-nav-notebook.png" alt="Navigate to the notebook" />
35+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/2-nav-notebook.png" alt="Navigate to the notebook" />
3436

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

37-
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/4-select-kernel.png" alt="Select kernel" />
39+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/4-select-kernel.png" alt="Select kernel" />
3840

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

41-
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/5-python-env-modal.png" alt="Select Python Environments" />
43+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/5-python-env-modal.png" alt="Select Python Environments" />
4244

43-
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-dev-env/1-dev-env-setup/6-select-recommended.png" alt="Select recommended interpreter" />
45+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/6-select-recommended.png" alt="Select recommended interpreter" />
4446

4547
That's it! You're ready for the lab!
4648

49+
<details>
50+
<summary>🦹 Use the MongoDB for VS Code extension to interact with the local MongoDB cluster from the VSCode IDE </summary>
51+
52+
In the left navigation bar of the IDE, click on the leaf icon. Under Connections, click the **Add Connection** button.
53+
54+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/7-add-connection.png" alt="Add MongoDB connection" />
55+
56+
In the tab that appears, click the **Connect** button.
57+
58+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/8-click-connect.png" alt="Click Connect" />
59+
60+
In the modal that appears at the top of the screen, enter the string `mongodb://admin:mongodb@mongodb:27017/` and hit `Enter` on your keyboard.
61+
62+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/9-enter-connection-string.png" alt="Enter connection string" />
63+
64+
If the connection was successful, you should see the cluster and its default databases under Connections. Any additional databases and collections created during the lab will appear here as well.
65+
66+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/20-dev-env/1-dev-env-setup/10-connections.png" alt="View connections" />
67+
68+
</details>
69+
4770
## Option 2: Run locally
4871

4972
:::caution
5073
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.
5174
:::
5275

53-
If you want to run the notebook locally, follow the steps below:
76+
To run the lab locally, follow the steps below:
5477

5578
* Clone the [GitHub repo](https://github.com/mongodb-developer/genai-devday-notebooks.git) for this lab by executing the following command from the terminal:
5679

@@ -86,4 +109,4 @@ jupyter notebook
86109

87110
* In the browser tab that pops up, open the file named `ai-rag-lab.ipynb`.
88111

89-
<Screenshot url="localhost:8888/tree" src="img/screenshots/30-dev-env/1-dev-env-setup/7-jupyter-notebook.png" alt="Jupyter Notebook" />
112+
<Screenshot url="localhost:8888/tree" src="img/screenshots/20-dev-env/1-dev-env-setup/11-jupyter-notebook.png" alt="Jupyter Notebook" />

docs/20-dev-env/2-setup-pre-reqs.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 👐 Setup prerequisites
2+
3+
Replace any placeholders and run the cells under **Step 1: Setup prerequisites** section in the notebook.
4+
5+
:::info
6+
7+
Additional steps **if you are running the lab locally**:
8+
9+
* Spin up a MongoDB Atlas cluster and obtain its connection string:
10+
11+
* Register for a [free MongoDB Atlas account](https://www.mongodb.com/cloud/atlas/register) if you don't already have one
12+
* [Create a new database cluster](https://www.mongodb.com/docs/guides/atlas/cluster)
13+
* [Obtain the connection string](https://www.mongodb.com/docs/guides/atlas/connection-string) for your database cluster
14+
15+
* Set the `MONGODB_URI` variable to the connection string for your cluster as follows:
16+
17+
```python
18+
MONGODB_URI = "<your_connection_string>"
19+
```
20+
21+
* Manually set the value of the `SERVERLESS_URL` variable as follows:
22+
23+
```python
24+
SERVERLESS_URL = "https://vtqjvgchmwcjwsrela2oyhlegu0hwqnw.lambda-url.us-west-2.on.aws/"
25+
```
26+
:::
File renamed without changes.

docs/20-mongodb-atlas/1-create-account.mdx

Lines changed: 0 additions & 67 deletions
This file was deleted.

docs/20-mongodb-atlas/2-create-cluster.mdx

Lines changed: 0 additions & 67 deletions
This file was deleted.

docs/20-mongodb-atlas/3-connection-string.mdx

Lines changed: 0 additions & 27 deletions
This file was deleted.

docs/20-mongodb-atlas/_category_.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/30-dev-env/2-setup-pre-reqs.mdx

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import Screenshot from "@site/src/components/Screenshot";
2+
3+
# 👐 Ingest data into MongoDB
4+
5+
The final step to build a MongoDB vector store for the chatbot is to ingest the embedded article chunks into MongoDB.
6+
7+
Fill in any `<CODE_BLOCK_N>` placeholders and run the cells under the **Step 5: Ingest data into MongoDB** section in the notebook to ingest the embedded documents into MongoDB.
8+
9+
The answers for code blocks in this section are as follows:
10+
11+
**CODE_BLOCK_5**
12+
13+
<details>
14+
<summary>Answer</summary>
15+
<div>
16+
```python
17+
collection.insert_many(embedded_docs)
18+
```
19+
</div>
20+
</details>
21+
22+
<details>
23+
<summary>🦹 Visually verify that the data has been imported into the local MongoDB cluster </summary>
24+
25+
Click the leaf icon in the left navigation bar of the IDE.
26+
27+
Ensure that you see a database called _mongodb_genai_devday_rag_, and a collection named _knowledge_base_ under it.
28+
29+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-prepare-the-data/4-ingest-data/1-verify-collection.png" alt="Verify collection" />
30+
31+
Click the **>** arrow next to _knowledge_base_ and note the number of documents.
32+
33+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-prepare-the-data/4-ingest-data/2-document-count.png" alt="Verify document count" />
34+
35+
To preview a document, click the **>** arrow next to _Documents_ and select a document from the list.
36+
37+
<Screenshot url="https://github.com/codespaces" src="img/screenshots/30-prepare-the-data/4-ingest-data/3-preview-document.png" alt="Preview document" />
38+
</details>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 👐 Create a vector search index
2+
3+
To retrieve documents from MongoDB using vector search, you must configure a vector search index on the collection into which you ingested your data. In this lab, you will programmatically create vector search indexes using MongoDB's Python driver.
4+
5+
Fill in any `<CODE_BLOCK_N>` placeholders and run the cells under the **Step 6: Create a vector search index** section in the notebook to create a vector search index.
6+
7+
The answers for code blocks in this section are as follows:
8+
9+
**CODE_BLOCK_6**
10+
11+
<details>
12+
<summary>Answer</summary>
13+
<div>
14+
```python
15+
collection.create_search_index(model=model)
16+
```
17+
</div>
18+
</details>

docs/50-perform-vector-search/3-vector-search.mdx renamed to docs/40-perform-vector-search/3-vector-search.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Fill in any `<CODE_BLOCK_N>` placeholders and run the cells under the **Step 7:
66

77
The answers for code blocks in this section are as follows:
88

9-
**CODE_BLOCK_9**
9+
**CODE_BLOCK_7**
1010

1111
<details>
1212
<summary>Answer</summary>
@@ -17,7 +17,7 @@ get_embedding(user_query)
1717
</div>
1818
</details>
1919

20-
**CODE_BLOCK_10**
20+
**CODE_BLOCK_8**
2121

2222
<details>
2323
<summary>Answer</summary>
@@ -45,7 +45,7 @@ get_embedding(user_query)
4545
</div>
4646
</details>
4747

48-
**CODE_BLOCK_11**
48+
**CODE_BLOCK_9**
4949

5050
<details>
5151
<summary>Answer</summary>

0 commit comments

Comments
 (0)