Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -176,17 +176,36 @@ def respond_strict(message, history):
|
|
176 |
|
177 |
|
178 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
179 |
with gr.Row():
|
180 |
cool_button = gr.Button("Cool Mom")
|
181 |
tutor_button = gr.Button("Tutor Mom")
|
182 |
strict_button = gr.Button("Strict Mom")
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
demo.launch()
|
|
|
176 |
|
177 |
|
178 |
with gr.Blocks() as demo:
|
179 |
+
mom_type = gr.State("Cool Mom") # default state
|
180 |
+
history = gr.State([])
|
181 |
+
|
182 |
+
with gr.Row():
|
183 |
+
gr.Markdown("### Choose your Mom Mode")
|
184 |
with gr.Row():
|
185 |
cool_button = gr.Button("Cool Mom")
|
186 |
tutor_button = gr.Button("Tutor Mom")
|
187 |
strict_button = gr.Button("Strict Mom")
|
188 |
+
|
189 |
+
def set_mom_cool(): return "Cool Mom"
|
190 |
+
def set_mom_tutor(): return "Tutor Mom"
|
191 |
+
def set_mom_strict(): return "Strict Mom"
|
192 |
+
|
193 |
+
cool_button.click(fn=set_mom_cool, inputs=[], outputs=mom_type)
|
194 |
+
tutor_button.click(fn=set_mom_tutor, inputs=[], outputs=mom_type)
|
195 |
+
strict_button.click(fn=set_mom_strict, inputs=[], outputs=mom_type)
|
196 |
+
|
197 |
+
def route_message(message, history, mom_type):
|
198 |
+
if mom_type == "Cool Mom":
|
199 |
+
return respond_cool(message, history)
|
200 |
+
elif mom_type == "Tutor Mom":
|
201 |
+
return respond_tutor(message, history)
|
202 |
+
else:
|
203 |
+
return respond_strict(message, history)
|
204 |
+
|
205 |
+
gr.ChatInterface(
|
206 |
+
fn=route_message,
|
207 |
+
additional_inputs=[history, mom_type],
|
208 |
+
title="StudyMama"
|
209 |
+
)
|
210 |
+
|
211 |
demo.launch()
|