HemanM commited on
Commit
afd132a
Β·
verified Β·
1 Parent(s): 5b27dcb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -13
app.py CHANGED
@@ -1,31 +1,37 @@
1
  import gradio as gr
2
- from inference import get_evo_response, get_gpt_response
 
3
  from logger import log_feedback
4
 
5
- def advisor_interface(query, context, feedback_choice):
6
- evo_output = get_evo_response(query, context)
7
- gpt_output = get_gpt_response(query, context)
 
8
 
 
 
 
 
 
9
  if feedback_choice != "No feedback":
10
- log_feedback(query, context, evo_output, feedback_choice)
11
 
12
  return evo_output, gpt_output
13
 
14
  with gr.Blocks() as demo:
15
- gr.Markdown("## 🧠 EvoAdvisor – Your Adaptive AI Copilot for Finance")
16
 
17
  with gr.Row():
18
- query = gr.Textbox(label="πŸ“ Ask a financial question", placeholder="e.g. Should we exit this position?")
19
- context = gr.Textbox(label="πŸ“‚ Related memo or policy context", placeholder="Paste internal strategy or notes here...")
20
 
21
- with gr.Row():
22
- feedback = gr.Radio(["πŸ‘ Helpful", "πŸ‘Ž Not Helpful", "No feedback"], label="Was Evo’s answer useful?", value="No feedback")
23
 
24
  with gr.Row():
25
- evo_out = gr.Textbox(label="πŸ”¬ EvoAdvisor's Suggestion")
26
- gpt_out = gr.Textbox(label="πŸ€– GPT-3.5's Suggestion")
27
 
28
  submit_btn = gr.Button("Run Advisors")
29
- submit_btn.click(fn=advisor_interface, inputs=[query, context, feedback], outputs=[evo_out, gpt_out])
30
 
31
  demo.launch()
 
1
  import gradio as gr
2
+ from inference import evo_rag_response, get_gpt_response
3
+ 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
 
30
  with gr.Row():
31
+ evo_out = gr.Textbox(label="πŸ”¬ EvoRAG Suggestion")
32
+ gpt_out = gr.Textbox(label="πŸ€– GPT-3.5 Suggestion")
33
 
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()