HemanM commited on
Commit
392ce44
Β·
verified Β·
1 Parent(s): 5ff1d2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -8
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
- # 🧾 Build RAG index if a file is uploaded
8
  if file is not None:
9
  build_index_from_file(file.name)
10
 
11
- # 🧠 Get EvoRAG + GPT responses
12
  evo_output = evo_rag_response(query)
13
- gpt_output = get_gpt_response(query, "") # GPT optional context
14
 
15
- # πŸ—³οΈ Log feedback
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. Should we reduce exposure to Fund A?")
26
- file = gr.File(label="πŸ“‚ Upload policy or memo (.pdf or .txt)", file_types=[".pdf", ".txt"])
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()