kavansaun commited on
Commit
78db410
·
verified ·
1 Parent(s): b5f0ebc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -18,6 +18,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
18
  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.
19
  global message_history # Made global variables so we can use them in the "predict_prompt" function.
20
  global instructions
 
21
  global user_dictionary # Pretty sure setting this as global is the only way to get it in the scope of this function but I dont know. This might be a leak for the user dictionary.
22
 
23
  new_id = str(uuid.uuid4()) # Id created by uuid.
@@ -29,7 +30,8 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
29
 
30
  # Creating a new file with the new id to save the user responses and the chat bot responses to the repository
31
  repo = g.get_user().get_repo("CATDATA")
32
- filename = str(new_id) + '.txt'
 
33
  repo.create_file(filename, "Saving" + filename, "")
34
 
35
  return gr.TextArea(new_id,visible=False) # Returning the "TextArea" object with what we want. Set visible to True if you want the id to appear when its made.
@@ -73,7 +75,7 @@ with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}
73
  print(content)
74
 
75
  #updating the repository with the entire message history
76
- file = repo.get_contents(user_id + ".txt")
77
  repo.update_file(file.path, commit_message, content, file.sha)
78
 
79
  return response # Returning the chat bot response
 
18
  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.
19
  global message_history # Made global variables so we can use them in the "predict_prompt" function.
20
  global instructions
21
+ global file_type
22
  global user_dictionary # Pretty sure setting this as global is the only way to get it in the scope of this function but I dont know. This might be a leak for the user dictionary.
23
 
24
  new_id = str(uuid.uuid4()) # Id created by uuid.
 
30
 
31
  # Creating a new file with the new id to save the user responses and the chat bot responses to the repository
32
  repo = g.get_user().get_repo("CATDATA")
33
+ file_type = '.txt'
34
+ filename = str(new_id) + file_type
35
  repo.create_file(filename, "Saving" + filename, "")
36
 
37
  return gr.TextArea(new_id,visible=False) # Returning the "TextArea" object with what we want. Set visible to True if you want the id to appear when its made.
 
75
  print(content)
76
 
77
  #updating the repository with the entire message history
78
+ file = repo.get_contents(user_id + file_type)
79
  repo.update_file(file.path, commit_message, content, file.sha)
80
 
81
  return response # Returning the chat bot response