HemanM commited on
Commit
0513045
Β·
verified Β·
1 Parent(s): 8bee30f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -1
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import gradio as gr
2
  from inference import get_evo_response, get_gpt_response
3
  import os
4
  from logger import log_feedback
@@ -59,4 +59,67 @@ with gr.Blocks(title="🧠 EvoRAG – General-Purpose Adaptive AI with Web Reaso
59
  outputs=[feedback_result]
60
  )
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  demo.launch()
 
 
1
+ '''import gradio as gr
2
  from inference import get_evo_response, get_gpt_response
3
  import os
4
  from logger import log_feedback
 
59
  outputs=[feedback_result]
60
  )
61
 
62
+ demo.launch()'''
63
+ import gradio as gr
64
+ from inference import get_evo_response, get_gpt_response
65
+ from logger import log_feedback
66
+ import os
67
+
68
+ LOG_PATH = "feedback_log.csv"
69
+ if os.path.dirname(LOG_PATH):
70
+ os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
71
+
72
+ def run_comparison(question, option1, option2, notes):
73
+ options = [option1, option2]
74
+ evo_ans, reasoning, confidence, evo_context = get_evo_response(question, options, notes)
75
+ gpt_ans = get_gpt_response(question, notes)
76
+
77
+ evo_text = f"**Evo's Suggestion:**\nβœ… {evo_ans}\n\n**Why?**\n{reasoning}\n\n---\n**Context Used**\n{evo_context}"
78
+ gpt_text = f"**GPT-3.5 Suggestion:**\n{gpt_ans}"
79
+
80
+ return evo_text, gpt_text
81
+
82
+ def save_feedback(question, notes, evo_answer, feedback):
83
+ log_feedback(question, notes, evo_answer, feedback)
84
+ return "βœ… Feedback received!"
85
+
86
+ with gr.Blocks(title="EvoRAG – Adaptive AI with Web Reasoning") as demo:
87
+ gr.Markdown("""
88
+ <div style='text-align: center; font-size: 28px; font-weight: bold;'>🧠 EvoRAG</div>
89
+ <div style='text-align: center; font-size: 16px; margin-bottom: 20px;'>General-Purpose Adaptive AI with Real-Time Web Search + Reasoning</div>
90
+ """)
91
+
92
+ with gr.Row():
93
+ with gr.Column():
94
+ question = gr.Textbox(label="πŸ“ Your Question", placeholder="e.g. Who is the president of the United States?")
95
+ option1 = gr.Textbox(label="πŸ”Ή Option 1", placeholder="e.g. Joe Biden")
96
+ option2 = gr.Textbox(label="πŸ”Έ Option 2", placeholder="e.g. Donald Trump")
97
+ notes = gr.Textbox(label="πŸ“‚ Extra Notes or Context (Optional)", lines=3, placeholder="Paste any relevant background info")
98
+ submit = gr.Button("πŸš€ Run Comparison", size="lg")
99
+
100
+ with gr.Column():
101
+ gr.Markdown("### 🧠 EvoRAG's Reasoned Answer")
102
+ evo_output = gr.Markdown()
103
+ gr.Markdown("### πŸ€– GPT-3.5's Suggestion")
104
+ gpt_output = gr.Markdown()
105
+
106
+ submit.click(
107
+ fn=run_comparison,
108
+ inputs=[question, option1, option2, notes],
109
+ outputs=[evo_output, gpt_output]
110
+ )
111
+
112
+ gr.Markdown("### πŸ—³οΈ Was EvoRAG helpful?")
113
+ with gr.Row():
114
+ feedback_choice = gr.Radio(["πŸ‘ Helpful", "πŸ‘Ž Not Helpful"], label="Your Feedback")
115
+ send_feedback = gr.Button("πŸ“¬ Submit Feedback")
116
+ feedback_msg = gr.Textbox(visible=False)
117
+
118
+ send_feedback.click(
119
+ fn=save_feedback,
120
+ inputs=[question, notes, evo_output, feedback_choice],
121
+ outputs=[feedback_msg]
122
+ )
123
+
124
  demo.launch()
125
+