Subahdip627 commited on
Commit
8ab5c7a
·
verified ·
1 Parent(s): 57718f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +150 -103
app.py CHANGED
@@ -1,6 +1,6 @@
1
  """
2
  PaperSearchPro - STRICT Hierarchical Keyword Search
3
- PREMIUM GUI with White Background and Modern Design
4
  """
5
 
6
  import requests
@@ -10,19 +10,25 @@ from datetime import datetime
10
  import gradio as gr
11
  import tempfile
12
 
13
- # Custom CSS for premium white background design
14
  custom_css = """
 
 
 
15
  :root {
16
  --primary-color: #2563eb;
 
17
  --secondary-color: #7c3aed;
18
  --success-color: #10b981;
19
  --warning-color: #f59e0b;
20
  --danger-color: #ef4444;
21
- --text-primary: #1f2937;
22
- --text-secondary: #6b7280;
 
23
  --border-color: #e5e7eb;
24
  --bg-white: #ffffff;
25
  --bg-light: #f9fafb;
 
26
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
27
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
28
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
@@ -34,7 +40,13 @@ custom_css = """
34
  /* Main container */
35
  .gradio-container {
36
  background-color: var(--bg-light) !important;
37
- font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
 
 
 
 
 
 
38
  }
39
 
40
  /* White cards */
@@ -52,14 +64,11 @@ custom_css = """
52
  }
53
 
54
  /* Headers */
55
- h1, h2, h3 {
56
- color: var(--text-primary) !important;
57
- font-weight: 600 !important;
58
- }
59
-
60
  h1 {
61
  font-size: 2rem !important;
62
- margin-bottom: 1rem !important;
 
 
63
  }
64
 
65
  h1 span {
@@ -68,21 +77,59 @@ h1 span {
68
  -webkit-text-fill-color: transparent;
69
  }
70
 
71
- /* Input fields */
72
- .gr-box, .gr-input, .gr-textarea {
 
 
 
 
 
 
 
73
  background-color: var(--bg-white) !important;
74
  border: 1px solid var(--border-color) !important;
75
  border-radius: var(--radius-md) !important;
76
- padding: 0.5rem !important;
77
- transition: border-color 0.3s, box-shadow 0.3s !important;
 
 
 
 
 
 
 
78
  }
79
 
80
- .gr-box:focus, .gr-input:focus, .gr-textarea:focus {
81
  border-color: var(--primary-color) !important;
82
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
83
  outline: none !important;
84
  }
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  /* Buttons */
87
  .gr-button-primary {
88
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
@@ -91,7 +138,9 @@ h1 span {
91
  font-weight: 600 !important;
92
  padding: 0.75rem 1.5rem !important;
93
  border-radius: var(--radius-md) !important;
94
- transition: transform 0.2s, box-shadow 0.2s !important;
 
 
95
  }
96
 
97
  .gr-button-primary:hover {
@@ -99,10 +148,6 @@ h1 span {
99
  box-shadow: var(--shadow-md) !important;
100
  }
101
 
102
- .gr-button-primary:active {
103
- transform: translateY(0);
104
- }
105
-
106
  .gr-button-secondary {
107
  background-color: var(--bg-white) !important;
108
  border: 1px solid var(--border-color) !important;
@@ -111,22 +156,16 @@ h1 span {
111
  padding: 0.75rem 1.5rem !important;
112
  border-radius: var(--radius-md) !important;
113
  transition: all 0.2s !important;
 
 
114
  }
115
 
116
  .gr-button-secondary:hover {
117
- background-color: var(--bg-light) !important;
118
  border-color: var(--text-secondary) !important;
119
  }
120
 
121
- /* Labels and text */
122
- label {
123
- color: var(--text-secondary) !important;
124
- font-size: 0.875rem !important;
125
- font-weight: 500 !important;
126
- margin-bottom: 0.25rem !important;
127
- }
128
-
129
- /* Dataframe/Table */
130
  .gr-dataframe {
131
  background-color: var(--bg-white) !important;
132
  border: 1px solid var(--border-color) !important;
@@ -137,6 +176,7 @@ label {
137
  .gr-dataframe table {
138
  border-collapse: separate !important;
139
  border-spacing: 0 !important;
 
140
  }
141
 
142
  .gr-dataframe th {
@@ -144,14 +184,16 @@ label {
144
  color: var(--text-primary) !important;
145
  font-weight: 600 !important;
146
  font-size: 0.875rem !important;
147
- padding: 0.75rem !important;
148
  border-bottom: 2px solid var(--border-color) !important;
 
149
  }
150
 
151
  .gr-dataframe td {
152
- padding: 0.75rem !important;
153
  border-bottom: 1px solid var(--border-color) !important;
154
  color: var(--text-primary) !important;
 
155
  }
156
 
157
  .gr-dataframe tr:last-child td {
@@ -167,104 +209,109 @@ label {
167
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)) !important;
168
  }
169
 
170
- /* Checkbox */
171
- .gr-checkbox {
172
- accent-color: var(--primary-color) !important;
173
  }
174
 
175
- /* Tabs */
176
- .gr-tabs {
177
- background-color: var(--bg-white) !important;
178
- border-radius: var(--radius-lg) !important;
179
- padding: 0.5rem !important;
180
  }
181
 
182
- .gr-tabs .tab-nav {
183
- border-bottom: 2px solid var(--border-color) !important;
 
184
  }
185
 
186
- .gr-tabs .tab-nav button {
187
- color: var(--text-secondary) !important;
188
- font-weight: 500 !important;
189
- padding: 0.75rem 1.5rem !important;
190
- border: none !important;
191
- background: transparent !important;
192
- transition: all 0.2s !important;
 
193
  }
194
 
195
- .gr-tabs .tab-nav button.selected {
 
 
196
  color: var(--primary-color) !important;
197
- border-bottom: 2px solid var(--primary-color) !important;
198
- }
199
-
200
- /* Info boxes */
201
- .info-box {
202
- background: linear-gradient(135deg, #f0f9ff, #e6f7ff);
203
- border-left: 4px solid var(--primary-color);
204
- border-radius: var(--radius-md);
205
- padding: 1rem;
206
- margin: 1rem 0;
207
  }
208
 
209
- .warning-box {
210
- background: linear-gradient(135deg, #fef3c7, #fffbeb);
211
- border-left: 4px solid var(--warning-color);
212
- border-radius: var(--radius-md);
213
- padding: 1rem;
214
- margin: 1rem 0;
215
- }
216
-
217
- .success-box {
218
- background: linear-gradient(135deg, #d1fae5, #ecfdf5);
219
- border-left: 4px solid var(--success-color);
220
- border-radius: var(--radius-md);
221
- padding: 1rem;
222
- margin: 1rem 0;
223
  }
224
 
225
- /* Keyword badges */
226
  .keyword-badge {
227
  display: inline-block;
228
- padding: 0.25rem 0.75rem;
229
  border-radius: 9999px;
230
  font-size: 0.875rem;
231
- font-weight: 500;
232
  margin: 0.25rem;
233
  }
234
 
235
  .keyword-required {
236
  background-color: #fee2e2;
237
- color: var(--danger-color);
238
  border: 1px solid #fecaca;
239
  }
240
 
241
  .keyword-optional {
242
  background-color: #dcfce7;
243
- color: var(--success-color);
244
  border: 1px solid #bbf7d0;
245
  }
246
 
247
- /* Metrics cards */
248
- .metric-card {
249
- background-color: var(--bg-white);
250
- border-radius: var(--radius-lg);
251
- padding: 1.25rem;
252
- box-shadow: var(--shadow-sm);
253
- border: 1px solid var(--border-color);
254
- text-align: center;
255
  }
256
 
257
- .metric-value {
258
- font-size: 1.875rem;
259
- font-weight: 700;
260
- color: var(--primary-color);
261
- line-height: 1;
262
  }
263
 
264
- .metric-label {
265
- font-size: 0.875rem;
266
- color: var(--text-secondary);
267
- margin-top: 0.5rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  }
269
  """
270
 
@@ -485,7 +532,7 @@ def create_interface():
485
  gr.HTML("""
486
  <div style='text-align: center; padding: 2rem 0;'>
487
  <h1><span>📱 PaperSearchPro</span></h1>
488
- <p style='color: #6b7280; font-size: 1.1rem;'>Academic Paper Search with Hierarchical Keywords</p>
489
  </div>
490
  """)
491
 
@@ -513,8 +560,8 @@ def create_interface():
513
 
514
  # Keywords section with badges
515
  gr.HTML("""
516
- <div style='margin: 1rem 0;'>
517
- <h3 style='margin-bottom: 0.5rem;'>🔑 Keyword Hierarchy</h3>
518
  <div>
519
  <span class='keyword-badge keyword-required'>Keyword 1: REQUIRED</span>
520
  <span class='keyword-badge keyword-required'>Keyword 2: REQUIRED</span>
@@ -537,7 +584,7 @@ def create_interface():
537
  label="Sort By",
538
  choices=["relevance", "citations", "year"],
539
  value="relevance",
540
- elem_classes="gr-input"
541
  )
542
 
543
  with gr.Column():
@@ -545,7 +592,7 @@ def create_interface():
545
  label="Order",
546
  choices=["descending", "ascending"],
547
  value="descending",
548
- elem_classes="gr-input"
549
  )
550
 
551
  with gr.Column():
@@ -621,7 +668,7 @@ def create_interface():
621
  label="Format",
622
  choices=["CSV", "Excel"],
623
  value="CSV",
624
- elem_classes="gr-input"
625
  )
626
 
627
  export_btn = gr.Button(
 
1
  """
2
  PaperSearchPro - STRICT Hierarchical Keyword Search
3
+ PREMIUM GUI with White Background and Modern Design - FIXED TEXT VISIBILITY
4
  """
5
 
6
  import requests
 
10
  import gradio as gr
11
  import tempfile
12
 
13
+ # Custom CSS for premium white background design - FIXED TEXT COLORS
14
  custom_css = """
15
+ /* Import Inter font */
16
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
17
+
18
  :root {
19
  --primary-color: #2563eb;
20
+ --primary-dark: #1d4ed8;
21
  --secondary-color: #7c3aed;
22
  --success-color: #10b981;
23
  --warning-color: #f59e0b;
24
  --danger-color: #ef4444;
25
+ --text-primary: #111827;
26
+ --text-secondary: #4b5563;
27
+ --text-muted: #6b7280;
28
  --border-color: #e5e7eb;
29
  --bg-white: #ffffff;
30
  --bg-light: #f9fafb;
31
+ --bg-hover: #f3f4f6;
32
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
33
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
34
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
 
40
  /* Main container */
41
  .gradio-container {
42
  background-color: var(--bg-light) !important;
43
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
44
+ color: var(--text-primary) !important;
45
+ }
46
+
47
+ /* All text elements */
48
+ label, span, div, p, h1, h2, h3, h4, h5, h6 {
49
+ color: var(--text-primary) !important;
50
  }
51
 
52
  /* White cards */
 
64
  }
65
 
66
  /* Headers */
 
 
 
 
 
67
  h1 {
68
  font-size: 2rem !important;
69
+ font-weight: 700 !important;
70
+ margin-bottom: 0.5rem !important;
71
+ color: var(--text-primary) !important;
72
  }
73
 
74
  h1 span {
 
77
  -webkit-text-fill-color: transparent;
78
  }
79
 
80
+ h3 {
81
+ font-size: 1.25rem !important;
82
+ font-weight: 600 !important;
83
+ color: var(--text-primary) !important;
84
+ margin-bottom: 1rem !important;
85
+ }
86
+
87
+ /* Input fields - FIXED TEXT COLOR */
88
+ .gr-box, .gr-input, .gr-textarea, input, textarea, select {
89
  background-color: var(--bg-white) !important;
90
  border: 1px solid var(--border-color) !important;
91
  border-radius: var(--radius-md) !important;
92
+ padding: 0.625rem !important;
93
+ color: var(--text-primary) !important;
94
+ font-size: 0.95rem !important;
95
+ transition: all 0.2s !important;
96
+ }
97
+
98
+ .gr-box::placeholder, .gr-input::placeholder, .gr-textarea::placeholder {
99
+ color: var(--text-muted) !important;
100
+ opacity: 0.7 !important;
101
  }
102
 
103
+ .gr-box:focus, .gr-input:focus, .gr-textarea:focus, input:focus, textarea:focus, select:focus {
104
  border-color: var(--primary-color) !important;
105
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
106
  outline: none !important;
107
  }
108
 
109
+ /* Labels - FIXED VISIBILITY */
110
+ label, .gr-label {
111
+ color: var(--text-secondary) !important;
112
+ font-size: 0.875rem !important;
113
+ font-weight: 600 !important;
114
+ margin-bottom: 0.375rem !important;
115
+ display: block !important;
116
+ }
117
+
118
+ /* Dropdown/Select - FIXED */
119
+ select, .gr-dropdown {
120
+ background-color: var(--bg-white) !important;
121
+ color: var(--text-primary) !important;
122
+ border: 1px solid var(--border-color) !important;
123
+ padding: 0.625rem !important;
124
+ border-radius: var(--radius-md) !important;
125
+ cursor: pointer !important;
126
+ }
127
+
128
+ select option {
129
+ background-color: var(--bg-white) !important;
130
+ color: var(--text-primary) !important;
131
+ }
132
+
133
  /* Buttons */
134
  .gr-button-primary {
135
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
 
138
  font-weight: 600 !important;
139
  padding: 0.75rem 1.5rem !important;
140
  border-radius: var(--radius-md) !important;
141
+ transition: all 0.2s !important;
142
+ cursor: pointer !important;
143
+ font-size: 1rem !important;
144
  }
145
 
146
  .gr-button-primary:hover {
 
148
  box-shadow: var(--shadow-md) !important;
149
  }
150
 
 
 
 
 
151
  .gr-button-secondary {
152
  background-color: var(--bg-white) !important;
153
  border: 1px solid var(--border-color) !important;
 
156
  padding: 0.75rem 1.5rem !important;
157
  border-radius: var(--radius-md) !important;
158
  transition: all 0.2s !important;
159
+ cursor: pointer !important;
160
+ font-size: 1rem !important;
161
  }
162
 
163
  .gr-button-secondary:hover {
164
+ background-color: var(--bg-hover) !important;
165
  border-color: var(--text-secondary) !important;
166
  }
167
 
168
+ /* Dataframe/Table - FIXED TEXT */
 
 
 
 
 
 
 
 
169
  .gr-dataframe {
170
  background-color: var(--bg-white) !important;
171
  border: 1px solid var(--border-color) !important;
 
176
  .gr-dataframe table {
177
  border-collapse: separate !important;
178
  border-spacing: 0 !important;
179
+ width: 100% !important;
180
  }
181
 
182
  .gr-dataframe th {
 
184
  color: var(--text-primary) !important;
185
  font-weight: 600 !important;
186
  font-size: 0.875rem !important;
187
+ padding: 0.875rem !important;
188
  border-bottom: 2px solid var(--border-color) !important;
189
+ text-align: left !important;
190
  }
191
 
192
  .gr-dataframe td {
193
+ padding: 0.875rem !important;
194
  border-bottom: 1px solid var(--border-color) !important;
195
  color: var(--text-primary) !important;
196
+ font-size: 0.875rem !important;
197
  }
198
 
199
  .gr-dataframe tr:last-child td {
 
209
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)) !important;
210
  }
211
 
212
+ .gr-slider-value {
213
+ color: var(--text-primary) !important;
214
+ font-weight: 600 !important;
215
  }
216
 
217
+ /* Checkbox - FIXED */
218
+ .gr-checkbox {
219
+ accent-color: var(--primary-color) !important;
 
 
220
  }
221
 
222
+ .gr-checkbox-label {
223
+ color: var(--text-primary) !important;
224
+ margin-left: 0.5rem !important;
225
  }
226
 
227
+ /* Metric cards - FIXED */
228
+ .metric-card {
229
+ background-color: var(--bg-white);
230
+ border-radius: var(--radius-lg);
231
+ padding: 1.25rem;
232
+ box-shadow: var(--shadow-sm);
233
+ border: 1px solid var(--border-color);
234
+ text-align: center;
235
  }
236
 
237
+ .metric-value {
238
+ font-size: 2rem !important;
239
+ font-weight: 700 !important;
240
  color: var(--primary-color) !important;
241
+ line-height: 1.2 !important;
242
+ margin: 0 !important;
 
 
 
 
 
 
 
 
243
  }
244
 
245
+ .metric-label {
246
+ font-size: 0.875rem !important;
247
+ color: var(--text-secondary) !important;
248
+ margin-top: 0.5rem !important;
249
+ font-weight: 500 !important;
 
 
 
 
 
 
 
 
 
250
  }
251
 
252
+ /* Keyword badges - FIXED */
253
  .keyword-badge {
254
  display: inline-block;
255
+ padding: 0.375rem 1rem;
256
  border-radius: 9999px;
257
  font-size: 0.875rem;
258
+ font-weight: 600;
259
  margin: 0.25rem;
260
  }
261
 
262
  .keyword-required {
263
  background-color: #fee2e2;
264
+ color: #b91c1c !important;
265
  border: 1px solid #fecaca;
266
  }
267
 
268
  .keyword-optional {
269
  background-color: #dcfce7;
270
+ color: #166534 !important;
271
  border: 1px solid #bbf7d0;
272
  }
273
 
274
+ /* Info boxes - FIXED TEXT */
275
+ .info-box {
276
+ background: linear-gradient(135deg, #f0f9ff, #e6f7ff);
277
+ border-left: 4px solid var(--primary-color);
278
+ border-radius: var(--radius-md);
279
+ padding: 1rem;
280
+ margin: 1rem 0;
 
281
  }
282
 
283
+ .info-box strong, .info-box p, .info-box div {
284
+ color: var(--text-primary) !important;
 
 
 
285
  }
286
 
287
+ /* Status text */
288
+ .gr-status, .gr-message {
289
+ color: var(--text-primary) !important;
290
+ font-size: 0.875rem !important;
291
+ }
292
+
293
+ /* Markdown content */
294
+ .gr-markdown {
295
+ color: var(--text-primary) !important;
296
+ }
297
+
298
+ .gr-markdown p, .gr-markdown h1, .gr-markdown h2, .gr-markdown h3 {
299
+ color: var(--text-primary) !important;
300
+ }
301
+
302
+ /* Links */
303
+ a {
304
+ color: var(--primary-color) !important;
305
+ text-decoration: none !important;
306
+ }
307
+
308
+ a:hover {
309
+ text-decoration: underline !important;
310
+ }
311
+
312
+ /* Ensure all text is visible */
313
+ * {
314
+ color: inherit;
315
  }
316
  """
317
 
 
532
  gr.HTML("""
533
  <div style='text-align: center; padding: 2rem 0;'>
534
  <h1><span>📱 PaperSearchPro</span></h1>
535
+ <p style='color: #4b5563; font-size: 1.1rem;'>Academic Paper Search with Hierarchical Keywords</p>
536
  </div>
537
  """)
538
 
 
560
 
561
  # Keywords section with badges
562
  gr.HTML("""
563
+ <div style='margin: 1.5rem 0;'>
564
+ <h3 style='color: #111827; margin-bottom: 0.75rem;'>🔑 Keyword Hierarchy</h3>
565
  <div>
566
  <span class='keyword-badge keyword-required'>Keyword 1: REQUIRED</span>
567
  <span class='keyword-badge keyword-required'>Keyword 2: REQUIRED</span>
 
584
  label="Sort By",
585
  choices=["relevance", "citations", "year"],
586
  value="relevance",
587
+ elem_classes="gr-dropdown"
588
  )
589
 
590
  with gr.Column():
 
592
  label="Order",
593
  choices=["descending", "ascending"],
594
  value="descending",
595
+ elem_classes="gr-dropdown"
596
  )
597
 
598
  with gr.Column():
 
668
  label="Format",
669
  choices=["CSV", "Excel"],
670
  value="CSV",
671
+ elem_classes="gr-dropdown"
672
  )
673
 
674
  export_btn = gr.Button(