Update app.py
Browse files
app.py
CHANGED
|
@@ -101,6 +101,9 @@ model_status_text = load_model(DEFAULT_MODEL)
|
|
| 101 |
FEEDBACK_FILE = os.path.join(os.path.dirname(__file__), "feedback_log.csv")
|
| 102 |
|
| 103 |
|
|
|
|
|
|
|
|
|
|
| 104 |
def init_feedback_file():
|
| 105 |
"""Create CSV with header if it doesn't exist yet."""
|
| 106 |
if not os.path.exists(FEEDBACK_FILE):
|
|
@@ -133,6 +136,21 @@ def log_feedback(bias_mode, prompt, response, thumb):
|
|
| 133 |
)
|
| 134 |
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
# ------------------------
|
| 137 |
# System prompts per bias
|
| 138 |
# ------------------------
|
|
@@ -481,4 +499,22 @@ with gr.Blocks() as demo:
|
|
| 481 |
outputs=[model_status],
|
| 482 |
)
|
| 483 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
demo.launch()
|
|
|
|
| 101 |
FEEDBACK_FILE = os.path.join(os.path.dirname(__file__), "feedback_log.csv")
|
| 102 |
|
| 103 |
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
def init_feedback_file():
|
| 108 |
"""Create CSV with header if it doesn't exist yet."""
|
| 109 |
if not os.path.exists(FEEDBACK_FILE):
|
|
|
|
| 136 |
)
|
| 137 |
|
| 138 |
|
| 139 |
+
def view_feedback_log():
|
| 140 |
+
if not os.path.exists(FEEDBACK_FILE):
|
| 141 |
+
return "feedback_log.csv does NOT exist yet or is empty."
|
| 142 |
+
try:
|
| 143 |
+
with open(FEEDBACK_FILE, "r", encoding="utf-8") as f:
|
| 144 |
+
content = f.read()
|
| 145 |
+
# Don't spam UI if huge:
|
| 146 |
+
if len(content) > 5000:
|
| 147 |
+
return "feedback_log.csv exists. Showing first 5000 chars:\n\n" + content[:5000]
|
| 148 |
+
return content
|
| 149 |
+
except Exception as e:
|
| 150 |
+
return f"Error reading feedback_log.csv: {e}"
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
|
| 154 |
# ------------------------
|
| 155 |
# System prompts per bias
|
| 156 |
# ------------------------
|
|
|
|
| 499 |
outputs=[model_status],
|
| 500 |
)
|
| 501 |
|
| 502 |
+
gr.Markdown("## 📄 Inspect feedback log (runtime only)")
|
| 503 |
+
|
| 504 |
+
feedback_view = gr.Textbox(
|
| 505 |
+
label="feedback_log.csv (preview)",
|
| 506 |
+
lines=10,
|
| 507 |
+
interactive=False,
|
| 508 |
+
)
|
| 509 |
+
|
| 510 |
+
btn_view_log = gr.Button("Show feedback_log.csv contents")
|
| 511 |
+
|
| 512 |
+
btn_view_log.click(
|
| 513 |
+
fn=view_feedback_log,
|
| 514 |
+
inputs=[],
|
| 515 |
+
outputs=[feedback_view],
|
| 516 |
+
)
|
| 517 |
+
|
| 518 |
+
|
| 519 |
+
|
| 520 |
demo.launch()
|