anaspro commited on
Commit
2585fc0
·
1 Parent(s): 283f8ba

Add RTL Arabic support with CSS and update examples to Arabic

Browse files
Files changed (1) hide show
  1. app.py +49 -3
app.py CHANGED
@@ -212,6 +212,46 @@ examples = [
212
  ["Write a short story about a robot learning to paint", "You are a helpful assistant.", 1000]
213
  ]
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  # Create the chat interface
216
  demo = gr.ChatInterface(
217
  fn=generate,
@@ -220,14 +260,20 @@ demo = gr.ChatInterface(
220
  file_types=list(IMAGE_FILE_TYPES + VIDEO_FILE_TYPES + AUDIO_FILE_TYPES),
221
  file_count="multiple",
222
  autofocus=True,
 
223
  ),
224
  multimodal=True,
225
  additional_inputs=[
226
- gr.Textbox(label="System Prompt", value="انت شخص عراقي عادي من بغداد، ذكي ومرح. تتحدث بالعراقي فقط وتجاوب بتفصيل حسب السؤال. ما تستخدم فصحى ابدا."),
227
  gr.Slider(label="Max New Tokens", minimum=100, maximum=2000, step=10, value=700),
228
  ],
229
- title="Shako IRAQI AI",
230
- examples=examples,
 
 
 
 
 
231
  stop_btn=False,
232
  )
233
 
 
212
  ["Write a short story about a robot learning to paint", "You are a helpful assistant.", 1000]
213
  ]
214
 
215
+ # CSS for RTL Arabic support
216
+ rtl_css = """
217
+ .arabic-rtl {
218
+ direction: rtl;
219
+ text-align: right;
220
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
221
+ }
222
+
223
+ .arabic-rtl .message {
224
+ direction: rtl;
225
+ text-align: right;
226
+ }
227
+
228
+ .arabic-rtl .message.user {
229
+ direction: rtl;
230
+ text-align: right;
231
+ }
232
+
233
+ .arabic-rtl .message.assistant {
234
+ direction: rtl;
235
+ text-align: right;
236
+ }
237
+
238
+ .arabic-rtl textarea, .arabic-rtl input {
239
+ direction: rtl;
240
+ text-align: right;
241
+ }
242
+
243
+ .arabic-rtl .gradio-container {
244
+ direction: rtl;
245
+ }
246
+
247
+ /* Make sure Arabic text displays properly */
248
+ .arabic-text {
249
+ font-family: 'Segoe UI', 'Arial Unicode MS', 'Noto Sans Arabic', sans-serif;
250
+ direction: rtl;
251
+ text-align: right;
252
+ }
253
+ """
254
+
255
  # Create the chat interface
256
  demo = gr.ChatInterface(
257
  fn=generate,
 
260
  file_types=list(IMAGE_FILE_TYPES + VIDEO_FILE_TYPES + AUDIO_FILE_TYPES),
261
  file_count="multiple",
262
  autofocus=True,
263
+ elem_classes=["arabic-rtl"]
264
  ),
265
  multimodal=True,
266
  additional_inputs=[
267
+ gr.Textbox(label="System Prompt", value="انت شخص عراقي عادي من بغداد، ذكي ومرح. تتحدث بالعراقي فقط وتجاوب بتفصيل حسب السؤال. ما تستخدم فصحى ابدا.", elem_classes=["arabic-rtl"]),
268
  gr.Slider(label="Max New Tokens", minimum=100, maximum=2000, step=10, value=700),
269
  ],
270
+ title="شكو - ذكاء عراقي",
271
+ examples=[
272
+ "مرحبا شكو، كيف حالك؟",
273
+ "شرح لي عن الذكاء الاصطناعي",
274
+ "أخبرني نكتة عراقية"
275
+ ],
276
+ css=rtl_css,
277
  stop_btn=False,
278
  )
279