peterpull commited on
Commit
08f7cb7
·
1 Parent(s): 03520f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -46,8 +46,7 @@ def generate_text() -> str:
46
 
47
 
48
  def push_to_hub(commit_message):
49
- repo.git_pull() # Make sure to pull the latest changes
50
- repo.git_add(os.path.join("data", DATA_FILENAME)) # Add the updated data file to the staged changes
51
  repo.git_commit(commit_message) # Commit the changes
52
  repo.push_to_hub(token=HF_TOKEN) # Push the changes to the remote repository
53
 
@@ -58,8 +57,8 @@ def store_message(chatinput: str, chatresponse: str):
58
  file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
59
  print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
60
 
61
- # Push back to hub every 3th time the function is called
62
- if store_message.count_calls % 3 == 0:
63
  print("Pushing back to Hugging Face model hub")
64
  # Call the push_to_hub() function to push the changes to the hub
65
  push_to_hub(commit_message="Added new chat data")
@@ -81,7 +80,7 @@ def get_index(index_file_path):
81
 
82
  index = get_index(INDEX_FILE)
83
 
84
- # passes the prompt to the chatbot
85
  def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5):
86
  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."
87
  response = index.query(prompt, response_mode="default")
 
46
 
47
 
48
  def push_to_hub(commit_message):
49
+ repo.git_add(DATA_FILE) # Add the updated data file to the staged changes
 
50
  repo.git_commit(commit_message) # Commit the changes
51
  repo.push_to_hub(token=HF_TOKEN) # Push the changes to the remote repository
52
 
 
57
  file.write(f"{datetime.now()},{chatinput},{chatresponse}\n")
58
  print(f"Wrote to datafile: {datetime.now()},{chatinput},{chatresponse}\n")
59
 
60
+ # Push back to hub every 2ND time the function is called
61
+ if store_message.count_calls % 2 == 0:
62
  print("Pushing back to Hugging Face model hub")
63
  # Call the push_to_hub() function to push the changes to the hub
64
  push_to_hub(commit_message="Added new chat data")
 
80
 
81
  index = get_index(INDEX_FILE)
82
 
83
+ # passes the prompt to the chatbot, queries the index, stores the output, returns the response
84
  def chatbot(input_text, mentioned_person='Mediator John Haynes', confidence_threshold=0.5):
85
  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."
86
  response = index.query(prompt, response_mode="default")