Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -105,20 +105,26 @@ def generate_and_exec_cypher(input_query):
|
|
105 |
return run_cypher_on_neo4j(gen_query, gen_key)
|
106 |
|
107 |
def chatbot(input, history=[]):
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
return run_cypher_on_neo4j(gen_query, gen_key)
|
106 |
|
107 |
def chatbot(input, history=[]):
|
108 |
+
|
109 |
+
try:
|
110 |
+
output = str(generate_and_exec_cypher(input))
|
111 |
+
history.append((input, output))
|
112 |
+
return history, history
|
113 |
+
except:
|
114 |
+
# a bit of protection against exposed error messages
|
115 |
+
# we could log these situations in the backend to revisit later in development
|
116 |
+
return "I'm sorry, there was an error retrieving the information you requested."
|
117 |
+
|
118 |
+
gr.ChatInterface(fn = chatbot,
|
119 |
+
title = "Mahabharata Chatbot",
|
120 |
+
description = "powered by Neo4j",
|
121 |
+
theme = "soft",
|
122 |
+
chatbot = gr.Chatbot(height=500),
|
123 |
+
undo_btn = None,
|
124 |
+
clear_btn = "\U0001F5D1 Clear chat",
|
125 |
+
examples = ["Who killed Ghatotakach?",
|
126 |
+
"Who are the parents of Karna?",
|
127 |
+
"Who are the kids of Kunti?",
|
128 |
+
"Who are the siblings of Karna?"],
|
129 |
+
inputs = ["text",'state'],
|
130 |
+
outputs = ["chatbot",'state']).launch(debug = True, share=True)
|