sgattup commited on
Commit
60c354a
·
verified ·
1 Parent(s): f0d0431

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +96 -39
app.py CHANGED
@@ -21,8 +21,7 @@ HUB_ARGS = {"token": HF_TOKEN} if HF_TOKEN else {}
21
 
22
  SYSTEM_PROMPT = """You are Estella Explainer, a math reading and language coach for young learners in grades 3 through 8.
23
 
24
- Your motto is:
25
- "My job is to explain math questions clearly so you know what you are supposed to do to solve the problem."
26
 
27
  Rules:
28
  - Give only ONE hint per problem.
@@ -98,9 +97,9 @@ def ask_estella(message: str, history: list) -> str:
98
  {
99
  "role": "user",
100
  "content": (
101
- "### Math Problem:\n"
102
  f"{message.strip()}\n\n"
103
- "### Estella's Hint:"
104
  ),
105
  },
106
  ]
@@ -142,6 +141,7 @@ def ask_estella(message: str, history: list) -> str:
142
  skip_special_tokens=True,
143
  ).strip()
144
 
 
145
  THEME = gr.themes.Soft(
146
  primary_hue="orange",
147
  secondary_hue="amber",
@@ -152,51 +152,99 @@ THEME = gr.themes.Soft(
152
 
153
 
154
  CUSTOM_CSS = """
 
 
 
 
 
 
 
 
155
  .gradio-container {
156
- background:
157
- radial-gradient(
158
- circle at 0% 0%,
159
- rgba(245, 158, 11, 0.14),
160
- transparent 28rem
161
- ),
162
- radial-gradient(
163
- circle at 100% 0%,
164
- rgba(16, 185, 129, 0.10),
165
- transparent 24rem
166
- ),
167
- #fffaf2 !important;
 
 
 
 
 
 
168
  }
169
 
170
  /* Title */
171
  .gradio-container h1 {
172
- color: #9a3412 !important;
173
  letter-spacing: -0.02em;
174
  }
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  /* User messages */
177
  .gradio-container .message.user {
178
- background: #fef3c7 !important;
179
- border: 1px solid #fcd34d !important;
180
  border-radius: 18px !important;
 
181
  }
182
 
183
  /* Estella messages */
184
  .gradio-container .message.bot {
185
- background: #ecfdf5 !important;
186
- border: 1px solid #a7f3d0 !important;
187
  border-radius: 18px !important;
 
 
 
 
 
 
 
 
 
188
  }
189
 
190
- /* Text input */
191
- .gradio-container textarea {
192
- border: 1px solid #f3c677 !important;
 
193
  border-radius: 16px !important;
194
- background: #fffdf8 !important;
 
 
 
 
 
 
 
195
  }
196
 
197
- /* Main submit button */
198
  .gradio-container button.primary {
199
- background: linear-gradient(135deg, #d97706, #f59e0b) !important;
200
  border: none !important;
201
  color: white !important;
202
  border-radius: 14px !important;
@@ -204,29 +252,38 @@ CUSTOM_CSS = """
204
  }
205
 
206
  .gradio-container button.primary:hover {
207
- background: linear-gradient(135deg, #b45309, #d97706) !important;
208
  }
209
 
210
  /* Example buttons */
211
  .gradio-container button.secondary {
212
- border-color: #f3c677 !important;
213
- color: #92400e !important;
214
  }
215
 
216
- /* Hide the default footer */
217
  footer {
218
  display: none !important;
219
  }
 
 
 
 
 
 
 
 
220
  """
221
 
 
222
  demo = gr.ChatInterface(
223
  fn=ask_estella,
224
- title="📚 Estella Explainer — Math Reading Coach",
225
  description=(
226
- '**"My job is to explain math questions clearly so you know '
227
- 'what you are supposed to do to solve the problem."**\n\n'
228
- "Type any math word problem and Estella will help you understand "
229
- "what it is asking—without solving it.\n\n"
230
  "Developed by [Sai Gattupalli, PhD](https://huggingface.co/sgattup) · "
231
  "[UMass Amherst College of Education](https://www.umass.edu/education/) · "
232
  "[Society and AI Research Group](https://societyandai.org) · "
@@ -239,6 +296,6 @@ demo = gr.ChatInterface(
239
 
240
  if __name__ == "__main__":
241
  demo.launch(
242
- theme=THEME,
243
- css=CUSTOM_CSS,
244
- )
 
21
 
22
  SYSTEM_PROMPT = """You are Estella Explainer, a math reading and language coach for young learners in grades 3 through 8.
23
 
24
+ Estella helps students understand what a math problem is asking before they begin solving it.
 
25
 
26
  Rules:
27
  - Give only ONE hint per problem.
 
97
  {
98
  "role": "user",
99
  "content": (
100
+ "Math Problem:\n"
101
  f"{message.strip()}\n\n"
102
+ "Estella's Hint:"
103
  ),
104
  },
105
  ]
 
141
  skip_special_tokens=True,
142
  ).strip()
143
 
144
+
145
  THEME = gr.themes.Soft(
146
  primary_hue="orange",
147
  secondary_hue="amber",
 
152
 
153
 
154
  CUSTOM_CSS = """
155
+ html,
156
+ body {
157
+ height: 100%;
158
+ margin: 0;
159
+ overflow: hidden !important;
160
+ background: #fff8cc !important;
161
+ }
162
+
163
  .gradio-container {
164
+ height: 100dvh !important;
165
+ min-height: 100dvh !important;
166
+ overflow: hidden !important;
167
+ background: #fff8cc !important;
168
+ color: #1f2937 !important;
169
+ }
170
+
171
+ /* Keep the page from expanding */
172
+ .gradio-container .main {
173
+ min-height: 0 !important;
174
+ }
175
+
176
+ /* Solid light-yellow interface */
177
+ .gradio-container,
178
+ .gradio-container .block,
179
+ .gradio-container .panel,
180
+ .gradio-container .form {
181
+ background-color: #fff8cc !important;
182
  }
183
 
184
  /* Title */
185
  .gradio-container h1 {
186
+ color: #78350f !important;
187
  letter-spacing: -0.02em;
188
  }
189
 
190
+ /* Readable body text */
191
+ .gradio-container p,
192
+ .gradio-container label,
193
+ .gradio-container span {
194
+ color: #1f2937;
195
+ }
196
+
197
+ /* Keep every hyperlink black */
198
+ .gradio-container a,
199
+ .gradio-container a:visited,
200
+ .gradio-container a:hover,
201
+ .gradio-container a:active {
202
+ color: #111827 !important;
203
+ text-decoration: underline;
204
+ }
205
+
206
  /* User messages */
207
  .gradio-container .message.user {
208
+ background: #fff0b8 !important;
209
+ border: 1px solid #f2c94c !important;
210
  border-radius: 18px !important;
211
+ color: #1f2937 !important;
212
  }
213
 
214
  /* Estella messages */
215
  .gradio-container .message.bot {
216
+ background: #fffdf0 !important;
217
+ border: 1px solid #e8dca3 !important;
218
  border-radius: 18px !important;
219
+ color: #1f2937 !important;
220
+ }
221
+
222
+ /* Keep the chat area scrollable instead of expanding the page */
223
+ .gradio-container .chatbot,
224
+ .gradio-container [data-testid="chatbot"] {
225
+ min-height: 220px !important;
226
+ max-height: calc(100dvh - 360px) !important;
227
+ overflow-y: auto !important;
228
  }
229
 
230
+ /* Bright, clearly visible message input */
231
+ .gradio-container textarea,
232
+ .gradio-container [data-testid="textbox"] {
233
+ border: 2px solid #e59b16 !important;
234
  border-radius: 16px !important;
235
+ background: #fffdf0 !important;
236
+ color: #1f2937 !important;
237
+ }
238
+
239
+ .gradio-container textarea:focus,
240
+ .gradio-container [data-testid="textbox"]:focus-within {
241
+ border-color: #c2410c !important;
242
+ box-shadow: 0 0 0 4px rgba(194, 65, 12, 0.18) !important;
243
  }
244
 
245
+ /* Submit button */
246
  .gradio-container button.primary {
247
+ background: #d97706 !important;
248
  border: none !important;
249
  color: white !important;
250
  border-radius: 14px !important;
 
252
  }
253
 
254
  .gradio-container button.primary:hover {
255
+ background: #b45309 !important;
256
  }
257
 
258
  /* Example buttons */
259
  .gradio-container button.secondary {
260
+ border-color: #e5b94c !important;
261
+ color: #78350f !important;
262
  }
263
 
264
+ /* Remove default footer */
265
  footer {
266
  display: none !important;
267
  }
268
+
269
+ /* Smaller screens */
270
+ @media (max-width: 640px) {
271
+ .gradio-container .chatbot,
272
+ .gradio-container [data-testid="chatbot"] {
273
+ max-height: 42dvh !important;
274
+ }
275
+ }
276
  """
277
 
278
+
279
  demo = gr.ChatInterface(
280
  fn=ask_estella,
281
+ title="Estella Explainer Math Reading Coach",
282
  description=(
283
+ "Estella helps students understand what a math problem is asking "
284
+ "before they begin solving it.\n\n"
285
+ "Enter a math question below for one clear, friendly hint. "
286
+ "Estella will not give away the answer.\n\n"
287
  "Developed by [Sai Gattupalli, PhD](https://huggingface.co/sgattup) · "
288
  "[UMass Amherst College of Education](https://www.umass.edu/education/) · "
289
  "[Society and AI Research Group](https://societyandai.org) · "
 
296
 
297
  if __name__ == "__main__":
298
  demo.launch(
299
+ theme=THEME,
300
+ css=CUSTOM_CSS,
301
+ )