wholewhale commited on
Commit
e9ae70a
·
1 Parent(s): 1d3cf79

added db clear var

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -23,6 +23,7 @@ def pdf_changes(pdf_doc):
23
  text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
24
  texts = text_splitter.split_documents(documents)
25
  embeddings = OpenAIEmbeddings()
 
26
  db = Chroma.from_documents(texts, embeddings)
27
  retriever = db.as_retriever()
28
  global qa
@@ -33,8 +34,9 @@ def pdf_changes(pdf_doc):
33
  return "Ready"
34
 
35
  def clear_data():
36
- global qa
37
  qa = None
 
38
  return "Data cleared"
39
 
40
  def add_text(history, text):
@@ -62,14 +64,15 @@ def infer(question, history):
62
  return result["answer"]
63
 
64
  def auto_clear_data():
65
- global qa, last_interaction_time
66
- if time.time() - last_interaction_time > 600:
67
  qa = None
68
-
 
69
  def periodic_clear():
70
  while True:
71
  auto_clear_data()
72
- time.sleep(60)
73
 
74
  threading.Thread(target=periodic_clear).start()
75
 
 
23
  text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
24
  texts = text_splitter.split_documents(documents)
25
  embeddings = OpenAIEmbeddings()
26
+ global db
27
  db = Chroma.from_documents(texts, embeddings)
28
  retriever = db.as_retriever()
29
  global qa
 
34
  return "Ready"
35
 
36
  def clear_data():
37
+ global qa, db
38
  qa = None
39
+ db = None
40
  return "Data cleared"
41
 
42
  def add_text(history, text):
 
64
  return result["answer"]
65
 
66
  def auto_clear_data():
67
+ global qa, db, last_interaction_time
68
+ if time.time() - last_interaction_time > 1000:
69
  qa = None
70
+ db = None
71
+
72
  def periodic_clear():
73
  while True:
74
  auto_clear_data()
75
+ time.sleep(600)
76
 
77
  threading.Thread(target=periodic_clear).start()
78