peterpull commited on
Commit
16c492d
·
1 Parent(s): b5fa340

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -49,15 +49,18 @@ def store_message(chatinput: str, chatresponse: str):
49
  with open(DATA_FILE, "a") as file:
50
  file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
51
  print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
52
-
53
- repo.push_to_hub() # Push changes to the remote repository
54
-
 
55
  return generate_text()
56
 
57
 
58
  #gets the index file which is the context data
59
  def get_index(index_file_path):
60
  if os.path.exists(index_file_path):
 
 
61
  return GPTSimpleVectorIndex.load_from_disk(index_file_path)
62
  else:
63
  print(f"Error: '{index_file_path}' does not exist.")
@@ -66,7 +69,7 @@ def get_index(index_file_path):
66
  # passes the prompt to the chatbot
67
  def chatbot(input_text, mentioned_person='Mediator John Haynes'):
68
  index = get_index(INDEX_FILE)
69
- prompt = f"You are {mentioned_person}: {input_text}\n\n At the end of your answer ask a provocative question."
70
  response = index.query(prompt, response_mode="compact")
71
 
72
  store_message(input_text,response)
 
49
  with open(DATA_FILE, "a") as file:
50
  file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
51
  print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
52
+
53
+ repo.push_to_hub(files=[str(os.path.join("data", DATA_FILENAME))])
54
+ print("pushed data.txt to repo")
55
+
56
  return generate_text()
57
 
58
 
59
  #gets the index file which is the context data
60
  def get_index(index_file_path):
61
  if os.path.exists(index_file_path):
62
+ index_size = os.path.getsize(index_file_path)
63
+ print(f"Size of {index_file_path}: {index_size} bytes") #let me know how big json file is.
64
  return GPTSimpleVectorIndex.load_from_disk(index_file_path)
65
  else:
66
  print(f"Error: '{index_file_path}' does not exist.")
 
69
  # passes the prompt to the chatbot
70
  def chatbot(input_text, mentioned_person='Mediator John Haynes'):
71
  index = get_index(INDEX_FILE)
72
+ prompt = f"You are {mentioned_person}: {input_text}\n\n At the end of your answer ask a provocative question."
73
  response = index.query(prompt, response_mode="compact")
74
 
75
  store_message(input_text,response)