Spaces:
Sleeping
Sleeping
Prathamesh1420
commited on
Commit
•
5c7d5dc
1
Parent(s):
e7addce
Update app.py
Browse files
app.py
CHANGED
@@ -5,36 +5,43 @@ from langchain_groq import ChatGroq
|
|
5 |
from langchain.chains import GraphCypherQAChain
|
6 |
from dotenv import load_dotenv
|
7 |
|
8 |
-
# Load environment variables
|
9 |
# Load environment variables
|
10 |
load_dotenv()
|
|
|
|
|
11 |
NEO4J_URI = "neo4j+s://64beefae.databases.neo4j.io"
|
12 |
NEO4J_USERNAME = "neo4j"
|
13 |
NEO4J_PASSWORD = "OTj5yGnWLF59yx4UX1g3xABarVOvVKiM3CT9L4bNkF8"
|
14 |
GROQ_API_KEY = "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"
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
m
|
30 |
-
m.
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
# Initialize LLM
|
40 |
llm = ChatGroq(groq_api_key=GROQ_API_KEY, model_name="Gemma2-9b-It")
|
|
|
5 |
from langchain.chains import GraphCypherQAChain
|
6 |
from dotenv import load_dotenv
|
7 |
|
|
|
8 |
# Load environment variables
|
9 |
load_dotenv()
|
10 |
+
|
11 |
+
# Set environment variables
|
12 |
NEO4J_URI = "neo4j+s://64beefae.databases.neo4j.io"
|
13 |
NEO4J_USERNAME = "neo4j"
|
14 |
NEO4J_PASSWORD = "OTj5yGnWLF59yx4UX1g3xABarVOvVKiM3CT9L4bNkF8"
|
15 |
GROQ_API_KEY = "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"
|
16 |
|
17 |
+
# Print environment variables for debugging
|
18 |
+
print("NEO4J_URI:", NEO4J_URI)
|
19 |
+
print("NEO4J_USERNAME:", NEO4J_USERNAME)
|
20 |
+
print("NEO4J_PASSWORD:", NEO4J_PASSWORD)
|
21 |
+
|
22 |
+
try:
|
23 |
+
# Initialize Neo4j graph
|
24 |
+
graph = Neo4jGraph(url=NEO4J_URI, username=NEO4J_USERNAME, password=NEO4J_PASSWORD)
|
25 |
+
|
26 |
+
# Load movie dataset into Neo4j
|
27 |
+
moview_query = """
|
28 |
+
LOAD CSV WITH HEADERS FROM
|
29 |
+
'https://raw.githubusercontent.com/Pk-Kolhapurkar/graphdb_neo4j/main/indian%20movies.csv' AS row
|
30 |
+
MERGE (m:Movie {id: row.ID})
|
31 |
+
SET m.year = toInteger(row.Year),
|
32 |
+
m.title = row['Movie Name'],
|
33 |
+
m.timing = toInteger(row['Timing(min)']),
|
34 |
+
m.rating = toFloat(row['Rating(10)']),
|
35 |
+
m.votes = toInteger(row.Votes),
|
36 |
+
m.language = row.Language
|
37 |
+
FOREACH (genre IN split(row.Genre, '|') |
|
38 |
+
MERGE (g:Genre {name: trim(genre)})
|
39 |
+
MERGE (m)-[:IN_GENRE]->(g))
|
40 |
+
"""
|
41 |
+
graph.query(moview_query)
|
42 |
+
graph.refresh_schema()
|
43 |
+
except Exception as e:
|
44 |
+
print("Error initializing Neo4jGraph:", str(e))
|
45 |
|
46 |
# Initialize LLM
|
47 |
llm = ChatGroq(groq_api_key=GROQ_API_KEY, model_name="Gemma2-9b-It")
|