Commit
·
2545c31
1
Parent(s):
369d9fb
error handling
Browse files
app.py
CHANGED
@@ -53,6 +53,7 @@ def bot(history):
|
|
53 |
return history
|
54 |
|
55 |
def infer(question, history):
|
|
|
56 |
res = []
|
57 |
for human, ai in history[:-1]:
|
58 |
pair = (human, ai)
|
@@ -62,11 +63,14 @@ def infer(question, history):
|
|
62 |
query = question
|
63 |
result = qa({"question": query, "chat_history": chat_history, "system:":"This is a world-class summarizing AI, be helpful."})
|
64 |
return result["answer"]
|
|
|
|
|
65 |
|
66 |
def auto_clear_data():
|
67 |
-
global qa, last_interaction_time
|
68 |
if time.time() - last_interaction_time > 600:
|
69 |
qa = None
|
|
|
70 |
|
71 |
def periodic_clear():
|
72 |
while True:
|
|
|
53 |
return history
|
54 |
|
55 |
def infer(question, history):
|
56 |
+
try:
|
57 |
res = []
|
58 |
for human, ai in history[:-1]:
|
59 |
pair = (human, ai)
|
|
|
63 |
query = question
|
64 |
result = qa({"question": query, "chat_history": chat_history, "system:":"This is a world-class summarizing AI, be helpful."})
|
65 |
return result["answer"]
|
66 |
+
except Exception as e:
|
67 |
+
return f"Error querying chatbot: {str(e)}"
|
68 |
|
69 |
def auto_clear_data():
|
70 |
+
global qa, da, last_interaction_time
|
71 |
if time.time() - last_interaction_time > 600:
|
72 |
qa = None
|
73 |
+
db = None
|
74 |
|
75 |
def periodic_clear():
|
76 |
while True:
|