Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -159,7 +159,7 @@ async def run_function_on_text(top_k,study_obj,study_type,phase,purpose,allocati
|
|
| 159 |
3. Conditions
|
| 160 |
4. Intervention/Treatment
|
| 161 |
|
| 162 |
-
Please
|
| 163 |
--------------------------------------------------
|
| 164 |
### Clinical Trial Information
|
| 165 |
{study_information}
|
|
@@ -181,13 +181,14 @@ async def run_function_on_text(top_k,study_obj,study_type,phase,purpose,allocati
|
|
| 181 |
|
| 182 |
|
| 183 |
"""
|
|
|
|
| 184 |
|
| 185 |
-
|
| 186 |
-
Based on the provided instructions clinical and criteria information, generate the
|
| 187 |
### Instruction:
|
| 188 |
Criteria generation:
|
| 189 |
-
As a clinical researcher, generate eligibility criteria
|
| 190 |
-
Ensure the criteria are clear, specific, and reasonable for a clinical research information().
|
| 191 |
|
| 192 |
Prioritize the following topics in clinical trial information.:
|
| 193 |
1. Study Objectives
|
|
@@ -195,11 +196,22 @@ async def run_function_on_text(top_k,study_obj,study_type,phase,purpose,allocati
|
|
| 195 |
3. Conditions
|
| 196 |
4. Intervention/Treatment
|
| 197 |
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
--------------------------------------------------
|
| 200 |
### Clinical Trial Information
|
| 201 |
{study_information}
|
| 202 |
--------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
### Pattern of the output
|
| 204 |
Inclusion Criteria
|
| 205 |
1.
|
|
@@ -215,11 +227,22 @@ async def run_function_on_text(top_k,study_obj,study_type,phase,purpose,allocati
|
|
| 215 |
.
|
| 216 |
.
|
| 217 |
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
"""
|
| 220 |
)
|
| 221 |
|
| 222 |
-
return query_response,complete_response
|
| 223 |
|
| 224 |
# Place holder
|
| 225 |
place_holder = f"""Study Objectives
|
|
@@ -280,45 +303,45 @@ interventions_place_holder = f"""Example:
|
|
| 280 |
|
| 281 |
prefilled_value = f"""Study Objectives The purpose of this study is to find out if the combination of docetaxel and capecitabine can shrink the size of breast tumors and preserve the breast. Conditions: Breast Cancer Intervention / Treatment: DRUG: Docetaxel, DRUG: Capecitabine Location: United States Study Design and Phases Study Type: INTERVENTIONAL Phase: PHASE2 Primary Purpose: TREATMENT Allocation: RANDOMIZED Interventional Model: PARALLEL Masking: NONE"""
|
| 282 |
|
| 283 |
-
custom_css = """
|
| 284 |
-
.gradio-container {
|
| 285 |
-
|
| 286 |
-
}
|
| 287 |
-
.main-header {
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
}
|
| 292 |
-
.tab-header {
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
}
|
| 297 |
-
.custom-chatbot {
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
}
|
| 301 |
-
.custom-button {
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
}
|
| 310 |
-
.custom-button:hover {
|
| 311 |
-
|
| 312 |
-
}
|
| 313 |
-
"""
|
| 314 |
-
|
| 315 |
-
# Define Gradio theme
|
| 316 |
-
theme = gr.themes.Default(
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
)
|
| 322 |
|
| 323 |
with gr.Blocks() as demo:
|
| 324 |
|
|
@@ -415,18 +438,24 @@ with gr.Blocks() as demo:
|
|
| 415 |
label="Response 2",
|
| 416 |
lines=5,
|
| 417 |
interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
|
| 419 |
submit_button.click(
|
| 420 |
run_function_on_text,
|
| 421 |
-
inputs=
|
| 422 |
-
outputs=
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
inputs_information = [top_k_box, study_obj_box, study_type_box, phase_box, purpose_box, allocation_box, intervention_model_box, masking_box, conditions_box, intervention_box, location_box, removed_location_box]
|
| 426 |
|
| 427 |
clear_button.click(lambda : [None] * len(inputs_information), outputs=inputs_information)
|
| 428 |
|
| 429 |
-
|
| 430 |
with gr.Row():
|
| 431 |
selected_response = gr.Radio(
|
| 432 |
choices=[
|
|
@@ -449,7 +478,7 @@ with gr.Blocks() as demo:
|
|
| 449 |
with gr.Row():
|
| 450 |
clear_all_button = gr.Button("Clear All")
|
| 451 |
|
| 452 |
-
output_information = inputs_information +
|
| 453 |
clear_all_button.click(lambda : [None] * len(output_information), outputs=output_information)
|
| 454 |
|
| 455 |
if __name__ == "__main__":
|
|
|
|
| 159 |
3. Conditions
|
| 160 |
4. Intervention/Treatment
|
| 161 |
|
| 162 |
+
Please follow the pattern of the output(### Pattern of the output).
|
| 163 |
--------------------------------------------------
|
| 164 |
### Clinical Trial Information
|
| 165 |
{study_information}
|
|
|
|
| 181 |
|
| 182 |
|
| 183 |
"""
|
| 184 |
+
)
|
| 185 |
|
| 186 |
+
combine_response = await llm.acomplete(f"""
|
| 187 |
+
Based on the provided instructions clinical, clinical trial information, and criteria information, generate the appropriate eligibility criteria for ### Clinical Trial Information by analyze clinical trial information(### Clinical Trial Information), criteria 1 (### Criteria 1) and criteria 2 (### Criteria 2).
|
| 188 |
### Instruction:
|
| 189 |
Criteria generation:
|
| 190 |
+
As a clinical researcher, generate appropriate eligibility criteria by analyzing given information.
|
| 191 |
+
Ensure the criteria are clear, specific, and reasonable for a clinical research information(### Clinical Trial Information).
|
| 192 |
|
| 193 |
Prioritize the following topics in clinical trial information.:
|
| 194 |
1. Study Objectives
|
|
|
|
| 196 |
3. Conditions
|
| 197 |
4. Intervention/Treatment
|
| 198 |
|
| 199 |
+
Do not generate redundant inclusion and exclusion criteria. For example, if a criterion is included in one set of inclusion or exclusion criteria, do not include it again.
|
| 200 |
+
|
| 201 |
+
Reference Papers generation:
|
| 202 |
+
Please give us NCT IDs and study names from the references list in ### Criteria 1.
|
| 203 |
+
|
| 204 |
+
Please follow the pattern of the output(### Pattern of the output).
|
| 205 |
--------------------------------------------------
|
| 206 |
### Clinical Trial Information
|
| 207 |
{study_information}
|
| 208 |
--------------------------------------------------
|
| 209 |
+
### Criteria 1
|
| 210 |
+
{query_response}
|
| 211 |
+
--------------------------------------------------
|
| 212 |
+
### Criteria 2
|
| 213 |
+
{complete_response}
|
| 214 |
+
--------------------------------------------------
|
| 215 |
### Pattern of the output
|
| 216 |
Inclusion Criteria
|
| 217 |
1.
|
|
|
|
| 227 |
.
|
| 228 |
.
|
| 229 |
|
| 230 |
+
Reference Papers
|
| 231 |
+
1.NCT ID:
|
| 232 |
+
Study Name:
|
| 233 |
+
Condition:
|
| 234 |
+
Intervention/Treatment:
|
| 235 |
+
2.NCT ID:
|
| 236 |
+
Study Name:
|
| 237 |
+
Condition:
|
| 238 |
+
Intervention/Treatment:
|
| 239 |
+
.
|
| 240 |
+
.
|
| 241 |
+
.
|
| 242 |
"""
|
| 243 |
)
|
| 244 |
|
| 245 |
+
return query_response,complete_response,combine_response
|
| 246 |
|
| 247 |
# Place holder
|
| 248 |
place_holder = f"""Study Objectives
|
|
|
|
| 303 |
|
| 304 |
prefilled_value = f"""Study Objectives The purpose of this study is to find out if the combination of docetaxel and capecitabine can shrink the size of breast tumors and preserve the breast. Conditions: Breast Cancer Intervention / Treatment: DRUG: Docetaxel, DRUG: Capecitabine Location: United States Study Design and Phases Study Type: INTERVENTIONAL Phase: PHASE2 Primary Purpose: TREATMENT Allocation: RANDOMIZED Interventional Model: PARALLEL Masking: NONE"""
|
| 305 |
|
| 306 |
+
# custom_css = """
|
| 307 |
+
# .gradio-container {
|
| 308 |
+
# font-family: 'Roboto', sans-serif;
|
| 309 |
+
# }
|
| 310 |
+
# .main-header {
|
| 311 |
+
# text-align: center;
|
| 312 |
+
# color: #4a4a4a;
|
| 313 |
+
# margin-bottom: 2rem;
|
| 314 |
+
# }
|
| 315 |
+
# .tab-header {
|
| 316 |
+
# font-size: 1.2rem;
|
| 317 |
+
# font-weight: bold;
|
| 318 |
+
# margin-bottom: 1rem;
|
| 319 |
+
# }
|
| 320 |
+
# .custom-chatbot {
|
| 321 |
+
# border-radius: 10px;
|
| 322 |
+
# box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 323 |
+
# }
|
| 324 |
+
# .custom-button {
|
| 325 |
+
# background-color: #3498db;
|
| 326 |
+
# color: white;
|
| 327 |
+
# border: none;
|
| 328 |
+
# padding: 10px 20px;
|
| 329 |
+
# border-radius: 5px;
|
| 330 |
+
# cursor: pointer;
|
| 331 |
+
# transition: background-color 0.3s ease;
|
| 332 |
+
# }
|
| 333 |
+
# .custom-button:hover {
|
| 334 |
+
# background-color: #2980b9;
|
| 335 |
+
# }
|
| 336 |
+
# """
|
| 337 |
+
|
| 338 |
+
# # Define Gradio theme
|
| 339 |
+
# theme = gr.themes.Default(
|
| 340 |
+
# primary_hue="zinc",
|
| 341 |
+
# secondary_hue="red",
|
| 342 |
+
# neutral_hue="neutral",
|
| 343 |
+
# font=[gr.themes.GoogleFont('Roboto'), "sans-serif"]
|
| 344 |
+
# )
|
| 345 |
|
| 346 |
with gr.Blocks() as demo:
|
| 347 |
|
|
|
|
| 438 |
label="Response 2",
|
| 439 |
lines=5,
|
| 440 |
interactive=False)
|
| 441 |
+
with gr.Row():
|
| 442 |
+
with gr.Column():
|
| 443 |
+
combine_box = gr.Textbox(
|
| 444 |
+
label="Response 3",
|
| 445 |
+
lines=5,
|
| 446 |
+
interactive=False)
|
| 447 |
+
|
| 448 |
+
inputs_information = [top_k_box, study_obj_box, study_type_box, phase_box, purpose_box, allocation_box, intervention_model_box, masking_box, conditions_box, intervention_box, location_box, removed_location_box]
|
| 449 |
+
outputs_information = [base_box, rag_box,combine_box]
|
| 450 |
|
| 451 |
submit_button.click(
|
| 452 |
run_function_on_text,
|
| 453 |
+
inputs=inputs_information,
|
| 454 |
+
outputs=outputs_information
|
| 455 |
+
)
|
|
|
|
|
|
|
| 456 |
|
| 457 |
clear_button.click(lambda : [None] * len(inputs_information), outputs=inputs_information)
|
| 458 |
|
|
|
|
| 459 |
with gr.Row():
|
| 460 |
selected_response = gr.Radio(
|
| 461 |
choices=[
|
|
|
|
| 478 |
with gr.Row():
|
| 479 |
clear_all_button = gr.Button("Clear All")
|
| 480 |
|
| 481 |
+
output_information = inputs_information + outputs_information
|
| 482 |
clear_all_button.click(lambda : [None] * len(output_information), outputs=output_information)
|
| 483 |
|
| 484 |
if __name__ == "__main__":
|