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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -34
app.py CHANGED
@@ -93,40 +93,16 @@ from huggingface_hub import HfApi, HfFolder
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
 
 
93
  api = HfApi()
94
 
95
  def write_to_file(file_name, value):
96
+ with open(file_name, 'a', encoding='utf-8') as file:
97
+ file.write(find_previous_question(value) + ';' + str(value) + '\n')
98
+
99
+ print(file_name)
100
+ api.upload_file(
101
+ path_or_fileobj='/' + file_name, # Use the file path instead of the file object
102
+ repo_id="mgreg555/docs_chat",
103
+ repo_type="space",
104
+ path_in_repo=file_name # Ensure this matches the file name if you want to keep the same name in the repo
105
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
 
108