zlmqi commited on
Commit
c262e5a
1 Parent(s): 76bd41a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -55,12 +55,12 @@ class Chatbot:
55
  self.history_file = dataset_dir / f"chat_log_{uuid4()}.json"
56
  #self.history_file = f"chat_log_{uuid.uuid4()}.json"
57
 
58
- scheduler = CommitScheduler(
59
- repo_id="history_data",
60
- repo_type="dataset",
61
- folder_path=dataset_dir,
62
- path_in_repo="data",
63
- )
64
 
65
  def generate_response(self, user_input):
66
  query_engine = index.as_query_engine(llm=llm_predictor)
@@ -71,6 +71,7 @@ class Chatbot:
71
 
72
  return message
73
 
 
74
  def load_chat_history(self):
75
  try:
76
  with open(self.history_file, 'r') as f:
@@ -102,7 +103,7 @@ class Chatbot:
102
 
103
  def save_chat_history(self):
104
  with scheduler.lock:
105
- with open(self.history_file, 'w') as f:
106
  json.dump(self.chat_history, f)
107
  f.write("\n")
108
 
 
55
  self.history_file = dataset_dir / f"chat_log_{uuid4()}.json"
56
  #self.history_file = f"chat_log_{uuid.uuid4()}.json"
57
 
58
+ #scheduler = CommitScheduler(
59
+ # repo_id="index",
60
+ # repo_type="dataset",
61
+ # folder_path=dataset_dir,
62
+ # path_in_repo="data",
63
+ #)
64
 
65
  def generate_response(self, user_input):
66
  query_engine = index.as_query_engine(llm=llm_predictor)
 
71
 
72
  return message
73
 
74
+ # do not need this function if use append mode when dump data in file
75
  def load_chat_history(self):
76
  try:
77
  with open(self.history_file, 'r') as f:
 
103
 
104
  def save_chat_history(self):
105
  with scheduler.lock:
106
+ with self.history_file.open("a") as f:
107
  json.dump(self.chat_history, f)
108
  f.write("\n")
109