Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,9 +5,8 @@ import retrain
|
|
| 5 |
import pandas as pd
|
| 6 |
import os
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
evo_output, evo_reasoning = get_evo_response(query, context, enable_search=True)
|
| 11 |
gpt_output = get_gpt_response(query, context)
|
| 12 |
|
| 13 |
if feedback_choice != "No feedback":
|
|
@@ -16,44 +15,43 @@ def advisor_interface(query, context, feedback_choice):
|
|
| 16 |
|
| 17 |
return evo_reasoning, gpt_output, load_history()
|
| 18 |
|
| 19 |
-
# π Retrain logic
|
| 20 |
def retrain_evo():
|
| 21 |
retrain.fine_tune_on_feedback()
|
| 22 |
return "β
Evo retrained on feedback.", load_history()
|
| 23 |
|
| 24 |
-
# π Feedback log viewer
|
| 25 |
def load_history():
|
| 26 |
if os.path.exists("feedback_log.csv"):
|
| 27 |
df = pd.read_csv("feedback_log.csv")
|
| 28 |
return df.tail(10).to_markdown(index=False)
|
| 29 |
return "No history available yet."
|
| 30 |
|
| 31 |
-
# π§ UI
|
| 32 |
with gr.Blocks() as demo:
|
| 33 |
-
gr.Markdown("## π§ EvoRAG β Retrieval-Augmented Adaptive AI
|
| 34 |
|
| 35 |
-
with gr.
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
| 40 |
|
| 41 |
with gr.Row():
|
| 42 |
-
feedback = gr.Radio(["π Helpful", "π Not Helpful", "No feedback"], label="
|
| 43 |
|
| 44 |
with gr.Row():
|
| 45 |
-
evo_out = gr.Textbox(label="π¬ EvoRAG Suggestion (with reasoning)", lines=
|
| 46 |
-
gpt_out = gr.Textbox(label="π€ GPT-3.5 Suggestion", lines=
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
run_button =
|
| 49 |
-
run_button.click(fn=advisor_interface, inputs=[query, context, feedback], outputs=[evo_out, gpt_out, gr.Textbox(label="π Recent Feedback Log")])
|
| 50 |
|
| 51 |
gr.Markdown("---")
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
-
retrain_button = gr.Button("π Retrain Evo Now from Feedback")
|
| 55 |
-
retrain_output = gr.Textbox(label="π οΈ Retrain Status", interactive=False)
|
| 56 |
-
history_output = gr.Textbox(label="π Recent Feedback Log", interactive=False)
|
| 57 |
-
retrain_button.click(fn=retrain_evo, inputs=[], outputs=[retrain_output, history_output])
|
| 58 |
|
| 59 |
demo.launch()
|
|
|
|
| 5 |
import pandas as pd
|
| 6 |
import os
|
| 7 |
|
| 8 |
+
def advisor_interface(query, context, file, feedback_choice):
|
| 9 |
+
evo_output, evo_reasoning = get_evo_response(query, context, file)
|
|
|
|
| 10 |
gpt_output = get_gpt_response(query, context)
|
| 11 |
|
| 12 |
if feedback_choice != "No feedback":
|
|
|
|
| 15 |
|
| 16 |
return evo_reasoning, gpt_output, load_history()
|
| 17 |
|
|
|
|
| 18 |
def retrain_evo():
|
| 19 |
retrain.fine_tune_on_feedback()
|
| 20 |
return "β
Evo retrained on feedback.", load_history()
|
| 21 |
|
|
|
|
| 22 |
def load_history():
|
| 23 |
if os.path.exists("feedback_log.csv"):
|
| 24 |
df = pd.read_csv("feedback_log.csv")
|
| 25 |
return df.tail(10).to_markdown(index=False)
|
| 26 |
return "No history available yet."
|
| 27 |
|
|
|
|
| 28 |
with gr.Blocks() as demo:
|
| 29 |
+
gr.Markdown("## π§ EvoRAG β Retrieval-Augmented Adaptive AI (General Purpose)")
|
| 30 |
|
| 31 |
+
with gr.Row():
|
| 32 |
+
query = gr.Textbox(label="π Ask any question", placeholder="e.g. What are the effects of inflation?")
|
| 33 |
+
context = gr.Textbox(label="π Optional background notes or memos", placeholder="Paste policy, notes, or ideas...")
|
| 34 |
+
|
| 35 |
+
with gr.Row():
|
| 36 |
+
file = gr.File(label="π Upload optional file (.txt or .pdf)", file_types=[".txt", ".pdf"])
|
| 37 |
|
| 38 |
with gr.Row():
|
| 39 |
+
feedback = gr.Radio(["π Helpful", "π Not Helpful", "No feedback"], label="Was Evoβs answer useful?", value="No feedback")
|
| 40 |
|
| 41 |
with gr.Row():
|
| 42 |
+
evo_out = gr.Textbox(label="π¬ EvoRAG Suggestion (with reasoning)", lines=6)
|
| 43 |
+
gpt_out = gr.Textbox(label="π€ GPT-3.5 Suggestion", lines=6)
|
| 44 |
+
|
| 45 |
+
run_button = gr.Button("Run Advisors")
|
| 46 |
+
history_output = gr.Textbox(label="π Recent History")
|
| 47 |
|
| 48 |
+
run_button.click(fn=advisor_interface, inputs=[query, context, file, feedback], outputs=[evo_out, gpt_out, history_output])
|
|
|
|
| 49 |
|
| 50 |
gr.Markdown("---")
|
| 51 |
+
gr.Markdown("### π Retrain Evo on Feedback")
|
| 52 |
+
retrain_button = gr.Button("π Retrain Evo")
|
| 53 |
+
retrain_status = gr.Textbox(label="π οΈ Retrain Status")
|
| 54 |
|
| 55 |
+
retrain_button.click(fn=retrain_evo, inputs=[], outputs=[retrain_status, history_output])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
demo.launch()
|