File size: 2,210 Bytes
1622676
 
5340d71
 
1622676
 
da4e68d
1622676
 
 
da4e68d
1622676
 
 
3eaea0f
1622676
 
3eaea0f
1622676
 
 
 
3eaea0f
1622676
3ec70fc
1622676
 
 
 
 
3eaea0f
1622676
 
3eaea0f
1622676
 
3eaea0f
3ec70fc
3eaea0f
1622676
 
 
 
3eaea0f
 
1622676
 
 
 
 
 
 
3eaea0f
1622676
 
 
3eaea0f
1622676
 
 
 
3eaea0f
 
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
64
import gradio as gr
from inference import evo_chat_predict
import subprocess

# Global chat history buffer
chat_history = []

# 🧠 Main chat handler
def chat_fn(user_input, option1, option2):
    global chat_history

    # Validate input
    if not user_input or not option1 or not option2:
        return "Please enter a message and both options.", chat_history

    options = [option1.strip(), option2.strip()]
    result = evo_chat_predict(chat_history, user_input, options)

    # Format Evo reply
    evo_response = f"**Answer:** {result['answer']}  \n**Reasoning:** {result['reasoning']}"
    chat_history.append(f"User: {user_input}")
    chat_history.append(f"Evo: {evo_response}")

    return evo_response, chat_history

# πŸ” Reset chat history
def clear_fn():
    global chat_history
    chat_history = []
    return "", "", "", []

# πŸ” Trigger Evo retraining
def retrain_model():
    try:
        subprocess.run(["python", "retrain_from_feedback.py"], check=True)
        return "βœ… Evo retrained successfully."
    except Exception as e:
        return f"❌ Retraining failed: {str(e)}"

# 🧠 Gradio UI layout
with gr.Blocks(title="EvoRAG – Real-Time Adaptive Reasoning AI") as demo:
    gr.Markdown("## 🧬 EvoRAG – The Evolving Reasoning AI")
    gr.Markdown("Ask a question, give two options, and Evo will decide with confidence. Then, retrain it live.")

    with gr.Row():
        with gr.Column(scale=4):
            user_input = gr.Textbox(label="Your Question", lines=2)
            option1 = gr.Textbox(label="Option 1")
            option2 = gr.Textbox(label="Option 2")
            submit = gr.Button("🧠 Ask Evo")
            clear = gr.Button("πŸ” Clear")
            retrain = gr.Button("πŸ“ˆ Retrain Evo from Feedback")

        with gr.Column(scale=6):
            evo_reply = gr.Markdown()
            chat_display = gr.HighlightedText(label="Conversation History")

    submit.click(fn=chat_fn, inputs=[user_input, option1, option2],
                 outputs=[evo_reply, chat_display])
    clear.click(fn=clear_fn, inputs=[], outputs=[user_input, option1, option2, chat_display])
    retrain.click(fn=retrain_model, inputs=[], outputs=evo_reply)

demo.launch()