Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,26 +4,32 @@ from retriever import build_index_from_file
|
|
4 |
from logger import log_feedback
|
5 |
|
6 |
def advisor_interface(query, file, feedback_choice):
|
7 |
-
#
|
8 |
if file is not None:
|
9 |
build_index_from_file(file.name)
|
10 |
|
11 |
-
#
|
12 |
evo_output = evo_rag_response(query)
|
13 |
-
gpt_output = get_gpt_response(query, "") #
|
14 |
|
15 |
-
#
|
16 |
if feedback_choice != "No feedback":
|
17 |
-
log_feedback(query, "[RAG context]", evo_output, feedback_choice)
|
18 |
|
19 |
return evo_output, gpt_output
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
with gr.Blocks() as demo:
|
22 |
-
gr.Markdown("## π§ EvoRAG β Retrieval-Augmented Adaptive AI for Finance")
|
23 |
|
24 |
with gr.Row():
|
25 |
-
query = gr.Textbox(label="π Ask a financial question", placeholder="e.g.
|
26 |
-
file = gr.File(label="π Upload
|
27 |
|
28 |
feedback = gr.Radio(["π Helpful", "π Not Helpful", "No feedback"], label="Was Evoβs answer useful?", value="No feedback")
|
29 |
|
@@ -34,4 +40,10 @@ with gr.Blocks() as demo:
|
|
34 |
submit_btn = gr.Button("Run Advisors")
|
35 |
submit_btn.click(fn=advisor_interface, inputs=[query, file, feedback], outputs=[evo_out, gpt_out])
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
demo.launch()
|
|
|
4 |
from logger import log_feedback
|
5 |
|
6 |
def advisor_interface(query, file, feedback_choice):
|
7 |
+
# Build FAISS index from uploaded file
|
8 |
if file is not None:
|
9 |
build_index_from_file(file.name)
|
10 |
|
11 |
+
# Get Evo + GPT responses
|
12 |
evo_output = evo_rag_response(query)
|
13 |
+
gpt_output = get_gpt_response(query, "") # optional context
|
14 |
|
15 |
+
# Log feedback
|
16 |
if feedback_choice != "No feedback":
|
17 |
+
log_feedback(query, "[RAG+WEB context]", evo_output, feedback_choice)
|
18 |
|
19 |
return evo_output, gpt_output
|
20 |
|
21 |
+
# Manual retrain trigger
|
22 |
+
def retrain_evo():
|
23 |
+
import retrain
|
24 |
+
retrain.fine_tune_on_feedback()
|
25 |
+
return "β
Evo retrained on feedback."
|
26 |
+
|
27 |
with gr.Blocks() as demo:
|
28 |
+
gr.Markdown("## π§ EvoRAG+ β Retrieval-Augmented Adaptive AI for Finance")
|
29 |
|
30 |
with gr.Row():
|
31 |
+
query = gr.Textbox(label="π Ask a financial question", placeholder="e.g. Option 1: Reduce exposure to Fund A. Option 2: Maintain allocation.")
|
32 |
+
file = gr.File(label="π Upload memo or policy (.pdf or .txt)", file_types=[".pdf", ".txt"])
|
33 |
|
34 |
feedback = gr.Radio(["π Helpful", "π Not Helpful", "No feedback"], label="Was Evoβs answer useful?", value="No feedback")
|
35 |
|
|
|
40 |
submit_btn = gr.Button("Run Advisors")
|
41 |
submit_btn.click(fn=advisor_interface, inputs=[query, file, feedback], outputs=[evo_out, gpt_out])
|
42 |
|
43 |
+
gr.Markdown("---")
|
44 |
+
|
45 |
+
retrain_btn = gr.Button("π Retrain Evo from Feedback")
|
46 |
+
retrain_status = gr.Textbox(label="Retraining Status")
|
47 |
+
retrain_btn.click(fn=retrain_evo, outputs=retrain_status)
|
48 |
+
|
49 |
demo.launch()
|