File size: 2,026 Bytes
1ddca65
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
import os

# Run init_save.py only once if trained_model is empty
if not os.path.exists("trained_model/config.json"):
    print("βš™οΈ Reinitializing EvoTransformer model...")
    import init_save


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()