Spaces:
Running
Running
File size: 1,826 Bytes
c615588 312dbba 923fd6e c615588 923fd6e c615588 568d79a c615588 312dbba c615588 e256998 c615588 488dba6 c615588 488dba6 c615588 488dba6 c615588 488dba6 c615588 488dba6 c615588 488dba6 c615588 488dba6 c615588 488dba6 c615588 488dba6 e695177 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import os
import gradio as gr
from watchdog import manual_retrain
from inference import generate_response
from logger import log_feedback
from dashboard import display_dashboard
# β
Ensure model is initialized
if not os.path.exists("trained_model/config.json"):
print("π¦ No model found in 'trained_model/'. Initializing...")
exec(open("init_save.py").read())
print("===== Application Startup at 2025-07-14 12:XX:XX =====")
# β
Interface logic
def evo_chat(goal, sol1, sol2):
response = generate_response(goal, sol1, sol2)
return response
def retrain_model():
success = manual_retrain()
return "β
Retrained successfully!" if success else "β οΈ Retrain failed."
def log_user_feedback(goal, sol1, sol2, correct):
log_feedback(goal, sol1, sol2, correct)
return "β
Feedback logged. Thank you!"
# β
UI
with gr.Blocks(title="EvoTransformer v2.1") as demo:
gr.Markdown("### π§ EvoTransformer v2.1 β Compare Options and Learn")
with gr.Row():
goal = gr.Textbox(label="Goal")
with gr.Row():
sol1 = gr.Textbox(label="Option 1")
sol2 = gr.Textbox(label="Option 2")
output = gr.Textbox(label="Model Suggestion")
run_btn = gr.Button("π Compare")
run_btn.click(fn=evo_chat, inputs=[goal, sol1, sol2], outputs=output)
with gr.Row():
correct = gr.Radio(["Solution 1", "Solution 2"], label="Which was better?")
log_btn = gr.Button("β
Log Feedback")
log_btn.click(fn=log_user_feedback, inputs=[goal, sol1, sol2, correct], outputs=None)
with gr.Accordion("π Dashboard", open=False):
display_dashboard()
retrain_btn = gr.Button("β»οΈ Retrain Evo")
retrain_status = gr.Textbox(label="Retrain Status")
retrain_btn.click(fn=retrain_model, outputs=retrain_status)
demo.launch()
|