Prakhar Bhandari
commited on
Commit
·
fd975a4
1
Parent(s):
c8025cd
Added .env to hide api keys
Browse files- .gitignore +2 -1
- kg_builder/src/api_connections.py +10 -6
- kg_builder/src/main.py +1 -1
.gitignore
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
graphrag/
|
|
|
|
|
|
| 1 |
+
graphrag/
|
| 2 |
+
.env
|
kg_builder/src/api_connections.py
CHANGED
|
@@ -1,16 +1,20 @@
|
|
| 1 |
|
| 2 |
from langchain_community.graphs import Neo4jGraph
|
|
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
graph = Neo4jGraph(
|
| 10 |
url=url,
|
| 11 |
username=username,
|
| 12 |
password=password
|
| 13 |
)
|
| 14 |
|
| 15 |
-
|
| 16 |
-
os.environ["OPENAI_API_KEY"] = "sk-proj-hceIL56CC2zfjAvAlMjbT3BlbkFJyHKX2wbiQxsG9yy8dGJN"
|
|
|
|
| 1 |
|
| 2 |
from langchain_community.graphs import Neo4jGraph
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
load_dotenv() # This loads the variables from .env into os.environ
|
| 7 |
+
|
| 8 |
+
# Now use os.getenv to access your variables
|
| 9 |
+
url = os.getenv("NEO4J_URL")
|
| 10 |
+
username = os.getenv("NEO4J_USERNAME")
|
| 11 |
+
password = os.getenv("NEO4J_PASSWORD")
|
| 12 |
+
openai_api_key = os.getenv("OPENAI_API_KEY")
|
| 13 |
+
|
| 14 |
graph = Neo4jGraph(
|
| 15 |
url=url,
|
| 16 |
username=username,
|
| 17 |
password=password
|
| 18 |
)
|
| 19 |
|
| 20 |
+
|
|
|
kg_builder/src/main.py
CHANGED
|
@@ -7,7 +7,7 @@ from tqdm import tqdm
|
|
| 7 |
def main():
|
| 8 |
print("Starting the script...")
|
| 9 |
# Take Wikipedia article name as input
|
| 10 |
-
article_name = input("Enter the Wikipedia article name: ")
|
| 11 |
|
| 12 |
print(f"Loading documents for: {article_name}")
|
| 13 |
# Load and process the Wikipedia article
|
|
|
|
| 7 |
def main():
|
| 8 |
print("Starting the script...")
|
| 9 |
# Take Wikipedia article name as input
|
| 10 |
+
article_name = input("Enter the Wikipedia article name: ")
|
| 11 |
|
| 12 |
print(f"Loading documents for: {article_name}")
|
| 13 |
# Load and process the Wikipedia article
|