legends810 commited on
Commit
171ec9a
·
verified ·
1 Parent(s): 072d959

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -122
app.py CHANGED
@@ -145,42 +145,12 @@ custom_css = """
145
  min-height: 100vh;
146
  }
147
 
148
- /* Header styling */
149
- .main-header {
150
- text-align: center;
151
- padding: 2rem 0;
152
- background: rgba(255, 255, 255, 0.8);
153
- border-radius: 1rem;
154
- margin-bottom: 2rem;
155
- backdrop-filter: blur(10px);
156
- }
157
-
158
  /* Chat interface styling */
159
  .chat-interface {
160
  max-width: 800px;
161
  margin: 0 auto;
162
  }
163
 
164
- /* Chatbot messages */
165
- .message.user {
166
- background: linear-gradient(135deg, #EAE4DE 0%, #D9CFC7 100%) !important;
167
- border-radius: 1rem 1rem 0.5rem 1rem !important;
168
- }
169
-
170
- .message.bot {
171
- background: linear-gradient(135deg, #F7F5F2 0%, #EFEBE7 100%) !important;
172
- border-radius: 1rem 1rem 1rem 0.5rem !important;
173
- border-left: 4px solid #D97757 !important;
174
- }
175
-
176
- /* Input styling */
177
- .input-container {
178
- background: rgba(255, 255, 255, 0.9) !important;
179
- border-radius: 1rem !important;
180
- border: 2px solid #EAE8E5 !important;
181
- backdrop-filter: blur(10px);
182
- }
183
-
184
  /* Button styling */
185
  .submit-btn {
186
  background: linear-gradient(135deg, #D97757 0%, #B85C42 100%) !important;
@@ -194,41 +164,6 @@ custom_css = """
194
  transform: translateY(-2px) !important;
195
  box-shadow: 0 8px 25px rgba(217, 119, 87, 0.3) !important;
196
  }
197
-
198
- /* Examples styling */
199
- .examples-container {
200
- display: flex;
201
- flex-wrap: wrap;
202
- gap: 0.5rem;
203
- justify-content: center;
204
- margin-top: 1rem;
205
- }
206
-
207
- .example-btn {
208
- background: rgba(247, 245, 242, 0.8) !important;
209
- border: 1px solid #EAE8E5 !important;
210
- border-radius: 2rem !important;
211
- padding: 0.5rem 1rem !important;
212
- font-size: 0.875rem !important;
213
- color: #5A524C !important;
214
- transition: all 0.2s ease !important;
215
- }
216
-
217
- .example-btn:hover {
218
- background: rgba(217, 119, 87, 0.1) !important;
219
- border-color: #D97757 !important;
220
- transform: translateY(-1px) !important;
221
- }
222
-
223
- /* Footer */
224
- .footer-info {
225
- text-align: center;
226
- padding: 1rem;
227
- color: #8B7355;
228
- font-size: 0.875rem;
229
- border-top: 1px solid #EAE8E5;
230
- background: rgba(255, 255, 255, 0.5);
231
- }
232
  """
233
 
234
  # Create Gradio Interface
@@ -243,69 +178,80 @@ with gr.Blocks(
243
  ) as demo:
244
 
245
  # Header
246
- with gr.Row(elem_classes="main-header"):
247
- with gr.Column():
248
- gr.HTML("""
249
- <div style="display: flex; align-items: center; justify-content: center; gap: 1rem;">
250
- <svg width="48" height="48" viewBox="0 0 100 100">
251
- <path d="M50 0 L61.8 38.2 L100 38.2 L69.1 61.8 L80.9 100 L50 76.4 L19.1 100 L30.9 61.8 L0 38.2 L38.2 38.2 Z" fill="#D97757"/>
252
- </svg>
253
- <h1 style="font-size: 2.5rem; font-weight: 600; color: #3D3D3D; margin: 0; font-family: 'Playfair Display', serif;">
254
- Hi, कैसे मदद कर सकता हूँ?
255
- </h1>
256
- </div>
257
- <p style="color: #8B7355; margin-top: 0.5rem; font-size: 1.1rem;">
258
- आपका AI Assistant - Hindi और English में बातचीत के लिए तैयार
259
- </p>
260
- """)
261
 
262
  # Main Chat Interface
263
- with gr.Row(elem_classes="chat-interface"):
264
- with gr.Column(scale=1):
265
- chatbot = gr.Chatbot(
266
- [],
267
- height=500,
268
- show_label=False,
269
- avatar_images=("👤", "🤖"),
270
- bubble_full_width=False,
271
- show_share_button=False,
272
- show_copy_button=True
273
- )
274
-
275
- with gr.Row():
276
- with gr.Column(scale=8):
277
- msg = gr.Textbox(
278
- placeholder="मुझसे कुछ भी पूछें... (Hindi या English में)",
279
- show_label=False,
280
- container=False,
281
- lines=1,
282
- max_lines=5
283
- )
284
- with gr.Column(scale=1, min_width=80):
285
- submit = gr.Button(
286
- "भेजें ➤",
287
- variant="primary",
288
- elem_classes="submit-btn"
289
- )
290
-
291
- # Example prompts
292
- with gr.Row():
293
- gr.Examples(
294
- examples=[
295
- ["एक कविता लिखकर दो"],
296
- ["Python में calculator बनाना सिखाएं"],
297
- ["मुझसे बात करिए"],
298
- ["What is machine learning?"],
299
- ["भारत का इतिहास बताएं"],
300
- ["कोई मजेदार fact बताएं"]
301
- ],
302
- inputs=msg,
303
- elem_classes="examples-container"
304
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
306
  # Footer
307
  gr.HTML("""
308
- <div class="footer-info">
309
  <p>🔒 Powered by <strong>Pollinations AI</strong> | 🌟 Built with Gradio on Hugging Face Spaces</p>
310
  <p style="font-size: 0.75rem; margin-top: 0.5rem;">
311
  यह AI assistant आपकी बातचीत को याद रखता है और context के साथ जवाब देता है
 
145
  min-height: 100vh;
146
  }
147
 
 
 
 
 
 
 
 
 
 
 
148
  /* Chat interface styling */
149
  .chat-interface {
150
  max-width: 800px;
151
  margin: 0 auto;
152
  }
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  /* Button styling */
155
  .submit-btn {
156
  background: linear-gradient(135deg, #D97757 0%, #B85C42 100%) !important;
 
164
  transform: translateY(-2px) !important;
165
  box-shadow: 0 8px 25px rgba(217, 119, 87, 0.3) !important;
166
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  """
168
 
169
  # Create Gradio Interface
 
178
  ) as demo:
179
 
180
  # Header
181
+ gr.HTML("""
182
+ <div style="text-align: center; padding: 2rem 0; background: rgba(255, 255, 255, 0.8); border-radius: 1rem; margin-bottom: 2rem; backdrop-filter: blur(10px);">
183
+ <div style="display: flex; align-items: center; justify-content: center; gap: 1rem;">
184
+ <svg width="48" height="48" viewBox="0 0 100 100">
185
+ <path d="M50 0 L61.8 38.2 L100 38.2 L69.1 61.8 L80.9 100 L50 76.4 L19.1 100 L30.9 61.8 L0 38.2 L38.2 38.2 Z" fill="#D97757"/>
186
+ </svg>
187
+ <h1 style="font-size: 2.5rem; font-weight: 600; color: #3D3D3D; margin: 0; font-family: 'Playfair Display', serif;">
188
+ Hi, कैसे मदद कर सकता हूँ?
189
+ </h1>
190
+ </div>
191
+ <p style="color: #8B7355; margin-top: 0.5rem; font-size: 1.1rem;">
192
+ आपका AI Assistant - Hindi और English में बातचीत के लिए तैयार
193
+ </p>
194
+ </div>
195
+ """)
196
 
197
  # Main Chat Interface
198
+ with gr.Column():
199
+ # Fixed Chatbot with proper parameters
200
+ chatbot = gr.Chatbot(
201
+ value=[],
202
+ height=500,
203
+ show_label=False,
204
+ avatar_images=("👤", "🤖"),
205
+ show_share_button=False,
206
+ show_copy_button=True,
207
+ type="tuples" # Explicitly set type to avoid warning
208
+ )
209
+
210
+ with gr.Row():
211
+ with gr.Column(scale=8):
212
+ msg = gr.Textbox(
213
+ placeholder="मुझसे कुछ भी पूछें... (Hindi या English में)",
214
+ show_label=False,
215
+ container=False,
216
+ lines=1,
217
+ max_lines=5
218
+ )
219
+ with gr.Column(scale=1, min_width=80):
220
+ submit = gr.Button(
221
+ "भेजें ➤",
222
+ variant="primary"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  )
224
+
225
+ # Example prompts - Fixed without elem_classes
226
+ with gr.Row():
227
+ with gr.Column():
228
+ gr.Markdown("**कुछ सुझाव:**")
229
+ example_buttons = []
230
+ examples = [
231
+ "एक कविता लिखकर दो",
232
+ "Python में calculator बनाना सिखाएं",
233
+ "मुझसे बात करिए",
234
+ "What is machine learning?",
235
+ "भारत का इतिहास बताएं",
236
+ "कोई मजेदार fact बताएं"
237
+ ]
238
+
239
+ # Create example buttons manually
240
+ with gr.Row():
241
+ for i, example in enumerate(examples[:3]):
242
+ btn = gr.Button(example, size="sm", variant="secondary")
243
+ example_buttons.append(btn)
244
+ btn.click(lambda x=example: x, outputs=msg)
245
+
246
+ with gr.Row():
247
+ for i, example in enumerate(examples[3:]):
248
+ btn = gr.Button(example, size="sm", variant="secondary")
249
+ example_buttons.append(btn)
250
+ btn.click(lambda x=example: x, outputs=msg)
251
 
252
  # Footer
253
  gr.HTML("""
254
+ <div style="text-align: center; padding: 1rem; color: #8B7355; font-size: 0.875rem; border-top: 1px solid #EAE8E5; background: rgba(255, 255, 255, 0.5);">
255
  <p>🔒 Powered by <strong>Pollinations AI</strong> | 🌟 Built with Gradio on Hugging Face Spaces</p>
256
  <p style="font-size: 0.75rem; margin-top: 0.5rem;">
257
  यह AI assistant आपकी बातचीत को याद रखता है और context के साथ जवाब देता है