pauladeeptech commited on
Commit
cba5e55
·
verified ·
1 Parent(s): 46eb8bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -43
app.py CHANGED
@@ -162,58 +162,54 @@ def chat(user_message, history):
162
 
163
 
164
  # -----------------------------
165
- # UI with better styling
166
  # -----------------------------
167
  custom_css = """
168
- .message.user {
169
- background-color: #f0f0f0 !important;
170
- border-radius: 12px !important;
171
- padding: 12px 16px !important;
172
- margin: 8px 0 !important;
173
  }
174
 
175
- .message.bot {
176
- background-color: #e8f4f8 !important;
177
  border-radius: 12px !important;
178
  padding: 12px 16px !important;
179
  margin: 8px 0 !important;
180
- line-height: 1.6 !important;
181
- }
182
-
183
- .message p {
184
- margin: 0 !important;
185
- padding: 0 !important;
186
- }
187
-
188
- #chatbot {
189
- height: 600px !important;
190
  }
191
  """
192
 
193
- demo = gr.ChatInterface(
194
- fn=chat,
195
- title="📚 HomeworkBuddy",
196
- description=(
197
- "**Willkommen bei HomeworkBuddy!**\n\n"
198
- "Ich helfe dir, schwierige Themen zu VERSTEHEN! Aber Achtung: Ich mache deine Hausaufgaben NICHT für dich - "
199
- "ich zeige dir, WIE du sie selbst lösen kannst! 🎓\n\n"
200
- "**Beispiel-Fragen:**\n"
201
- "- Was ist Prozentrechnung?\n"
202
- "- Erkläre mir das Dreisatz-Prinzip\n"
203
- "- Wie funktioniert Photosynthese?\n"
204
- "- Ich verstehe Bruchrechnung nicht\n\n"
205
- "Stell mir deine Fragen! 💪"
206
- ),
207
- examples=[
208
- "Was ist 20% von 150?",
209
- "Erkläre mir Bruchrechnung",
210
- "Wie funktioniert Photosynthese?",
211
- "Was ist das Dreisatz-Prinzip?",
212
- "Kannst du meine Mathe-Hausaufgabe lösen?",
213
- ],
214
- css=custom_css,
215
- type="messages", # This makes messages render as paragraphs instead of textboxes
216
- )
 
 
 
 
 
 
 
 
 
217
 
218
  if __name__ == "__main__":
219
- demo.launch(ssr_mode=False)
 
 
162
 
163
 
164
  # -----------------------------
165
+ # UI with better styling using Blocks
166
  # -----------------------------
167
  custom_css = """
168
+ #chatbot {
169
+ height: 600px !important;
 
 
 
170
  }
171
 
172
+ #chatbot .message {
 
173
  border-radius: 12px !important;
174
  padding: 12px 16px !important;
175
  margin: 8px 0 !important;
 
 
 
 
 
 
 
 
 
 
176
  }
177
  """
178
 
179
+ # Use Blocks to wrap ChatInterface and add CSS
180
+ with gr.Blocks(css=custom_css, title="📚 HomeworkBuddy") as demo:
181
+ gr.Markdown(
182
+ """
183
+ # 📚 HomeworkBuddy
184
+
185
+ **Willkommen bei HomeworkBuddy!**
186
+
187
+ Ich helfe dir, schwierige Themen zu VERSTEHEN! Aber Achtung: Ich mache deine Hausaufgaben NICHT für dich -
188
+ ich zeige dir, WIE du sie selbst lösen kannst! 🎓
189
+
190
+ **Beispiel-Fragen:**
191
+ - Was ist Prozentrechnung?
192
+ - Erkläre mir das Dreisatz-Prinzip
193
+ - Wie funktioniert Photosynthese?
194
+ - Ich verstehe Bruchrechnung nicht
195
+
196
+ Stell mir deine Fragen! 💪
197
+ """
198
+ )
199
+
200
+ chatbot = gr.ChatInterface(
201
+ fn=chat,
202
+ examples=[
203
+ "Was ist 20% von 150?",
204
+ "Erkläre mir Bruchrechnung",
205
+ "Wie funktioniert Photosynthese?",
206
+ "Was ist das Dreisatz-Prinzip?",
207
+ "Kannst du meine Mathe-Hausaufgabe lösen?",
208
+ ],
209
+ type="messages",
210
+ chatbot=gr.Chatbot(elem_id="chatbot", height=600),
211
+ )
212
 
213
  if __name__ == "__main__":
214
+ demo.launch(ssr_mode=False)
215
+