ALLOUNE commited on
Commit
6986adb
·
1 Parent(s): be240c1
Files changed (3) hide show
  1. app.py +13 -30
  2. src/ressources/main_css.py +349 -0
  3. src/services/processor.py +5 -2
app.py CHANGED
@@ -62,7 +62,6 @@ async def process_constraints(constraints: InputConstraints):
62
  @app.post("/prior-art-constraints", response_model=OutputPriorArt)
63
  async def prior_art_constraints(data: InputPriorArtConstraints):
64
  prior_art = process_prior_art(data.technologies, data.constraints, "constraints", "pydantic")
65
- print(prior_art)
66
  return prior_art
67
 
68
  @app.post("/prior-art-problems", response_model=OutputPriorArt)
@@ -249,7 +248,6 @@ def format_prior_art_html(prior_art_data: dict) -> str:
249
  def gradio_prior_art(best_technologies, constraints):
250
  prior_art = process_prior_art(best_technologies, constraints, "constraints", "dict")
251
  html_prior_art = format_prior_art_html(prior_art)
252
- print(html_prior_art)
253
  return html_prior_art
254
 
255
  def process_input_gradio(problem_description: str):
@@ -297,19 +295,12 @@ def process_input_gradio(problem_description: str):
297
  final_technologies_html = format_final_technologies_html(best_technologies)
298
 
299
  return (
300
- prompt,
301
- constraints_html, # Output HTML for constraints
302
- best_combinations_html, # Output HTML for best combinations
303
- ", ".join(map(str, best_technologies_id)), # Still a simple text list
304
- final_technologies_html, # Output HTML for final technologies
305
- {"technologies": best_technologies}, # `best_technologies` is the actual list of dicts
306
  constraints
307
- )
308
-
309
-
310
- # Return a gr.update object to change the value and visibility in one step
311
- # return gr.update(value=html_prior_art, visible=True)
312
-
313
 
314
  # --- Gradio Interface Setup ---
315
  input_problem = gr.Textbox(
@@ -317,18 +308,16 @@ input_problem = gr.Textbox(
317
  placeholder="e.g., Develop a secure and scalable e-commerce platform with real-time analytics."
318
  )
319
 
320
- output_prompt = gr.Textbox(label="1. Generated Prompt", interactive=False)
321
- output_constraints = gr.HTML(label="2. Retrieved Constraints") # Changed to HTML
322
- output_best_combinations = gr.HTML(label="7. Best Technology Combinations Found") # Changed to HTML
323
- output_selected_ids = gr.Textbox(label="8. Selected Technology IDs", interactive=False)
324
- output_final_technologies = gr.HTML(label="9. Final Best Technologies") # Changed to HTML
325
- output_prior_art = gr.HTML(label="10. Prior Art Analysis") # Initially hidden
326
 
327
  stock_technologies = gr.JSON(visible=False)
328
  stock_constraints = gr.JSON(visible=False)
329
 
330
  with gr.Blocks(
331
- theme=gr.themes.Soft(),
332
  css=custom_css
333
  ) as gradio_app_blocks:
334
  gr.Markdown("# Insight Finder: Step-by-Step Technology Selection")
@@ -347,12 +336,11 @@ with gr.Blocks(
347
 
348
  with gr.Row():
349
  with gr.Column():
350
- output_prompt.render()
351
  output_constraints.render()
352
  with gr.Column():
353
- output_selected_ids.render()
354
  output_best_combinations.render()
355
- output_final_technologies.render()
 
356
 
357
  gr.Markdown("---")
358
  gr.Markdown("### Prior Art Analysis")
@@ -365,10 +353,8 @@ with gr.Blocks(
365
  fn=process_input_gradio,
366
  inputs=input_problem,
367
  outputs=[
368
- output_prompt,
369
  output_constraints,
370
  output_best_combinations,
371
- output_selected_ids,
372
  output_final_technologies,
373
  stock_technologies,
374
  stock_constraints
@@ -381,7 +367,4 @@ with gr.Blocks(
381
  outputs=output_prior_art
382
  )
383
 
384
-
385
- gr.mount_gradio_app(app, gradio_app_blocks, path="/gradio")
386
- #if __name__ == "__main__":
387
- # gradio_app_blocks.launch()
 
62
  @app.post("/prior-art-constraints", response_model=OutputPriorArt)
63
  async def prior_art_constraints(data: InputPriorArtConstraints):
64
  prior_art = process_prior_art(data.technologies, data.constraints, "constraints", "pydantic")
 
65
  return prior_art
66
 
67
  @app.post("/prior-art-problems", response_model=OutputPriorArt)
 
248
  def gradio_prior_art(best_technologies, constraints):
249
  prior_art = process_prior_art(best_technologies, constraints, "constraints", "dict")
250
  html_prior_art = format_prior_art_html(prior_art)
 
251
  return html_prior_art
252
 
253
  def process_input_gradio(problem_description: str):
 
295
  final_technologies_html = format_final_technologies_html(best_technologies)
296
 
297
  return (
298
+ constraints_html,
299
+ best_combinations_html,
300
+ final_technologies_html,
301
+ {"technologies": best_technologies},
 
 
302
  constraints
303
+ )
 
 
 
 
 
304
 
305
  # --- Gradio Interface Setup ---
306
  input_problem = gr.Textbox(
 
308
  placeholder="e.g., Develop a secure and scalable e-commerce platform with real-time analytics."
309
  )
310
 
311
+ output_constraints = gr.HTML(label="Retrieved Constraints") # Changed to HTML
312
+ output_best_combinations = gr.HTML(label="Best Technology Combinations Found") # Changed to HTML
313
+ output_final_technologies = gr.HTML(label="Final Best Technologies") # Changed to HTML
314
+ output_prior_art = gr.HTML(label="Prior Art Analysis") # Initially hidden
 
 
315
 
316
  stock_technologies = gr.JSON(visible=False)
317
  stock_constraints = gr.JSON(visible=False)
318
 
319
  with gr.Blocks(
320
+ theme=gr.themes.Base(),
321
  css=custom_css
322
  ) as gradio_app_blocks:
323
  gr.Markdown("# Insight Finder: Step-by-Step Technology Selection")
 
336
 
337
  with gr.Row():
338
  with gr.Column():
 
339
  output_constraints.render()
340
  with gr.Column():
 
341
  output_best_combinations.render()
342
+ with gr.Row():
343
+ output_final_technologies.render()
344
 
345
  gr.Markdown("---")
346
  gr.Markdown("### Prior Art Analysis")
 
353
  fn=process_input_gradio,
354
  inputs=input_problem,
355
  outputs=[
 
356
  output_constraints,
357
  output_best_combinations,
 
358
  output_final_technologies,
359
  stock_technologies,
360
  stock_constraints
 
367
  outputs=output_prior_art
368
  )
369
 
370
+ gr.mount_gradio_app(app, gradio_app_blocks, path="/gradio")
 
 
 
src/ressources/main_css.py ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ custom_css = """
2
+ /* General Body and Font Styling */
3
+ body {
4
+ color: #333;
5
+ background-color: #f0f2f5;
6
+ }
7
+
8
+ /* Header Styling */
9
+ .gradio-container h1 {
10
+ color: #0056b3; /* A deep blue for the main title */
11
+ text-align: center;
12
+ margin-bottom: 10px;
13
+ font-weight: 600;
14
+ font-size: 2.5em;
15
+ text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
16
+ }
17
+
18
+ .gradio-container h2 {
19
+ color: #007bff; /* A slightly lighter blue for subtitles */
20
+ text-align: center;
21
+ margin-top: 0;
22
+ margin-bottom: 30px;
23
+ font-weight: 400;
24
+ font-size: 1.2em;
25
+ }
26
+
27
+ /* Card-like styling for individual components */
28
+ .gradio-container .gr-box {
29
+ background-color: #ffffff;
30
+ border-radius: 12px;
31
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
32
+ padding: 20px;
33
+ margin-bottom: 20px;
34
+ border: 1px solid #e0e0e0;
35
+ }
36
+
37
+ /* Input Textbox Styling */
38
+ .gradio-container input[type="text"],
39
+ .gradio-container textarea {
40
+ border: 1px solid #ced4da;
41
+ border-radius: 8px;
42
+ padding: 12px 15px;
43
+ font-size: 1em;
44
+ color: #495057;
45
+ transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
46
+ }
47
+
48
+ .gradio-container input[type="text"]:focus,
49
+ .gradio-container textarea:focus {
50
+ border-color: #007bff;
51
+ box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
52
+ outline: none;
53
+ }
54
+
55
+ /* Button Styling */
56
+ .gradio-container button {
57
+ background-color: #28a745; /* A vibrant green for action */
58
+ color: white;
59
+ border: none;
60
+ border-radius: 8px;
61
+ padding: 12px 25px;
62
+ font-size: 1.1em;
63
+ font-weight: 500;
64
+ cursor: pointer;
65
+ transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
66
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
67
+ }
68
+
69
+ .gradio-container button:hover {
70
+ background-color: #218838; /* Darker green on hover */
71
+ transform: translateY(-2px);
72
+ }
73
+
74
+ .gradio-container button:active {
75
+ transform: translateY(0);
76
+ }
77
+
78
+ /* Labels for outputs */
79
+ .gradio-container label {
80
+ font-weight: 600;
81
+ color: #495057;
82
+ margin-bottom: 8px;
83
+ display: block; /* Ensure labels are on their own line */
84
+ font-size: 1.1em;
85
+ }
86
+
87
+ /* --- Specific Styling for Outputs --- */
88
+
89
+ /* 2. Retrieved Constraints Styling */
90
+ .constraints-container {
91
+ padding: 15px;
92
+ background-color: #f8f9fa;
93
+ border-radius: 8px;
94
+ border: 1px solid #e9ecef;
95
+ font-family: 'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif; /* Different font */
96
+ line-height: 1.6;
97
+ max-height: 300px;
98
+ overflow-y: auto;
99
+ }
100
+ .constraint-item {
101
+ margin-bottom: 10px;
102
+ padding-bottom: 10px;
103
+ border-bottom: 1px dashed #e0e0e0;
104
+ }
105
+ .constraint-item:last-child {
106
+ border-bottom: none;
107
+ margin-bottom: 0;
108
+ padding-bottom: 0;
109
+ }
110
+ .constraint-title {
111
+ font-weight: bold;
112
+ color: #004085; /* Darker blue for constraint titles */
113
+ font-size: 1.1em;
114
+ }
115
+ .constraint-description {
116
+ color: #333;
117
+ font-size: 1em;
118
+ }
119
+
120
+ /* 7. Best Technology Combinations Found & 9. Final Best Technologies Styling */
121
+ .combinations-outer-container, .final-tech-container {
122
+ padding: 15px;
123
+ background-color: #f8f9fa;
124
+ border-radius: 8px;
125
+ border: 1px solid #e9ecef;
126
+ max-height: 500px; /* Adjust as needed */
127
+ overflow-y: auto;
128
+ font-family: 'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif; /* Different font */
129
+ }
130
+
131
+ .problem-card {
132
+ background-color: #ffffff;
133
+ border: 1px solid #cfe2ff; /* Light blue border for problem card */
134
+ border-radius: 10px;
135
+ padding: 20px;
136
+ margin-bottom: 20px;
137
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
138
+ }
139
+ .problem-card-title {
140
+ color: #0056b3; /* Deep blue for problem title */
141
+ font-size: 1.4em;
142
+ margin-top: 0;
143
+ margin-bottom: 15px;
144
+ border-bottom: 2px solid #cfe2ff;
145
+ padding-bottom: 10px;
146
+ }
147
+
148
+ .technologies-inner-container {
149
+ display: grid;
150
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Responsive grid for technologies */
151
+ gap: 15px;
152
+ }
153
+
154
+ .technology-card, .final-tech-card {
155
+ background-color: #f0faff; /* Very light blue for technology cards */
156
+ border: 1px solid #b0d9ff; /* Slightly darker blue border */
157
+ border-radius: 8px;
158
+ padding: 15px;
159
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
160
+ transition: transform 0.2s ease-in-out;
161
+ }
162
+
163
+ .technology-card:hover, .final-tech-card:hover {
164
+ transform: translateY(-3px);
165
+ }
166
+
167
+ .tech-card-title, .final-tech-title {
168
+ color: #007bff; /* Gradio's primary blue */
169
+ font-size: 1.2em;
170
+ margin-top: 0;
171
+ margin-bottom: 10px;
172
+ font-weight: 600;
173
+ }
174
+
175
+ .technology-card p, .final-tech-card p {
176
+ font-size: 0.95em;
177
+ line-height: 1.5;
178
+ margin-bottom: 5px;
179
+ color: #555;
180
+ }
181
+ .technology-card p strong, .final-tech-card p strong {
182
+ color: #004085; /* Darker blue for bold labels */
183
+ }
184
+
185
+ /* --- Prior Art Section Styling --- */
186
+ .prior-art-container {
187
+ background-color: #e6f7ff; /* Very light blue background for distinct section */
188
+ border: 2px solid #99d6ff; /* A clear blue border */
189
+ border-radius: 15px;
190
+ padding: 25px;
191
+ margin-top: 30px;
192
+ box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
193
+ font-family: 'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif; /* Different font */
194
+ color: #2c3e50; /* Darker text for readability */
195
+ line-height: 1.7;
196
+ max-height: 800px; /* Constrain height */
197
+ overflow-y: auto; /* Enable scrolling */
198
+ }
199
+
200
+ .prior-art-container h3, .prior-art-container h4, .prior-art-container h5 {
201
+ color: #003366; /* Even darker blue for headings */
202
+ font-weight: 700;
203
+ margin-top: 20px;
204
+ margin-bottom: 10px;
205
+ }
206
+
207
+ .prior-art-summary p {
208
+ margin-bottom: 10px;
209
+ }
210
+
211
+ .prior-art-summary .summary-bullet {
212
+ margin-left: 20px;
213
+ margin-bottom: 5px;
214
+ }
215
+ .prior-art-summary .summary-bullet strong {
216
+ color: #0056b3;
217
+ }
218
+
219
+
220
+ .prior-art-documents {
221
+ margin-top: 25px;
222
+ display: grid;
223
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
224
+ gap: 20px;
225
+ }
226
+
227
+ .prior-art-document-card {
228
+ background-color: #ffffff;
229
+ border: 1px solid #b3e0ff; /* Lightest blue for document cards */
230
+ border-radius: 10px;
231
+ padding: 20px;
232
+ box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
233
+ transition: transform 0.2s ease-in-out;
234
+ }
235
+
236
+ .prior-art-document-card:hover {
237
+ transform: translateY(-5px);
238
+ }
239
+
240
+ .document-title {
241
+ color: #007bff;
242
+ font-size: 1.3em;
243
+ margin-top: 0;
244
+ margin-bottom: 10px;
245
+ border-bottom: 1px solid #e0f2ff;
246
+ padding-bottom: 8px;
247
+ }
248
+
249
+ .document-description {
250
+ font-size: 0.95em;
251
+ color: #444;
252
+ margin-bottom: 15px;
253
+ }
254
+ .document-description strong {
255
+ color: #004085;
256
+ }
257
+
258
+ .document-technologies h5 {
259
+ color: #0056b3;
260
+ font-size: 1em;
261
+ margin-top: 10px;
262
+ margin-bottom: 8px;
263
+ border-bottom: 1px dashed #cceeff;
264
+ padding-bottom: 5px;
265
+ }
266
+
267
+ .document-technologies ul {
268
+ list-style-type: none; /* Remove default bullet points */
269
+ padding-left: 0;
270
+ margin-top: 0;
271
+ }
272
+ .document-technologies li {
273
+ background-color: #f5fcff; /* Even lighter background for list items */
274
+ border-left: 3px solid #007bff;
275
+ padding: 8px 10px;
276
+ margin-bottom: 5px;
277
+ border-radius: 4px;
278
+ font-size: 0.9em;
279
+ color: #333;
280
+ }
281
+ .document-technologies li strong {
282
+ color: #003366;
283
+ }
284
+
285
+ /* Disruptive line */
286
+ .disruptive-line {
287
+ border: none;
288
+ border-top: 3px dashed #007bff; /* Blue dashed line */
289
+ margin: 40px auto;
290
+ width: 80%;
291
+ opacity: 0.7;
292
+ }
293
+
294
+ /* Prior Art Inline Links (e.g., [1]) */
295
+ .prior-art-inline-link {
296
+ color: #007bff; /* Blue for clickable numbers */
297
+ text-decoration: none;
298
+ font-weight: bold;
299
+ transition: color 0.2s ease-in-out;
300
+ }
301
+ .prior-art-inline-link:hover {
302
+ color: #0056b3;
303
+ text-decoration: underline;
304
+ }
305
+
306
+ /* Grouped URI Links at the end */
307
+ .grouped-uris-section {
308
+ margin-top: 30px;
309
+ padding-top: 20px;
310
+ border-top: 1px solid #cceeff;
311
+ }
312
+ .grouped-uris-section h3 {
313
+ text-align: center;
314
+ color: #0056b3;
315
+ }
316
+ .grouped-uris-section ul {
317
+ list-style-type: decimal; /* Numbered list */
318
+ padding-left: 25px;
319
+ margin-top: 15px;
320
+ }
321
+ .grouped-uris-section li {
322
+ margin-bottom: 8px;
323
+ }
324
+ .prior-art-grouped-link {
325
+ color: #007bff;
326
+ text-decoration: none;
327
+ transition: text-decoration 0.2s ease-in-out;
328
+ }
329
+ .prior-art-grouped-link:hover {
330
+ text-decoration: underline;
331
+ }
332
+
333
+ /* Responsive adjustments */
334
+ @media (max-width: 768px) {
335
+ .gradio-container {
336
+ padding: 15px;
337
+ }
338
+ .gradio-container h1 {
339
+ font-size: 2em;
340
+ }
341
+ .gradio-container button {
342
+ width: 100%;
343
+ padding: 15px;
344
+ }
345
+ .technologies-inner-container, .prior-art-documents {
346
+ grid-template-columns: 1fr; /* Stack columns on smaller screens */
347
+ }
348
+ }
349
+ """
src/services/processor.py CHANGED
@@ -240,8 +240,11 @@ def search_prior_art(technologies_input: list, data: str, data_type: str, techno
240
  prompt = f"Find prior art patents or research paper online that address those constraints: '{data}'. " \
241
 
242
  prompt += f"Using any combination of the following technologies: {', '.join(technology_titles)}. " \
243
- f"Specifically look for patents that integrate multiple of these technologies. " \
244
- f"Indicate for each document found what technologies is used inside of it from the provided list"
 
 
 
245
 
246
  client,config = set_gemini()
247
 
 
240
  prompt = f"Find prior art patents or research paper online that address those constraints: '{data}'. " \
241
 
242
  prompt += f"Using any combination of the following technologies: {', '.join(technology_titles)}. " \
243
+ f"Specifically look for patents that integrate multiple of these technologies." \
244
+ f"Indicate for each document found what technologies is used inside of it from the provided list" \
245
+ f"Indicate for each document the solution, then the twist of this solution," \
246
+ f"What makes it different from all the other existing solutions." \
247
+ f"Output only one sentence for the solution and the twist." \
248
 
249
  client,config = set_gemini()
250