Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
78 |
-
|
|
|
|
|
79 |
|
80 |
-
|
|
|
|
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
85 |
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
gr.Markdown("""
|
88 |
-
<div style=
|
89 |
-
<div style=
|
|
|
|
|
90 |
""")
|
91 |
-
|
92 |
with gr.Row():
|
93 |
with gr.Column():
|
94 |
-
question = gr.Textbox(label="π Your Question", placeholder="e.g.
|
95 |
-
option1 = gr.Textbox(label="πΉ Option 1", placeholder="e.g.
|
96 |
-
option2 = gr.Textbox(label="πΈ Option 2", placeholder="e.g.
|
97 |
-
notes = gr.Textbox(label="π Extra Notes or Context (Optional)", lines=
|
98 |
-
|
99 |
|
100 |
with gr.Column():
|
101 |
-
gr.Markdown("### π§ EvoRAG's
|
102 |
evo_output = gr.Markdown()
|
103 |
gr.Markdown("### π€ GPT-3.5's Suggestion")
|
104 |
gpt_output = gr.Markdown()
|
105 |
|
106 |
-
|
107 |
fn=run_comparison,
|
108 |
inputs=[question, option1, option2, notes],
|
109 |
outputs=[evo_output, gpt_output]
|
110 |
)
|
111 |
|
112 |
-
gr.Markdown("###
|
113 |
with gr.Row():
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
119 |
fn=save_feedback,
|
120 |
-
inputs=[question, notes, evo_output,
|
121 |
-
outputs=[
|
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()
|