kdallash commited on
Commit
1da590d
ยท
verified ยท
1 Parent(s): b057615

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -15
app.py CHANGED
@@ -7,7 +7,7 @@ import html
7
  from sentence_transformers import SentenceTransformer
8
  import os
9
 
10
- os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1" # โ† Changed to 1 for faster model loading next time
11
 
12
  # ===============================
13
  # Load data & models (ONCE)
@@ -69,7 +69,7 @@ def short_preview(text, length=300):
69
  return text[:length].rsplit(' ', 1)[0] + "..."
70
 
71
  # ===============================
72
- # Search Function (with Arabic messages)
73
  # ===============================
74
  def search_hadith(query, top_k):
75
  if not query or not str(query).strip():
@@ -142,7 +142,7 @@ def search_hadith(query, top_k):
142
  return "\n".join(html_parts)
143
 
144
  # ===============================
145
- # PROFESSIONAL DARK MODE + PERFECT ARABIC TYPOGRAPHY CSS
146
  # ===============================
147
  custom_css = """
148
  @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@400;500;700&display=swap');
@@ -158,7 +158,7 @@ custom_css = """
158
  --button-primary-background-fill-hover: #2563eb !important;
159
  }
160
 
161
- /* Force dark + best Arabic font */
162
  body, .gradio-container, .gr-panel, .gr-box, .gr-form, .wrap, .panel, .block, footer {
163
  background-color: #020617 !important;
164
  color: #f1f5f9 !important;
@@ -166,26 +166,24 @@ body, .gradio-container, .gr-panel, .gr-box, .gr-form, .wrap, .panel, .block, fo
166
  }
167
  .gradio-container { max-width: 960px !important; margin: 0 auto !important; }
168
 
169
- /* Arabic text optimization */
170
  .text-rtl, .full-text, .summary, .title, .topic {
171
  font-family: 'Cairo', 'Noto Sans Arabic', sans-serif !important;
172
  line-height: 2.05 !important;
173
  }
174
 
175
- /* Inputs */
176
  label span, input, textarea, .gr-input, .gr-textarea {
177
  color: #f1f5f9 !important;
178
  background: #1e2937 !important;
179
  border-color: #475569 !important;
180
  }
181
-
182
- /* Buttons */
183
  button.primary {
184
  background: linear-gradient(90deg, #3b82f6, #60a5fa) !important;
185
  font-weight: 600 !important;
186
  }
187
 
188
- /* Cards - Premium dark look */
189
  .card {
190
  background: #1e2937 !important;
191
  border-radius: 18px !important;
@@ -218,7 +216,26 @@ button.primary {
218
  color: #e2e8f0 !important;
219
  }
220
 
221
- /* Rest of the styles (same as before - clean & professional) */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  .results { margin-top: 24px; }
223
  .footer a { color: #60a5fa !important; font-weight: 600 !important; }
224
  .empty { color: #94a3b8 !important; text-align: center; padding: 50px 20px; font-size: 17px; }
@@ -229,7 +246,7 @@ button.primary {
229
  """
230
 
231
  # ===============================
232
- # Gradio Interface (Fixed for 6.9.0)
233
  # ===============================
234
  interface = gr.Interface(
235
  fn=search_hadith,
@@ -249,10 +266,10 @@ interface = gr.Interface(
249
  )
250
  ],
251
  outputs=gr.HTML(),
252
- title="๐Ÿ“– ู…ุญุฑูƒ ุจุญุซ ุงู„ุญุฏูŠุซ ุงู„ุฐูƒูŠ",
253
  description="""
254
- ู…ุญุฑูƒ ุจุญุซ ุฏู„ุงู„ูŠ ู…ุชุทูˆุฑ ู„ู„ุญุฏูŠุซ ุงู„ู†ุจูˆูŠ ุงู„ุดุฑูŠู<br>
255
- ูŠุฌู…ุน ุจูŠู† ุงู„ุจุญุซ ุงู„ู…ุนุฌู…ูŠ (BM25) ูˆุงู„ุฏู„ุงู„ูŠ (Embeddings) ูˆุชู‚ู†ูŠุฉ ุงู„ู€ Anchors
256
  """,
257
  examples=[
258
  ["ุฃู‡ู…ูŠุฉ ุงู„ู†ูŠุฉ ูˆุฃุซุฑู‡ุง ููŠ ู‚ุจูˆู„ ุงู„ุฃุนู…ุงู„", 5],
@@ -260,7 +277,7 @@ interface = gr.Interface(
260
  ["ูุถู„ ุงู„ุตู„ุงุฉ ุนู„ู‰ ุงู„ู†ุจูŠ ๏ทบ", 5]
261
  ],
262
  flagging_mode="never",
263
- theme=gr.themes.Soft(), # โ† FIXED: Compatible with Gradio 6.9.0
264
  css=custom_css
265
  )
266
 
 
7
  from sentence_transformers import SentenceTransformer
8
  import os
9
 
10
+ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
11
 
12
  # ===============================
13
  # Load data & models (ONCE)
 
69
  return text[:length].rsplit(' ', 1)[0] + "..."
70
 
71
  # ===============================
72
+ # Search Function
73
  # ===============================
74
  def search_hadith(query, top_k):
75
  if not query or not str(query).strip():
 
142
  return "\n".join(html_parts)
143
 
144
  # ===============================
145
+ # PROFESSIONAL DARK MODE + PERFECT ARABIC TYPOGRAPHY + HIDDEN SCROLL ARROWS
146
  # ===============================
147
  custom_css = """
148
  @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@400;500;700&display=swap');
 
158
  --button-primary-background-fill-hover: #2563eb !important;
159
  }
160
 
161
+ /* Global dark + Arabic font */
162
  body, .gradio-container, .gr-panel, .gr-box, .gr-form, .wrap, .panel, .block, footer {
163
  background-color: #020617 !important;
164
  color: #f1f5f9 !important;
 
166
  }
167
  .gradio-container { max-width: 960px !important; margin: 0 auto !important; }
168
 
169
+ /* Arabic text perfection */
170
  .text-rtl, .full-text, .summary, .title, .topic {
171
  font-family: 'Cairo', 'Noto Sans Arabic', sans-serif !important;
172
  line-height: 2.05 !important;
173
  }
174
 
175
+ /* Inputs & Buttons */
176
  label span, input, textarea, .gr-input, .gr-textarea {
177
  color: #f1f5f9 !important;
178
  background: #1e2937 !important;
179
  border-color: #475569 !important;
180
  }
 
 
181
  button.primary {
182
  background: linear-gradient(90deg, #3b82f6, #60a5fa) !important;
183
  font-weight: 600 !important;
184
  }
185
 
186
+ /* Premium result cards */
187
  .card {
188
  background: #1e2937 !important;
189
  border-radius: 18px !important;
 
216
  color: #e2e8f0 !important;
217
  }
218
 
219
+ /* Hide the unwanted white scroll arrow boxes (the ones in your 2nd screenshot) */
220
+ .gradio-container button[aria-label*="Scroll"],
221
+ .gradio-container .gr-button.scroll,
222
+ .gr-scrollbar-button,
223
+ ::-webkit-scrollbar-button,
224
+ [data-testid*="scroll"],
225
+ button[class*="scroll"],
226
+ .scroll-button,
227
+ .gr-scroll-button {
228
+ display: none !important;
229
+ visibility: hidden !important;
230
+ opacity: 0 !important;
231
+ pointer-events: none !important;
232
+ }
233
+
234
+ /* Clean up any remaining floating arrows */
235
+ .gradio-container > div > button:last-child {
236
+ display: none !important;
237
+ }
238
+
239
  .results { margin-top: 24px; }
240
  .footer a { color: #60a5fa !important; font-weight: 600 !important; }
241
  .empty { color: #94a3b8 !important; text-align: center; padding: 50px 20px; font-size: 17px; }
 
246
  """
247
 
248
  # ===============================
249
+ # Gradio Interface โ€“ ENGLISH HEADER ONLY
250
  # ===============================
251
  interface = gr.Interface(
252
  fn=search_hadith,
 
266
  )
267
  ],
268
  outputs=gr.HTML(),
269
+ title="๐Ÿ“– Intelligent Hadith Search Engine",
270
  description="""
271
+ Advanced AI-powered semantic search engine for the Noble Prophetic Hadith.<br>
272
+ Combines lexical search (BM25), semantic embeddings, and topic-aware Anchors.
273
  """,
274
  examples=[
275
  ["ุฃู‡ู…ูŠุฉ ุงู„ู†ูŠุฉ ูˆุฃุซุฑู‡ุง ููŠ ู‚ุจูˆู„ ุงู„ุฃุนู…ุงู„", 5],
 
277
  ["ูุถู„ ุงู„ุตู„ุงุฉ ุนู„ู‰ ุงู„ู†ุจูŠ ๏ทบ", 5]
278
  ],
279
  flagging_mode="never",
280
+ theme=gr.themes.Soft(),
281
  css=custom_css
282
  )
283