kavansaun commited on
Commit
5731ee8
·
verified ·
1 Parent(s): 471de47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -15,6 +15,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
15
  def load_user(): # When the chatblock loads, the message history is initialized, the instructions are initialized, and the users id is created, sent, and made visible to the ui variable above.
16
  global message_history # Made global variables so we can use them in the "predict_prompt" function.
17
  global instructions
 
18
 
19
  message_history = [] # Empty list for message history.
20
  instructions = 'Be accommodative or unaccommodative' # Change the message under the apostrophes to change the instructions you want the bot to inhibit.
@@ -47,6 +48,14 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
47
 
48
  response = [(message_history[i]["content"], message_history[i+1]["content"]) for i in range(1, len(message_history)-1, 2)] # Variable for the response
49
 
 
 
 
 
 
 
 
 
50
  # This chunk of code basically loops through the message history so we can write it to a save file repository.
51
  content = ''
52
  for i in range(1,len(message_history), 1):
@@ -56,6 +65,10 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
56
  content += ('Bot: ' + message_history[i]["content"] + '\n')
57
  else:
58
  content += ''
 
 
 
 
59
 
60
  return response # Returning the response
61
 
 
15
  def load_user(): # When the chatblock loads, the message history is initialized, the instructions are initialized, and the users id is created, sent, and made visible to the ui variable above.
16
  global message_history # Made global variables so we can use them in the "predict_prompt" function.
17
  global instructions
18
+ global filename
19
 
20
  message_history = [] # Empty list for message history.
21
  instructions = 'Be accommodative or unaccommodative' # Change the message under the apostrophes to change the instructions you want the bot to inhibit.
 
48
 
49
  response = [(message_history[i]["content"], message_history[i+1]["content"]) for i in range(1, len(message_history)-1, 2)] # Variable for the response
50
 
51
+ # Add token and connect to repository (again)
52
+ g = Github(token)
53
+
54
+ # Repository details
55
+ repo = g.get_user().get_repo("CATDATA")
56
+ file_path = filename
57
+ commit_message = "Updating file content"
58
+
59
  # This chunk of code basically loops through the message history so we can write it to a save file repository.
60
  content = ''
61
  for i in range(1,len(message_history), 1):
 
65
  content += ('Bot: ' + message_history[i]["content"] + '\n')
66
  else:
67
  content += ''
68
+
69
+ #updating the repository with the entire message history
70
+ file = repo.get_contents(file_path)
71
+ repo.update_file(file.path, commit_message, content, file.sha)
72
 
73
  return response # Returning the response
74