Commit
·
d4eee96
1
Parent(s):
b101fbd
auto clear and update fxn
Browse files
app.py
CHANGED
@@ -67,7 +67,7 @@ def pdf_changes(pdf_doc):
|
|
67 |
retriever=retriever,
|
68 |
return_source_documents=False
|
69 |
)
|
70 |
-
summary_box.
|
71 |
return f"Ready. Full Summary loaded."
|
72 |
|
73 |
except Exception as e:
|
@@ -115,16 +115,22 @@ def infer(question, history):
|
|
115 |
except Exception as e:
|
116 |
return f"Error querying chatbot: {str(e)}"
|
117 |
|
118 |
-
def auto_clear_data():
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
-
def periodic_clear():
|
125 |
-
while True:
|
126 |
-
auto_clear_data()
|
127 |
-
time.sleep(1000)
|
128 |
|
129 |
threading.Thread(target=periodic_clear).start()
|
130 |
|
|
|
67 |
retriever=retriever,
|
68 |
return_source_documents=False
|
69 |
)
|
70 |
+
summary_box.set_value(full_summary)
|
71 |
return f"Ready. Full Summary loaded."
|
72 |
|
73 |
except Exception as e:
|
|
|
115 |
except Exception as e:
|
116 |
return f"Error querying chatbot: {str(e)}"
|
117 |
|
118 |
+
def auto_clear_data():
|
119 |
+
global qa, db, last_interaction_time
|
120 |
+
buffer_time = 300 # 5 minutes buffer time
|
121 |
+
if time.time() - last_interaction_time > (1000 + buffer_time):
|
122 |
+
try:
|
123 |
+
qa = None
|
124 |
+
db = None
|
125 |
+
print("Data cleared successfully.") # Logging
|
126 |
+
except Exception as e:
|
127 |
+
print(f"Error while clearing data: {str(e)}") # Exception Handling
|
128 |
+
|
129 |
+
def periodic_clear():
|
130 |
+
while True:
|
131 |
+
auto_clear_data()
|
132 |
+
time.sleep(1000) # Sleep for 1000 seconds
|
133 |
|
|
|
|
|
|
|
|
|
134 |
|
135 |
threading.Thread(target=periodic_clear).start()
|
136 |
|