peterpull commited on
Commit
3e2554b
·
1 Parent(s): b0e433a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -49,8 +49,12 @@ 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
-
54
  return generate_text()
55
 
56
  #gets the index file which is the context data
@@ -63,12 +67,13 @@ def get_index(index_file_path):
63
  print(f"Error: '{index_file_path}' does not exist.")
64
  sys.exit()
65
 
66
- debuggerindex_file_path = "./index/index.json"
67
- index = get_index(debuggerindex_file_path)
68
 
69
  # passes the prompt to the chatbot
 
70
  def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5):
71
- prompt = f"You are {mentioned_person}. Answer this: {input_text}. Only reply from the contextual data, or say you don't know. At the end of your answer ask an insightful question."
72
  response = index.query(prompt, response_mode="default")
73
 
74
  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
+ #trial - take out if fails
54
+ with open('backup.txt', "a") as file:
55
+ file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
56
+ print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
57
 
 
58
  return generate_text()
59
 
60
  #gets the index file which is the context data
 
67
  print(f"Error: '{index_file_path}' does not exist.")
68
  sys.exit()
69
 
70
+ print(f"Creating index...")
71
+ index = get_index(INDEX_FILE)
72
 
73
  # passes the prompt to the chatbot
74
+
75
  def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5):
76
+ prompt = f"You are {mentioned_person}. Answer this: {input_text}. Reply from the contextual data or say you don't know. To finish, ask an insightful question."
77
  response = index.query(prompt, response_mode="default")
78
 
79
  store_message(input_text,response)