Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,14 @@ import retrain
|
|
5 |
import pandas as pd
|
6 |
import os
|
7 |
|
8 |
-
def advisor_interface(
|
9 |
-
|
10 |
-
|
|
|
11 |
|
12 |
if feedback_choice != "No feedback":
|
13 |
label = 1 if feedback_choice == "π Helpful" else 0
|
14 |
-
log_feedback(
|
15 |
|
16 |
return evo_reasoning, gpt_output, load_history()
|
17 |
|
@@ -22,32 +23,36 @@ def retrain_evo():
|
|
22 |
def load_history():
|
23 |
if os.path.exists("feedback_log.csv"):
|
24 |
df = pd.read_csv("feedback_log.csv")
|
25 |
-
|
|
|
|
|
|
|
26 |
return "No history available yet."
|
27 |
|
28 |
with gr.Blocks() as demo:
|
29 |
gr.Markdown("## π§ EvoRAG β General-Purpose Adaptive AI with RAG + Web Search")
|
30 |
|
31 |
with gr.Row():
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
with gr.Row():
|
36 |
-
|
|
|
|
|
37 |
|
38 |
with gr.Row():
|
39 |
evo_out = gr.Textbox(label="π¬ EvoRAG Suggestion (with reasoning)")
|
40 |
gpt_out = gr.Textbox(label="π€ GPT-3.5 Suggestion")
|
41 |
|
42 |
run_button = gr.Button("Run Advisors")
|
43 |
-
run_button.click(fn=advisor_interface, inputs=[
|
44 |
|
45 |
gr.Markdown("---")
|
46 |
gr.Markdown("### π Retrain Evo from Feedback")
|
47 |
retrain_button = gr.Button("π Retrain Evo")
|
48 |
retrain_output = gr.Textbox(label="π οΈ Retrain Status")
|
49 |
history_output = gr.Textbox(label="π Recent History")
|
50 |
-
|
51 |
retrain_button.click(fn=retrain_evo, inputs=[], outputs=[retrain_output, history_output])
|
52 |
|
53 |
demo.launch()
|
|
|
5 |
import pandas as pd
|
6 |
import os
|
7 |
|
8 |
+
def advisor_interface(question, context, options_text, feedback_choice):
|
9 |
+
options = [opt.strip() for opt in options_text.split("\n") if opt.strip()]
|
10 |
+
evo_output, evo_reasoning = get_evo_response(question, context, options)
|
11 |
+
gpt_output = get_gpt_response(question, context, options)
|
12 |
|
13 |
if feedback_choice != "No feedback":
|
14 |
label = 1 if feedback_choice == "π Helpful" else 0
|
15 |
+
log_feedback(question, context, evo_output, label)
|
16 |
|
17 |
return evo_reasoning, gpt_output, load_history()
|
18 |
|
|
|
23 |
def load_history():
|
24 |
if os.path.exists("feedback_log.csv"):
|
25 |
df = pd.read_csv("feedback_log.csv")
|
26 |
+
try:
|
27 |
+
return df.tail(10).to_markdown(index=False)
|
28 |
+
except ImportError:
|
29 |
+
return "π History available, but markdown rendering failed. Install `tabulate` for full view."
|
30 |
return "No history available yet."
|
31 |
|
32 |
with gr.Blocks() as demo:
|
33 |
gr.Markdown("## π§ EvoRAG β General-Purpose Adaptive AI with RAG + Web Search")
|
34 |
|
35 |
with gr.Row():
|
36 |
+
question = gr.Textbox(label="π Ask anything", placeholder="e.g. Who is the current president of the US?")
|
37 |
+
with gr.Row():
|
38 |
+
options_text = gr.Textbox(label="π’ Options (one per line)", placeholder="Option 1\nOption 2\nOption 3", lines=4)
|
39 |
with gr.Row():
|
40 |
+
context = gr.Textbox(label="π Optional Context or Notes", placeholder="Paste memo, article, or info here...", lines=4)
|
41 |
+
|
42 |
+
feedback = gr.Radio(["π Helpful", "π Not Helpful", "No feedback"], label="Was Evoβs answer useful?", value="No feedback")
|
43 |
|
44 |
with gr.Row():
|
45 |
evo_out = gr.Textbox(label="π¬ EvoRAG Suggestion (with reasoning)")
|
46 |
gpt_out = gr.Textbox(label="π€ GPT-3.5 Suggestion")
|
47 |
|
48 |
run_button = gr.Button("Run Advisors")
|
49 |
+
run_button.click(fn=advisor_interface, inputs=[question, context, options_text, feedback], outputs=[evo_out, gpt_out, gr.Textbox(label="π Recent History")])
|
50 |
|
51 |
gr.Markdown("---")
|
52 |
gr.Markdown("### π Retrain Evo from Feedback")
|
53 |
retrain_button = gr.Button("π Retrain Evo")
|
54 |
retrain_output = gr.Textbox(label="π οΈ Retrain Status")
|
55 |
history_output = gr.Textbox(label="π Recent History")
|
|
|
56 |
retrain_button.click(fn=retrain_evo, inputs=[], outputs=[retrain_output, history_output])
|
57 |
|
58 |
demo.launch()
|