lobrien001
commited on
Commit
•
e3fe553
1
Parent(s):
8a6b182
Update app.py
Browse files
app.py
CHANGED
@@ -10,9 +10,16 @@ from transformers import pipeline
|
|
10 |
from sklearn.metrics import precision_score, recall_score, f1_score
|
11 |
import requests
|
12 |
from datasets import load_dataset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# --- Logging Setup ---
|
15 |
-
logging.basicConfig(filename=
|
16 |
logging.debug("Logging setup complete.")
|
17 |
|
18 |
# Load the model
|
@@ -183,8 +190,8 @@ body {
|
|
183 |
|
184 |
def update_logs(logs_display):
|
185 |
while True:
|
186 |
-
with open(
|
187 |
-
logs =
|
188 |
logs_display.value = "".join(logs[-10:]) # Display last 10 lines
|
189 |
time.sleep(1) # Update every 1 second
|
190 |
|
|
|
10 |
from sklearn.metrics import precision_score, recall_score, f1_score
|
11 |
import requests
|
12 |
from datasets import load_dataset
|
13 |
+
import os
|
14 |
+
|
15 |
+
# --- Ensure chat_log.txt exists ---
|
16 |
+
log_file = "chat_log.txt"
|
17 |
+
if not os.path.exists(log_file):
|
18 |
+
with open(log_file, 'w') as f:
|
19 |
+
pass # Just create the file
|
20 |
|
21 |
# --- Logging Setup ---
|
22 |
+
logging.basicConfig(filename=log_file, level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
23 |
logging.debug("Logging setup complete.")
|
24 |
|
25 |
# Load the model
|
|
|
190 |
|
191 |
def update_logs(logs_display):
|
192 |
while True:
|
193 |
+
with open(log_file, "r") as log_file_handler:
|
194 |
+
logs = log_file_handler.readlines()
|
195 |
logs_display.value = "".join(logs[-10:]) # Display last 10 lines
|
196 |
time.sleep(1) # Update every 1 second
|
197 |
|