Alysha Creelman
commited on
Commit
Β·
a56aa3f
1
Parent(s):
327f48b
Adding buttons and picture of wormington
Browse files- app.py +35 -16
- wormington_headshot.jpg +0 -0
app.py
CHANGED
@@ -127,26 +127,45 @@ custom_css = """
|
|
127 |
margin-bottom: 20px;
|
128 |
color: #a7e0fd;
|
129 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
"""
|
131 |
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
with gr.Blocks(css=custom_css) as demo:
|
135 |
gr.Markdown("<h2 style='text-align: center;'>πβοΈ School AI Chatbot βοΈπ</h2>")
|
136 |
-
gr.
|
137 |
-
gr.Markdown("Interact with Wormington Scholar π by selecting the appropriate level below.")
|
138 |
-
|
139 |
|
140 |
-
|
141 |
with gr.Row():
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
with gr.Row():
|
152 |
use_local_model = gr.Checkbox(label="Use Local Model", value=False)
|
@@ -159,12 +178,12 @@ with gr.Blocks(css=custom_css) as demo:
|
|
159 |
|
160 |
chat_history = gr.Chatbot(label="Chat")
|
161 |
|
162 |
-
user_input = gr.Textbox(show_label=False, placeholder="
|
163 |
|
164 |
cancel_button = gr.Button("Cancel Inference", variant="danger")
|
165 |
|
166 |
# Adjusted to ensure history is maintained and passed correctly
|
167 |
-
user_input.submit(respond, [user_input, chat_history,
|
168 |
|
169 |
cancel_button.click(cancel_inference)
|
170 |
|
|
|
127 |
margin-bottom: 20px;
|
128 |
color: #a7e0fd;
|
129 |
}
|
130 |
+
#school_ai_image {
|
131 |
+
width: 150px;
|
132 |
+
height: auto;
|
133 |
+
display: block;
|
134 |
+
margin: 0 auto;
|
135 |
+
}
|
136 |
"""
|
137 |
|
138 |
+
# Define system messages for each level
|
139 |
+
def update_system_message(level):
|
140 |
+
if level == "Elementary School":
|
141 |
+
return "Your name is Wormington. You are a friendly Chatbot that can help answer questions from elementary school students. Please respond with the vocabulary that a seven-year-old can understand."
|
142 |
+
elif level == "Middle School":
|
143 |
+
return "Your name is Wormington. You are a friendly Chatbot that can help answer questions from middle school students. Please respond at a level that middle schoolers can understand."
|
144 |
+
elif level == "High School":
|
145 |
+
return "Your name is Wormington. You are a friendly Chatbot that can help answer questions from high school students. Please respond at a level that a high schooler can understand."
|
146 |
+
elif level == "College":
|
147 |
+
return "Your name is Wormington. You are a friendly Chatbot that can help answer questions from college students. Please respond using very advanced, college-level vocabulary."
|
148 |
+
|
149 |
+
# Define interface
|
150 |
with gr.Blocks(css=custom_css) as demo:
|
151 |
gr.Markdown("<h2 style='text-align: center;'>πβοΈ School AI Chatbot βοΈπ</h2>")
|
152 |
+
gr.Image("wormington_headshot.jpg", elem_id="school_ai_image", show_label=False, interactive=False)
|
153 |
+
gr.Markdown("<h1 style= 'text-align: center;'>Interact with Wormington Scholar π by selecting the appropriate level below.")
|
|
|
154 |
|
|
|
155 |
with gr.Row():
|
156 |
+
elementary_button = gr.Button("Elementary School", elem_id="elementary", variant="primary")
|
157 |
+
middle_button = gr.Button("Middle School", elem_id="middle", variant="primary")
|
158 |
+
high_button = gr.Button("High School", elem_id="high", variant="primary")
|
159 |
+
college_button = gr.Button("College", elem_id="college", variant="primary")
|
160 |
+
|
161 |
+
# Display area for the selected system message
|
162 |
+
system_message_display = gr.Textbox(label="System Message", value="", interactive=False)
|
163 |
+
|
164 |
+
# Update the system message when a button is clicked
|
165 |
+
elementary_button.click(fn=lambda: update_system_message("Elementary School"), inputs=None, outputs=system_message_display)
|
166 |
+
middle_button.click(fn=lambda: update_system_message("Middle School"), inputs=None, outputs=system_message_display)
|
167 |
+
high_button.click(fn=lambda: update_system_message("High School"), inputs=None, outputs=system_message_display)
|
168 |
+
college_button.click(fn=lambda: update_system_message("College"), inputs=None, outputs=system_message_display)
|
169 |
|
170 |
with gr.Row():
|
171 |
use_local_model = gr.Checkbox(label="Use Local Model", value=False)
|
|
|
178 |
|
179 |
chat_history = gr.Chatbot(label="Chat")
|
180 |
|
181 |
+
user_input = gr.Textbox(show_label=False, placeholder="Wormington would love to answer your questions. Type them here:")
|
182 |
|
183 |
cancel_button = gr.Button("Cancel Inference", variant="danger")
|
184 |
|
185 |
# Adjusted to ensure history is maintained and passed correctly
|
186 |
+
user_input.submit(respond, [user_input, chat_history, system_message_display, max_tokens, temperature, top_p, use_local_model], chat_history)
|
187 |
|
188 |
cancel_button.click(cancel_inference)
|
189 |
|
wormington_headshot.jpg
ADDED
![]() |