Update app.py
Browse files
app.py
CHANGED
@@ -168,14 +168,18 @@ def save_chat(chatbot):
|
|
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. "
|
179 |
hf_token (str): Hugging Face API token'ınız.
|
180 |
local_log_file (str): Yüklenecek log dosyasının yolu.
|
181 |
"""
|
@@ -286,4 +290,4 @@ with gr.Blocks(css=demo_css, theme=theme) as demo:
|
|
286 |
send_button.click(reset_textbox, [], [inputs])
|
287 |
save_button.click(save_chat_and_upload, [chatbot], [save_status])
|
288 |
|
289 |
-
demo.queue(max_size=10).launch(debug=True)
|
|
|
168 |
def reset_textbox():
|
169 |
return gr.update(value='')
|
170 |
|
171 |
+
from huggingface_hub import HfApi, create_repo
|
172 |
+
|
173 |
+
# Repository oluşturma (eğer mevcut değilse)
|
174 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
175 |
+
create_repo("BF", token=HF_TOKEN, repo_type="space", exist_ok=True)
|
176 |
|
177 |
def upload_logs_to_hf(repo_id: str, hf_token: str, local_log_file: str = "chat_logs.txt"):
|
178 |
"""
|
179 |
Log dosyasını Hugging Face Hub repository'sine yükler.
|
180 |
|
181 |
Args:
|
182 |
+
repo_id (str): Repository kimliği (örn. "SamiKoen/BF").
|
183 |
hf_token (str): Hugging Face API token'ınız.
|
184 |
local_log_file (str): Yüklenecek log dosyasının yolu.
|
185 |
"""
|
|
|
290 |
send_button.click(reset_textbox, [], [inputs])
|
291 |
save_button.click(save_chat_and_upload, [chatbot], [save_status])
|
292 |
|
293 |
+
demo.queue(max_size=10).launch(debug=True)
|