Spaces:
Sleeping
Sleeping
Prathamesh1420
commited on
Commit
•
6d55f94
1
Parent(s):
dc1d706
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,12 @@ from dotenv import load_dotenv
|
|
7 |
|
8 |
# Load environment variables
|
9 |
load_dotenv()
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
|
15 |
# Initialize Neo4j graph
|
16 |
graph = Neo4jGraph(url=NEO4J_URI, username=NEO4J_USERNAME, password=NEO4J_PASSWORD)
|
@@ -52,9 +54,17 @@ if st.button("Find Director"):
|
|
52 |
# Debug: Print the raw response to check its structure
|
53 |
st.write("Raw Response:", response)
|
54 |
|
55 |
-
#
|
56 |
-
if response and '
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
else:
|
60 |
-
st.write("I don't know the answer.")
|
|
|
7 |
|
8 |
# Load environment variables
|
9 |
load_dotenv()
|
10 |
+
|
11 |
+
# Set environment variables
|
12 |
+
NEO4J_URI = os.getenv("NEO4J_URI")
|
13 |
+
NEO4J_USERNAME = os.getenv("NEO4J_USERNAME")
|
14 |
+
NEO4J_PASSWORD = os.getenv("NEO4J_PASSWORD")
|
15 |
+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
16 |
|
17 |
# Initialize Neo4j graph
|
18 |
graph = Neo4jGraph(url=NEO4J_URI, username=NEO4J_USERNAME, password=NEO4J_PASSWORD)
|
|
|
54 |
# Debug: Print the raw response to check its structure
|
55 |
st.write("Raw Response:", response)
|
56 |
|
57 |
+
# Extract the director's name from the full context
|
58 |
+
if response and 'full_context' in response:
|
59 |
+
full_context = response['full_context']
|
60 |
+
if full_context and isinstance(full_context, list) and len(full_context) > 0:
|
61 |
+
director_info = full_context[0]
|
62 |
+
director_name = director_info.get('p.name', None)
|
63 |
+
if director_name:
|
64 |
+
st.write(f"The director of the movie is {director_name}.")
|
65 |
+
else:
|
66 |
+
st.write("Could not find the director's name in the response.")
|
67 |
+
else:
|
68 |
+
st.write("No full context found in the response.")
|
69 |
else:
|
70 |
+
st.write("I don't know the answer.")
|