Spaces:
Sleeping
Sleeping
import gradio as gr | |
from inference import get_evo_response, get_gpt_response | |
from logger import log_feedback | |
import retrain | |
import pandas as pd | |
import os | |
def advisor_interface(query, context, feedback_choice): | |
evo_output, evo_reasoning = get_evo_response(query, context) | |
gpt_output = get_gpt_response(query, context) | |
if feedback_choice != "No feedback": | |
label = 1 if feedback_choice == "π Helpful" else 0 | |
log_feedback(query, context, evo_output, label) | |
return evo_reasoning, gpt_output, load_history() | |
def retrain_evo(): | |
retrain.fine_tune_on_feedback() | |
return "β Evo retrained on feedback.", load_history() | |
def load_history(): | |
if os.path.exists("feedback_log.csv"): | |
df = pd.read_csv("feedback_log.csv") | |
return df.tail(10).to_markdown(index=False) | |
return "No history available yet." | |
with gr.Blocks() as demo: | |
gr.Markdown("## π§ EvoRAG β General-Purpose Adaptive AI with RAG + Web Search") | |
with gr.Row(): | |
query = gr.Textbox(label="π Ask anything", placeholder="e.g. What are the latest trends in AI regulation?") | |
context = gr.Textbox(label="π Optional Context or Notes", placeholder="Paste any relevant information or leave blank.") | |
with gr.Row(): | |
feedback = gr.Radio(["π Helpful", "π Not Helpful", "No feedback"], label="Was Evoβs answer useful?", value="No feedback") | |
with gr.Row(): | |
evo_out = gr.Textbox(label="π¬ EvoRAG Suggestion (with reasoning)") | |
gpt_out = gr.Textbox(label="π€ GPT-3.5 Suggestion") | |
run_button = gr.Button("Run Advisors") | |
run_button.click(fn=advisor_interface, inputs=[query, context, feedback], outputs=[evo_out, gpt_out, gr.Textbox(label="π Recent History")]) | |
gr.Markdown("---") | |
gr.Markdown("### π Retrain Evo from Feedback") | |
retrain_button = gr.Button("π Retrain Evo") | |
retrain_output = gr.Textbox(label="π οΈ Retrain Status") | |
history_output = gr.Textbox(label="π Recent History") | |
retrain_button.click(fn=retrain_evo, inputs=[], outputs=[retrain_output, history_output]) | |
demo.launch() | |