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
Copy file name to clipboardexpand all lines: apps/graph_rag_demo/README.md
+11-11
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# kg_graph__rag_mongo
2
-
This guide explores how to leverage MongoDB's capabilities to create and manipulate graph representations using both Python and Node.js. By utilizing these two popular programming languages, we can demonstrate the versatility of MongoDB in different development environments, showcasing how to perform essential Graph RAG to represent and analyze graphs can provide valuable insights into complex relationships and interactions within data combining the Graph and RAG data in MongoDB.
2
+
This guide explores how to leverage MongoDB's capabilities to create and manipulate graph representations using both Python and Node.js. By utilizing these two popular programming languages, we can demonstrate the versatility of MongoDB in different development environments, showcasing how to perform essential Graph RAG to represent and analyze graphs can provide valuable insights into complex relationships and interactions within data combining the Graph and RAG data in MongoDB.
3
3
4
4
5
5
## Prep Steps
@@ -8,21 +8,21 @@ This guide explores how to leverage MongoDB's capabilities to create and manipul
8
8
Set up a Atlas a [cloud-based MongoDB instance of MongoDB.](https://www.mongodb.com/docs/atlas/tutorial/create-new-cluster/)
9
9
10
10
2. Install Required Libraries:
11
-
For Python:
12
-
Please do a regular installation of Anaconda for your Operating System using the [doc](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)
11
+
For Python:
12
+
Please do a regular installation of Anaconda for your Operating System using the [doc](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)
13
13
Once conda is installed, open up a shell with the Conda CLI, change to this directory and create a new environment with the packages listed in the requirements.txt by executing the following statement:
14
-
14
+
15
15
```bash
16
16
conda env create -f environment.yaml
17
17
conda activate kg-demo
18
18
```
19
-
For Node.js:
19
+
For Node.js:
20
20
For the Node JS files we have a package.json and you will be able to use npm install to install all the packages needed. Our Code was tested on Node version v20.15.0 and npm version 10.7.0
21
21
22
-
3. Now open the .env file in the directory and populate the following three variables. Please note that the .env file may be empty when you clone this repository
22
+
3. Now open the .env file in the directory and populate the following three variables. Please note that the .env file may be empty when you clone this repository
23
23
OPENAI_API_KEY1=
24
24
ATLAS_CONNECTION_STRING=
25
-
PDF =
25
+
PDF =
26
26
27
27
4. Create the MongoDB Atlas Database:
28
28
Please note that ATLAS_CONNECTION_STRING and OPENAI_API_KEY1 should already be created in the environment file.
@@ -32,7 +32,7 @@ This guide explores how to leverage MongoDB's capabilities to create and manipul
32
32
5. Download and install **MongoDB Compass** for your platform by following the steps mentioned [here](https://www.mongodb.com/docs/compass/current/install/). Please ensure you install a compass version 1.40.0 or higher. Once installed, connect to your Atlas cluster by following the link [here](https://www.mongodb.com/docs/compass/current/connect/).
33
33
34
34
6. Create vector index on the Compass UI for the <code>embedding</code> field for <code>knowledge_graph</code> collection. [Please refer to this document](https://www.mongodb.com/docs/compass/current/indexes/create-vector-search-index/). You can use the following json document for the index defination. Please name the vector index as <code>vector_index</code>
35
-
Sample:
35
+
Sample:
36
36
```json
37
37
{
38
38
"fields": [ {
@@ -44,8 +44,8 @@ This guide explores how to leverage MongoDB's capabilities to create and manipul
44
44
}
45
45
```
46
46
After this create an Atlas Search Index on the <code>knowledge_graph</code> collection. [Please refer this document](https://www.mongodb.com/docs/compass/current/indexes/create-search-index/). Please name the Atlas Search Index as <code>default</code>
47
-
48
-
47
+
48
+
49
49
50
50
51
51
## Running the application
@@ -97,4 +97,4 @@ It will then ask about the Spanning Tree depth. You can give it a value of 2 or
97
97
The answer for this question should be something as below:
98
98
99
99
**Social Support:Social factor Stress:Condition Diet:Lifestyle factor Physical Health:Condition Work Environment:Environment Job Satisfaction:Emotional state Aging:Condition Job Satisfaction:Condition Productivity:Condition Social Support:Activity Immune System:Biological system Cortisol:Hormone Cognitive Function:Function Immune System:System Diet:Activity Burnout:Condition Work Performance:Condition Heart Disease:Disease Cognitive Function:Condition Sleep Quality:Condition Inflammation:Biological process Social Support:Condition Productivity:Outcome Employee Turnover:Outcome Work Environment:Factor Diabetes:Disease Genetics:Biological factor Physical Activity:Activity Diet:Condition Obesity:Condition Heart Disease:Condition Social Support:Factor Social Relationships:Condition Sleep Quality:Health aspect Inflammation:Condition Diet:Factor Memory:Condition Blood Pressure:Condition Exercise:Activity Depression:Condition Anxiety:Condition Mental Health:Aspect Learning:Condition Sleep Quality:Aspect Stress:Concept Diet:Behavior Physical Health:Health aspect Anxiety:Emotional state Anxiety:Mental condition Depression:Mental condition Depression:Emotional state Physical Activity:Behavior Job Satisfaction:Psychological factor Mental Health:Health aspect Mental Health:Condition -----------
100
-
Social support is related to aging through its impact on stress. Social support reduces stress, and since stress accelerates aging, having social support can indirectly slow down the aging process by reducing the level of stress experienced by individuals.**
100
+
Social support is related to aging through its impact on stress. Social support reduces stress, and since stress accelerates aging, having social support can indirectly slow down the aging process by reducing the level of stress experienced by individuals.**
Copy file name to clipboardexpand all lines: apps/graph_rag_demo/addEmbeddings.js
+2-4
Original file line number
Diff line number
Diff line change
@@ -24,8 +24,8 @@ async function run() {
24
24
// Ensure that the collection is empty
25
25
awaitcollection.deleteMany({});
26
26
constpdfArray=[
27
-
'./PDF_KG/Diet, Stress and Mental Healt.pdf',
28
-
'./PDF_KG/Effect of Stress Management Interventions on Job Stress among nurses working in critical care units.pdf',
27
+
'./PDF_KG/Diet, Stress and Mental Healt.pdf',
28
+
'./PDF_KG/Effect of Stress Management Interventions on Job Stress among nurses working in critical care units.pdf',
29
29
'./PDF_KG/Factors contributing to stress among parents of children with autism.pdf',
30
30
'./PDF_KG/Level of physical activity, well-being, stress and self rated health in persons with migraine and co existing tension-type headache and neck pain.pdf',
31
31
'./PDF_KG/Stress and Blood Pr ess and Blood Pressure During Pr e During Pregnancy Racial Diff egnancy Racial Differences.pdf',
0 commit comments