EvoPlatform / app.py
HemanM's picture
Update app.py
f39d1fb verified
raw
history blame
1.35 kB
import gradio as gr
from inference import get_evo_response, get_gpt_response
from logger import log_feedback
from utils import extract_text_from_file
def advisor_interface(question, file, feedback_choice):
context = extract_text_from_file(file) if file else ""
evo_answer = get_evo_response(question, context)
gpt_answer = get_gpt_response(question, context)
if feedback_choice != "No feedback":
log_feedback(question, context, evo_answer, feedback_choice)
return evo_answer, gpt_answer
with gr.Blocks() as demo:
gr.Markdown("## 🧠 EvoRAG – Retrieval-Augmented Adaptive AI")
with gr.Row():
question = gr.Textbox(label="πŸ“ Ask anything", placeholder="e.g. Should we diversify the portfolio?")
with gr.Row():
file = gr.File(label="πŸ“‚ Upload memo (.pdf or .txt)", file_types=[".pdf", ".txt"], type="binary")
with gr.Row():
feedback = gr.Radio(["πŸ‘ Helpful", "πŸ‘Ž Not Helpful", "No feedback"], label="Was Evo’s answer useful?", value="No feedback")
with gr.Row():
evo_out = gr.Textbox(label="πŸ”¬ EvoRAG Suggestion")
gpt_out = gr.Textbox(label="πŸ€– GPT-3.5 Suggestion")
submit_btn = gr.Button("Run Advisors")
submit_btn.click(fn=advisor_interface, inputs=[question, file, feedback], outputs=[evo_out, gpt_out])
demo.launch()