SamiKoen commited on
Commit
8df7630
·
verified ·
1 Parent(s): e182566

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py CHANGED
@@ -168,6 +168,38 @@ def save_chat(chatbot):
168
  def reset_textbox():
169
  return gr.update(value='')
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  # Gradio arayüzü
172
  demo_css = """
173
  #send_button, #save_button {
 
168
  def reset_textbox():
169
  return gr.update(value='')
170
 
171
+ from huggingface_hub import HfApi
172
+
173
+ def upload_logs_to_hf(repo_id: str, hf_token: str, local_log_file: str = "chat_logs.txt"):
174
+ """
175
+ Log dosyasını Hugging Face Hub repository'sine yükler.
176
+
177
+ Args:
178
+ repo_id (str): Repository kimliği (örn. "kullaniciadi/space-ismi").
179
+ hf_token (str): Hugging Face API token'ınız.
180
+ local_log_file (str): Yüklenecek log dosyasının yolu.
181
+ """
182
+ api = HfApi(token=hf_token)
183
+
184
+ try:
185
+ api.upload_file(
186
+ path_or_fileobj=local_log_file,
187
+ path_in_repo=local_log_file,
188
+ repo_id=repo_id,
189
+ repo_type="space",
190
+ commit_message="Log dosyası güncellendi"
191
+ )
192
+ print(f"Log dosyası başarıyla yüklendi: {local_log_file}")
193
+ except Exception as e:
194
+ print(f"Log dosyası yüklenirken hata oluştu: {e}")
195
+
196
+ # Örnek kullanım:
197
+ if __name__ == "__main__":
198
+ HF_REPO_ID = "kullaniciadi/space-ismi" # Kendi repo kimliğinizi girin.
199
+ HF_TOKEN = "your_hf_token_here" # Oluşturduğunuz token'ı buraya ekleyin.
200
+ upload_logs_to_hf(HF_REPO_ID, HF_TOKEN)
201
+
202
+
203
  # Gradio arayüzü
204
  demo_css = """
205
  #send_button, #save_button {