Alysha Creelman commited on
Commit
a56aa3f
Β·
1 Parent(s): 327f48b

Adding buttons and picture of wormington

Browse files
Files changed (2) hide show
  1. app.py +35 -16
  2. 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
- # Define the interface
 
 
 
 
 
 
 
 
 
 
134
  with gr.Blocks(css=custom_css) as demo:
135
  gr.Markdown("<h2 style='text-align: center;'>🍎✏️ School AI Chatbot ✏️🍎</h2>")
136
- gr.Markdown("<h1 style='text-align: center;'>πŸ›</h1>")
137
- gr.Markdown("Interact with Wormington Scholar πŸ› by selecting the appropriate level below.")
138
-
139
 
140
-
141
  with gr.Row():
142
- system_message = gr.Dropdown(
143
- choices=["You are a friendly Chatbot that responds with the vocabulary of the seven year old.",
144
- "You are a friendly Chatbot. Please respond at a level that middle schoolers can understand",
145
- "You are a friendly high school Chatbot who responds at a level the average person can understand.",
146
- "You are a friendly Chatbot that uses a very advanced, college-level vocabulary in your responses."],
147
- label="System message",
148
- interactive=True
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="Type your message here...")
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, system_message, max_tokens, temperature, top_p, use_local_model], 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