peterpull commited on
Commit
8910981
1 Parent(s): 06cac98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -16,7 +16,7 @@ os.environ["OPENAI_API_KEY"] = os.environ['SECRET_CODE']
16
  DATASET_REPO_URL = "https://huggingface.co/datasets/peterpull/MediatorBot"
17
  DATA_FILENAME = "data.txt"
18
  INDEX_FILENAME = "index.json"
19
- DATA_FILE = os.path.join("data", DATA_FILENAME)
20
  INDEX_FILE = os.path.join("data", INDEX_FILENAME)
21
 
22
  # we need a write access token.
@@ -50,17 +50,9 @@ def store_message(chatinput: str, chatresponse: str):
50
  file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
51
  print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
52
 
53
- # Push back to hub every 10th time the function is called
54
- if store_message.count_calls % 10 == 0:
55
- print("Pushing back to Hugging Face model hub")
56
- # Call the push_to_hub() function to push the changes to the hub
57
- push_to_hub(commit_message="Added new chat data")
58
- store_message.count_calls += 1
59
 
60
  return generate_text()
61
 
62
- store_message.count_calls = 1 #initiases the count at one. We want to count how many messages stored before pushing back to repo.
63
-
64
  #gets the index file which is the context data
65
  def get_index(index_file_path):
66
  if os.path.exists(index_file_path):
@@ -72,7 +64,7 @@ def get_index(index_file_path):
72
  sys.exit()
73
 
74
  index = get_index(INDEX_FILE)
75
-
76
  # passes the prompt to the chatbot
77
  def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5):
78
  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."
 
16
  DATASET_REPO_URL = "https://huggingface.co/datasets/peterpull/MediatorBot"
17
  DATA_FILENAME = "data.txt"
18
  INDEX_FILENAME = "index.json"
19
+ DATA_FILEP = os.path.join("data", DATA_FILENAME)
20
  INDEX_FILE = os.path.join("data", INDEX_FILENAME)
21
 
22
  # we need a write access token.
 
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
57
  def get_index(index_file_path):
58
  if os.path.exists(index_file_path):
 
64
  sys.exit()
65
 
66
  index = get_index(INDEX_FILE)
67
+
68
  # passes the prompt to the chatbot
69
  def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5):
70
  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."