HemanM commited on
Commit
76788c6
Β·
verified Β·
1 Parent(s): 0513045

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -25
app.py CHANGED
@@ -69,56 +69,76 @@ 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()
 
69
  if os.path.dirname(LOG_PATH):
70
  os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
71
 
72
+ # πŸ” Core logic for response generation
73
  def run_comparison(question, option1, option2, notes):
74
  options = [option1, option2]
75
  evo_ans, reasoning, confidence, evo_context = get_evo_response(question, options, notes)
76
  gpt_ans = get_gpt_response(question, notes)
77
 
78
+ evo_output = f"""
79
+ ### βœ… Evo's Suggestion: **{evo_ans}**
80
+ **🧠 Reasoning:**
81
+ {reasoning}
82
 
83
+ **πŸ“š Context Used:**
84
+ {evo_context}
85
+ """
86
 
87
+ gpt_output = f"""
88
+ ### πŸ€– GPT-3.5 Suggestion
89
+ {gpt_ans}
90
+ """
91
 
92
+ return evo_output.strip(), gpt_output.strip()
93
+
94
+ # 🧠 Feedback logic
95
+ def save_feedback(question, notes, evo_output, feedback):
96
+ log_feedback(question, notes, evo_output, feedback)
97
+ if feedback == "πŸ‘ Evo was correct. Retrain from this.":
98
+ return "βœ… Evo will be retrained with your feedback."
99
+ return "πŸ“© Feedback recorded. Thanks!"
100
+
101
+ with gr.Blocks(title="EvoRAG – General-Purpose AI with Web Reasoning") as demo:
102
  gr.Markdown("""
103
+ <div style="text-align: center; font-size: 32px; font-weight: bold; color: #222">🧠 EvoRAG</div>
104
+ <div style="text-align: center; font-size: 16px; margin-bottom: 20px; color: #444">
105
+ General-Purpose Adaptive AI that Thinks, Reads, and Evolves – Powered by Real-Time Web Search
106
+ </div>
107
  """)
108
+
109
  with gr.Row():
110
  with gr.Column():
111
+ question = gr.Textbox(label="πŸ“ Your Question", placeholder="e.g. What should I do if my house is on fire?")
112
+ option1 = gr.Textbox(label="πŸ”Ή Option 1", placeholder="e.g. I hide under the bed")
113
+ option2 = gr.Textbox(label="πŸ”Έ Option 2", placeholder="e.g. I run for dear life")
114
+ notes = gr.Textbox(label="πŸ“‚ Extra Notes or Context (Optional)", lines=4, placeholder="Paste news, user context, or background information")
115
+ run_button = gr.Button("πŸš€ Run Comparison")
116
 
117
  with gr.Column():
118
+ gr.Markdown("### 🧠 EvoRAG's Response")
119
  evo_output = gr.Markdown()
120
  gr.Markdown("### πŸ€– GPT-3.5's Suggestion")
121
  gpt_output = gr.Markdown()
122
 
123
+ run_button.click(
124
  fn=run_comparison,
125
  inputs=[question, option1, option2, notes],
126
  outputs=[evo_output, gpt_output]
127
  )
128
 
129
+ gr.Markdown("### πŸ” Help Evo Learn – Give Feedback")
130
  with gr.Row():
131
+ feedback = gr.Radio(
132
+ ["πŸ‘ Evo was correct. Retrain from this.", "πŸ‘Ž Evo was wrong."],
133
+ label="What did you think of Evo's answer?"
134
+ )
135
+ submit_button = gr.Button("πŸ“¬ Submit Feedback / Retrain Evo")
136
+ feedback_status = gr.Textbox(visible=False)
137
+
138
+ submit_button.click(
139
  fn=save_feedback,
140
+ inputs=[question, notes, evo_output, feedback],
141
+ outputs=[feedback_status]
142
  )
143
 
144
  demo.launch()