Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,37 @@
|
|
1 |
import gradio as gr
|
2 |
-
from inference import
|
|
|
3 |
from logger import log_feedback
|
4 |
|
5 |
-
def advisor_interface(query,
|
6 |
-
|
7 |
-
|
|
|
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("## π§
|
16 |
|
17 |
with gr.Row():
|
18 |
-
query = gr.Textbox(label="π Ask a financial question", placeholder="e.g. Should we
|
19 |
-
|
20 |
|
21 |
-
|
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="π¬
|
26 |
-
gpt_out = gr.Textbox(label="π€ GPT-3.5
|
27 |
|
28 |
submit_btn = gr.Button("Run Advisors")
|
29 |
-
submit_btn.click(fn=advisor_interface, inputs=[query,
|
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()
|