Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -121,7 +121,6 @@ def process_input_gradio(problem_description: str):
|
|
121 |
)
|
122 |
|
123 |
# --- Gradio Interface Setup ---
|
124 |
-
|
125 |
# Define the input and output components
|
126 |
input_problem = gr.Textbox(
|
127 |
label="Enter Problem Description",
|
@@ -134,20 +133,168 @@ output_best_combinations = gr.JSON(label="7. Best Technology Combinations Found"
|
|
134 |
output_selected_ids = gr.Textbox(label="8. Selected Technology IDs", interactive=False)
|
135 |
output_final_technologies = gr.JSON(label="9. Final Best Technologies")
|
136 |
|
137 |
-
#
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
gr.Markdown("# Insight Finder: Step-by-Step Technology Selection")
|
140 |
-
gr.Markdown("Enter a problem description to see how relevant technologies are identified through various processing steps.")
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
process_button.click(
|
152 |
fn=process_input_gradio,
|
153 |
inputs=input_problem,
|
@@ -159,5 +306,5 @@ with gr.Blocks() as gradio_app_blocks:
|
|
159 |
output_final_technologies
|
160 |
]
|
161 |
)
|
162 |
-
|
163 |
gr.mount_gradio_app(app, gradio_app_blocks, path="/gradio")
|
|
|
121 |
)
|
122 |
|
123 |
# --- Gradio Interface Setup ---
|
|
|
124 |
# Define the input and output components
|
125 |
input_problem = gr.Textbox(
|
126 |
label="Enter Problem Description",
|
|
|
133 |
output_selected_ids = gr.Textbox(label="8. Selected Technology IDs", interactive=False)
|
134 |
output_final_technologies = gr.JSON(label="9. Final Best Technologies")
|
135 |
|
136 |
+
# Custom CSS for a professional look
|
137 |
+
custom_css = """
|
138 |
+
/* General Body and Font Styling */
|
139 |
+
body {
|
140 |
+
font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
|
141 |
+
color: #333;
|
142 |
+
background-color: #f0f2f5;
|
143 |
+
}
|
144 |
+
|
145 |
+
/* Header Styling */
|
146 |
+
.gradio-container h1 {
|
147 |
+
color: #0056b3; /* A deep blue for the main title */
|
148 |
+
text-align: center;
|
149 |
+
margin-bottom: 10px;
|
150 |
+
font-weight: 600;
|
151 |
+
font-size: 2.5em;
|
152 |
+
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
|
153 |
+
}
|
154 |
+
|
155 |
+
.gradio-container h2 {
|
156 |
+
color: #007bff; /* A slightly lighter blue for subtitles */
|
157 |
+
text-align: center;
|
158 |
+
margin-top: 0;
|
159 |
+
margin-bottom: 30px;
|
160 |
+
font-weight: 400;
|
161 |
+
font-size: 1.2em;
|
162 |
+
}
|
163 |
+
|
164 |
+
/* Card-like styling for individual components */
|
165 |
+
.gradio-container .gr-box {
|
166 |
+
background-color: #ffffff;
|
167 |
+
border-radius: 12px;
|
168 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
169 |
+
padding: 20px;
|
170 |
+
margin-bottom: 20px;
|
171 |
+
border: 1px solid #e0e0e0;
|
172 |
+
}
|
173 |
+
|
174 |
+
/* Input Textbox Styling */
|
175 |
+
.gradio-container input[type="text"],
|
176 |
+
.gradio-container textarea {
|
177 |
+
border: 1px solid #ced4da;
|
178 |
+
border-radius: 8px;
|
179 |
+
padding: 12px 15px;
|
180 |
+
font-size: 1em;
|
181 |
+
color: #495057;
|
182 |
+
transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
|
183 |
+
}
|
184 |
+
|
185 |
+
.gradio-container input[type="text"]:focus,
|
186 |
+
.gradio-container textarea:focus {
|
187 |
+
border-color: #007bff;
|
188 |
+
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
189 |
+
outline: none;
|
190 |
+
}
|
191 |
+
|
192 |
+
/* Button Styling */
|
193 |
+
.gradio-container button {
|
194 |
+
background-color: #28a745; /* A vibrant green for action */
|
195 |
+
color: white;
|
196 |
+
border: none;
|
197 |
+
border-radius: 8px;
|
198 |
+
padding: 12px 25px;
|
199 |
+
font-size: 1.1em;
|
200 |
+
font-weight: 500;
|
201 |
+
cursor: pointer;
|
202 |
+
transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
|
203 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
204 |
+
}
|
205 |
+
|
206 |
+
.gradio-container button:hover {
|
207 |
+
background-color: #218838; /* Darker green on hover */
|
208 |
+
transform: translateY(-2px);
|
209 |
+
}
|
210 |
+
|
211 |
+
.gradio-container button:active {
|
212 |
+
transform: translateY(0);
|
213 |
+
}
|
214 |
+
|
215 |
+
/* Labels for outputs */
|
216 |
+
.gradio-container label {
|
217 |
+
font-weight: 600;
|
218 |
+
color: #495057;
|
219 |
+
margin-bottom: 8px;
|
220 |
+
display: block; /* Ensure labels are on their own line */
|
221 |
+
font-size: 1.1em;
|
222 |
+
}
|
223 |
+
|
224 |
+
/* JSON Output Specific Styling */
|
225 |
+
.gradio-container .json-display {
|
226 |
+
background-color: #f8f9fa;
|
227 |
+
border: 1px solid #e9ecef;
|
228 |
+
border-radius: 8px;
|
229 |
+
padding: 15px;
|
230 |
+
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
231 |
+
color: #212529;
|
232 |
+
white-space: pre-wrap; /* Preserve whitespace and wrap long lines */
|
233 |
+
overflow-x: auto; /* Allow horizontal scrolling if content is too wide */
|
234 |
+
max-height: 400px; /* Limit height and add scroll */
|
235 |
+
}
|
236 |
+
|
237 |
+
/* Responsive adjustments (Gradio handles a lot, but for specific tweaks) */
|
238 |
+
@media (max-width: 768px) {
|
239 |
+
.gradio-container {
|
240 |
+
padding: 15px;
|
241 |
+
}
|
242 |
+
.gradio-container h1 {
|
243 |
+
font-size: 2em;
|
244 |
+
}
|
245 |
+
.gradio-container button {
|
246 |
+
width: 100%;
|
247 |
+
padding: 15px;
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
/* Optional: Logo and Branding Placeholder */
|
252 |
+
/* You would typically add an image element in your gr.Blocks() for a logo */
|
253 |
+
/* Example if you have a logo image: */
|
254 |
+
/* .logo {
|
255 |
+
display: block;
|
256 |
+
margin: 0 auto 20px auto;
|
257 |
+
max-width: 200px;
|
258 |
+
height: auto;
|
259 |
+
} */
|
260 |
+
"""
|
261 |
+
|
262 |
+
# Create the Gradio Blocks demo with custom theme and CSS
|
263 |
+
with gr.Blocks(
|
264 |
+
theme=gr.themes.Soft(), # A modern, soft theme from Gradio
|
265 |
+
css=custom_css
|
266 |
+
) as gradio_app_blocks:
|
267 |
+
# Optional: Add your logo here
|
268 |
+
# gr.Image("path/to/your/logo.png", width=150, show_label=False, container=False, elem_classes="logo")
|
269 |
+
|
270 |
gr.Markdown("# Insight Finder: Step-by-Step Technology Selection")
|
271 |
+
gr.Markdown("## Enter a problem description to see how relevant technologies are identified through various processing steps.")
|
272 |
+
|
273 |
+
with gr.Row(): # Use a row for better layout on wider screens
|
274 |
+
with gr.Column(scale=2): # Input takes more space
|
275 |
+
input_problem.render()
|
276 |
+
with gr.Column(scale=1): # Button in a smaller column
|
277 |
+
gr.Box(
|
278 |
+
gr.Markdown("Click to start the analysis:"),
|
279 |
+
process_button := gr.Button("Process Problem", elem_id="process_button")
|
280 |
+
)
|
281 |
|
282 |
+
|
283 |
+
gr.Markdown("---") # Separator for visual clarity
|
284 |
+
|
285 |
+
gr.Markdown("### Processing Steps & Results:")
|
286 |
+
|
287 |
+
# Group outputs into columns for better organization
|
288 |
+
with gr.Row():
|
289 |
+
with gr.Column():
|
290 |
+
output_prompt.render()
|
291 |
+
output_constraints.render()
|
292 |
+
with gr.Column():
|
293 |
+
output_best_combinations.render()
|
294 |
+
output_selected_ids.render()
|
295 |
+
output_final_technologies.render()
|
296 |
+
|
297 |
+
# Link the button to the processing function
|
298 |
process_button.click(
|
299 |
fn=process_input_gradio,
|
300 |
inputs=input_problem,
|
|
|
306 |
output_final_technologies
|
307 |
]
|
308 |
)
|
309 |
+
|
310 |
gr.mount_gradio_app(app, gradio_app_blocks, path="/gradio")
|