Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,12 +35,10 @@ class OutputPriorArt(BaseModel):
|
|
| 35 |
class InputPriorArtConstraints(BaseModel):
|
| 36 |
technologies: List[Technology]
|
| 37 |
constraints: Dict[str, str]
|
| 38 |
-
data_type: str
|
| 39 |
|
| 40 |
class InputPriorArtProblem(BaseModel):
|
| 41 |
technologies: List[Technology]
|
| 42 |
-
problem:
|
| 43 |
-
data_type: str
|
| 44 |
|
| 45 |
|
| 46 |
# This schema defines the root structure of the JSON
|
|
@@ -59,16 +57,15 @@ async def process_constraints(constraints: InputConstraints):
|
|
| 59 |
return {"technologies": result}
|
| 60 |
|
| 61 |
@app.post("/prior-art-constraints", response_model=OutputPriorArt)
|
| 62 |
-
async def
|
| 63 |
-
prior_art = process_prior_art(data.technologies, data.constraints,
|
| 64 |
return prior_art
|
| 65 |
|
| 66 |
@app.post("/prior-art-problems", response_model=OutputPriorArt)
|
| 67 |
-
async def
|
| 68 |
-
prior_art = process_prior_art(data.technologies, data.
|
| 69 |
return prior_art
|
| 70 |
|
| 71 |
-
|
| 72 |
def make_json_serializable(data):
|
| 73 |
if isinstance(data, dict):
|
| 74 |
return {k: make_json_serializable(v) for k, v in data.items()}
|
|
@@ -81,7 +78,6 @@ def make_json_serializable(data):
|
|
| 81 |
else:
|
| 82 |
return data
|
| 83 |
|
| 84 |
-
# --- Helper functions to format HTML outputs ---
|
| 85 |
def format_constraints_html(constraints: dict) -> str:
|
| 86 |
html_content = "<div class='constraints-container'>"
|
| 87 |
for title, description in constraints.items():
|
|
@@ -105,7 +101,7 @@ def format_best_combinations_html(combinations_data: list) -> str:
|
|
| 105 |
<div class='technologies-inner-container'>
|
| 106 |
"""
|
| 107 |
for tech_info_score in technologies:
|
| 108 |
-
tech_info = tech_info_score[0]
|
| 109 |
if isinstance(tech_info, dict):
|
| 110 |
html_content += f"""
|
| 111 |
<div class='technology-card'>
|
|
@@ -189,6 +185,8 @@ def process_input_gradio(problem_description: str):
|
|
| 189 |
# For Final Technologies:
|
| 190 |
final_technologies_html = format_final_technologies_html(best_technologies)
|
| 191 |
|
|
|
|
|
|
|
| 192 |
|
| 193 |
return (
|
| 194 |
prompt,
|
|
@@ -307,7 +305,7 @@ body {
|
|
| 307 |
background-color: #f8f9fa;
|
| 308 |
border-radius: 8px;
|
| 309 |
border: 1px solid #e9ecef;
|
| 310 |
-
font-family: '
|
| 311 |
line-height: 1.6;
|
| 312 |
max-height: 300px;
|
| 313 |
overflow-y: auto;
|
|
@@ -455,4 +453,6 @@ with gr.Blocks(
|
|
| 455 |
]
|
| 456 |
)
|
| 457 |
|
| 458 |
-
gr.mount_gradio_app(app, gradio_app_blocks, path="/gradio")
|
|
|
|
|
|
|
|
|
| 35 |
class InputPriorArtConstraints(BaseModel):
|
| 36 |
technologies: List[Technology]
|
| 37 |
constraints: Dict[str, str]
|
|
|
|
| 38 |
|
| 39 |
class InputPriorArtProblem(BaseModel):
|
| 40 |
technologies: List[Technology]
|
| 41 |
+
problem: str
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
# This schema defines the root structure of the JSON
|
|
|
|
| 57 |
return {"technologies": result}
|
| 58 |
|
| 59 |
@app.post("/prior-art-constraints", response_model=OutputPriorArt)
|
| 60 |
+
async def prior_art_constraints(data: InputPriorArtConstraints):
|
| 61 |
+
prior_art = process_prior_art(data.technologies, data.constraints, "constraints")
|
| 62 |
return prior_art
|
| 63 |
|
| 64 |
@app.post("/prior-art-problems", response_model=OutputPriorArt)
|
| 65 |
+
async def prior_art_problems(data: InputPriorArtProblem):
|
| 66 |
+
prior_art = process_prior_art(data.technologies, data.problems, "problem")
|
| 67 |
return prior_art
|
| 68 |
|
|
|
|
| 69 |
def make_json_serializable(data):
|
| 70 |
if isinstance(data, dict):
|
| 71 |
return {k: make_json_serializable(v) for k, v in data.items()}
|
|
|
|
| 78 |
else:
|
| 79 |
return data
|
| 80 |
|
|
|
|
| 81 |
def format_constraints_html(constraints: dict) -> str:
|
| 82 |
html_content = "<div class='constraints-container'>"
|
| 83 |
for title, description in constraints.items():
|
|
|
|
| 101 |
<div class='technologies-inner-container'>
|
| 102 |
"""
|
| 103 |
for tech_info_score in technologies:
|
| 104 |
+
tech_info = tech_info_score[0]
|
| 105 |
if isinstance(tech_info, dict):
|
| 106 |
html_content += f"""
|
| 107 |
<div class='technology-card'>
|
|
|
|
| 185 |
# For Final Technologies:
|
| 186 |
final_technologies_html = format_final_technologies_html(best_technologies)
|
| 187 |
|
| 188 |
+
prior_art = process_prior_art(best_technologies, constraints, "constraints")
|
| 189 |
+
print(prior_art)
|
| 190 |
|
| 191 |
return (
|
| 192 |
prompt,
|
|
|
|
| 305 |
background-color: #f8f9fa;
|
| 306 |
border-radius: 8px;
|
| 307 |
border: 1px solid #e9ecef;
|
| 308 |
+
font-family: 'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif; /* Different font */
|
| 309 |
line-height: 1.6;
|
| 310 |
max-height: 300px;
|
| 311 |
overflow-y: auto;
|
|
|
|
| 453 |
]
|
| 454 |
)
|
| 455 |
|
| 456 |
+
gr.mount_gradio_app(app, gradio_app_blocks, path="/gradio")
|
| 457 |
+
#if __name__ == "__main__":
|
| 458 |
+
# gradio_app_blocks.launch()
|