mgreg555 commited on
Commit
52c813c
·
verified ·
1 Parent(s): 61deff8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -13
app.py CHANGED
@@ -88,24 +88,45 @@ def chat(query,history):
88
  """## Setting up UI with gradio"""
89
 
90
  import gradio as gr
91
-
92
- from huggingface_hub import HfApi
93
 
94
  api = HfApi()
95
 
96
  def write_to_file(file_name, value):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  # Write to the file
98
- with open(file_name, 'a', encoding='utf-8') as file:
99
- file.write(find_previous_question(value) + ';' + str(value) + '\n')
100
-
101
- print(file_name)
102
- # Upload the file using its path
103
- api.upload_file(
104
- path_or_fileobj=file_name, # Use the file path instead of the file object
105
- repo_id="mgreg555/docs_chat",
106
- repo_type="space",
107
- path_in_repo=file_name # Ensure this matches the file name if you want to keep the same name in the repo
108
- )
109
 
110
 
111
 
 
88
  """## Setting up UI with gradio"""
89
 
90
  import gradio as gr
91
+ from huggingface_hub import HfApi, HfFolder
 
92
 
93
  api = HfApi()
94
 
95
  def write_to_file(file_name, value):
96
+
97
+
98
+ # Initialize the HfApi
99
+ hf_api = HfApi()
100
+
101
+ # Specify your repository name
102
+ repo_name = "mgreg555/docs_chat"
103
+
104
+ # Specify the file path you want to update
105
+ file_path = "good.txt"
106
+
107
+ # Specify the new content you want to upload
108
+ new_content = "This is the new content of the file."
109
+
110
+ # Get the repository folder
111
+ repo_folder = HfFolder(repo_name)
112
+
113
+ # Update the file
114
+ repo_folder.save_file(file_path, new_content)
115
+
116
+ # Push the changes to the repository
117
+ repo_folder.git_push()
118
  # Write to the file
119
+ # with open(file_name, 'a', encoding='utf-8') as file:
120
+ # file.write(find_previous_question(value) + ';' + str(value) + '\n')
121
+
122
+ # print(file_name)
123
+ # # Upload the file using its path
124
+ # api.upload_file(
125
+ # path_or_fileobj=file_name, # Use the file path instead of the file object
126
+ # repo_id="mgreg555/docs_chat",
127
+ # repo_type="space",
128
+ # path_in_repo=file_name # Ensure this matches the file name if you want to keep the same name in the repo
129
+ # )
130
 
131
 
132