Update app.py
Browse files
app.py
CHANGED
@@ -41,12 +41,13 @@ for item in root.findall('item'):
|
|
41 |
item_info = (stockAmount, price)
|
42 |
products.append((name, item_info, full_name))
|
43 |
|
44 |
-
# HF_TOKEN
|
45 |
-
|
46 |
-
if not
|
47 |
-
raise ValueError("
|
48 |
-
|
49 |
-
|
|
|
50 |
|
51 |
def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=None, history=None):
|
52 |
if chatbot is None:
|
@@ -100,6 +101,7 @@ def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=None,
|
|
100 |
except Exception as e:
|
101 |
print(f"Dosya yazma hatası (Kullanıcı): {e}")
|
102 |
|
|
|
103 |
chatbot.append({"role": "user", "content": inputs})
|
104 |
response = requests.post(API_URL, headers=headers, json=payload, stream=True)
|
105 |
print(f"Logging: Response code - {response.status_code}")
|
@@ -171,7 +173,7 @@ def upload_logs_to_hf(repo_id: str, hf_token: str, local_log_file: str = "chat_l
|
|
171 |
hf_token (str): Hugging Face API token'ınız.
|
172 |
local_log_file (str): Yüklenecek log dosyasının yolu.
|
173 |
"""
|
174 |
-
api = HfApi(token=
|
175 |
try:
|
176 |
api.upload_file(
|
177 |
path_or_fileobj=local_log_file,
|
@@ -187,8 +189,8 @@ def upload_logs_to_hf(repo_id: str, hf_token: str, local_log_file: str = "chat_l
|
|
187 |
def save_chat_and_upload(chatbot):
|
188 |
save_status = save_chat(chatbot)
|
189 |
HF_REPO_ID = "SamiKoen/BF" # Kendi repo kimliğinizi girin.
|
190 |
-
|
191 |
-
upload_logs_to_hf(HF_REPO_ID,
|
192 |
return save_status
|
193 |
|
194 |
# Gradio arayüzü
|
|
|
41 |
item_info = (stockAmount, price)
|
42 |
products.append((name, item_info, full_name))
|
43 |
|
44 |
+
# HF_TOKEN yerine "hfapi" ortam değişkenini alıyoruz
|
45 |
+
hfapi = os.getenv("hfapi")
|
46 |
+
if not hfapi:
|
47 |
+
raise ValueError("hfapi ortam değişkeni ayarlanmamış!")
|
48 |
+
|
49 |
+
# Repository oluşturma (repo adı "BF" kullanıcı adınızla uyumlu olmalı; space_sdk eklenmiş)
|
50 |
+
create_repo("BF", token=hfapi, repo_type="space", space_sdk="gradio", exist_ok=True)
|
51 |
|
52 |
def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=None, history=None):
|
53 |
if chatbot is None:
|
|
|
101 |
except Exception as e:
|
102 |
print(f"Dosya yazma hatası (Kullanıcı): {e}")
|
103 |
|
104 |
+
# Chatbot'a kullanıcı mesajını ekle
|
105 |
chatbot.append({"role": "user", "content": inputs})
|
106 |
response = requests.post(API_URL, headers=headers, json=payload, stream=True)
|
107 |
print(f"Logging: Response code - {response.status_code}")
|
|
|
173 |
hf_token (str): Hugging Face API token'ınız.
|
174 |
local_log_file (str): Yüklenecek log dosyasının yolu.
|
175 |
"""
|
176 |
+
api = HfApi(token=hf_token)
|
177 |
try:
|
178 |
api.upload_file(
|
179 |
path_or_fileobj=local_log_file,
|
|
|
189 |
def save_chat_and_upload(chatbot):
|
190 |
save_status = save_chat(chatbot)
|
191 |
HF_REPO_ID = "SamiKoen/BF" # Kendi repo kimliğinizi girin.
|
192 |
+
hfapi = os.getenv("hfapi")
|
193 |
+
upload_logs_to_hf(HF_REPO_ID, hfapi)
|
194 |
return save_status
|
195 |
|
196 |
# Gradio arayüzü
|