Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -157,104 +157,105 @@ async def run_function_on_text(top_k,study_obj,study_type,phase,purpose,allocati
|
|
| 157 |
"""
|
| 158 |
)
|
| 159 |
|
| 160 |
-
# LLM.complete
|
| 161 |
-
complete_response = await llm.acomplete(f"""
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
)
|
| 197 |
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
### Instruction:
|
| 201 |
-
Criteria generation:
|
| 202 |
-
As a clinical researcher, generate appropriate eligibility criteria by analyzing given information.
|
| 203 |
-
Ensure the criteria are clear, specific, and reasonable for a clinical research information(### Clinical Trial Information).
|
| 204 |
-
|
| 205 |
-
Prioritize the following topics in clinical trial information.:
|
| 206 |
-
1. Study Objectives
|
| 207 |
-
2. Study Design and Phases
|
| 208 |
-
3. Conditions
|
| 209 |
-
4. Intervention/Treatment
|
| 210 |
-
|
| 211 |
-
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.
|
| 212 |
-
|
| 213 |
-
Reference Papers generation:
|
| 214 |
-
Please give us NCT IDs and study names from the references list in ### Criteria 1.
|
| 215 |
-
|
| 216 |
-
Please follow the pattern of the output(### Pattern of the output).
|
| 217 |
-
--------------------------------------------------
|
| 218 |
-
### Clinical Trial Information
|
| 219 |
-
{study_information}
|
| 220 |
-
--------------------------------------------------
|
| 221 |
-
### Criteria 1
|
| 222 |
-
{query_response}
|
| 223 |
-
--------------------------------------------------
|
| 224 |
-
### Criteria 2
|
| 225 |
-
{complete_response}
|
| 226 |
-
--------------------------------------------------
|
| 227 |
-
### Pattern of the output
|
| 228 |
-
Inclusion Criteria
|
| 229 |
-
1.
|
| 230 |
-
2.
|
| 231 |
-
.
|
| 232 |
-
.
|
| 233 |
-
.
|
| 234 |
-
|
| 235 |
-
Exclusion Criteria
|
| 236 |
-
1.
|
| 237 |
-
2.
|
| 238 |
-
.
|
| 239 |
-
.
|
| 240 |
-
.
|
| 241 |
-
|
| 242 |
-
Reference Papers
|
| 243 |
-
1.NCT ID:
|
| 244 |
-
Study Name:
|
| 245 |
-
Condition:
|
| 246 |
-
Intervention/Treatment:
|
| 247 |
-
2.NCT ID:
|
| 248 |
-
Study Name:
|
| 249 |
-
Condition:
|
| 250 |
-
Intervention/Treatment:
|
| 251 |
-
.
|
| 252 |
-
.
|
| 253 |
-
.
|
| 254 |
-
"""
|
| 255 |
-
)
|
| 256 |
-
|
| 257 |
-
return query_response,complete_response,combine_response
|
| 258 |
|
| 259 |
# Place holder
|
| 260 |
place_holder = f"""Study Objectives
|
|
@@ -406,19 +407,20 @@ with gr.Blocks() as demo:
|
|
| 406 |
label="Response 1",
|
| 407 |
lines=15,
|
| 408 |
interactive=False)
|
| 409 |
-
with gr.Column():
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
with gr.Column():
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
|
| 420 |
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]
|
| 421 |
-
outputs_information = [base_box
|
|
|
|
| 422 |
|
| 423 |
submit_button.click(
|
| 424 |
run_function_on_text,
|
|
@@ -428,26 +430,26 @@ with gr.Blocks() as demo:
|
|
| 428 |
|
| 429 |
clear_button.click(lambda : [None] * len(inputs_information), outputs=inputs_information)
|
| 430 |
|
| 431 |
-
with gr.Row():
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
"Response 3",
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
with gr.Row():
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
#Flagging
|
| 446 |
-
dataset_name = "ravistech/feedback-demo-space"
|
| 447 |
-
hf_writer = gr.HuggingFaceDatasetSaver(hf_token=token_w, dataset_name=dataset_name, private=True)
|
| 448 |
-
hf_writer.setup([selected_response, 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, top_k_box, base_box, rag_box, combine_box],dataset_name)
|
| 449 |
-
|
| 450 |
-
flag_button.click(lambda *args: hf_writer.flag(list(args)), [selected_response, 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, top_k_box, base_box, rag_box, combine_box], None, preprocess=False)
|
| 451 |
|
| 452 |
#Clear all
|
| 453 |
with gr.Row():
|
|
|
|
| 157 |
"""
|
| 158 |
)
|
| 159 |
|
| 160 |
+
# # LLM.complete
|
| 161 |
+
# complete_response = await llm.acomplete(f"""
|
| 162 |
+
# Based on the provided instructions and clinical trial information, generate the new eligibility criteria by analyzing clinical trial information(### Clinical Trial Information).
|
| 163 |
+
# ### Instruction:
|
| 164 |
+
# Criteria generation:
|
| 165 |
+
# As a clinical researcher, generate new eligibility criteria for given clinical trial information.
|
| 166 |
+
# Ensure the criteria are clear, specific, and reasonable for a clinical research information.
|
| 167 |
+
|
| 168 |
+
# Prioritize the following topics in clinical trial information.:
|
| 169 |
+
# 1. Study Objectives
|
| 170 |
+
# 2. Study Design and Phases
|
| 171 |
+
# 3. Conditions
|
| 172 |
+
# 4. Intervention/Treatment
|
| 173 |
+
|
| 174 |
+
# Please follow the pattern of the output(### Pattern of the output).
|
| 175 |
+
# --------------------------------------------------
|
| 176 |
+
# ### Clinical Trial Information
|
| 177 |
+
# {study_information}
|
| 178 |
+
# --------------------------------------------------
|
| 179 |
+
# ### Pattern of the output
|
| 180 |
+
# Inclusion Criteria
|
| 181 |
+
# 1.
|
| 182 |
+
# 2.
|
| 183 |
+
# .
|
| 184 |
+
# .
|
| 185 |
+
# .
|
| 186 |
+
|
| 187 |
+
# Exclusion Criteria
|
| 188 |
+
# 1.
|
| 189 |
+
# 2.
|
| 190 |
+
# .
|
| 191 |
+
# .
|
| 192 |
+
# .
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
# """
|
| 196 |
+
# )
|
| 197 |
+
|
| 198 |
+
# combine_response = await llm.acomplete(f"""
|
| 199 |
+
# 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).
|
| 200 |
+
# ### Instruction:
|
| 201 |
+
# Criteria generation:
|
| 202 |
+
# As a clinical researcher, generate appropriate eligibility criteria by analyzing given information.
|
| 203 |
+
# Ensure the criteria are clear, specific, and reasonable for a clinical research information(### Clinical Trial Information).
|
| 204 |
+
|
| 205 |
+
# Prioritize the following topics in clinical trial information.:
|
| 206 |
+
# 1. Study Objectives
|
| 207 |
+
# 2. Study Design and Phases
|
| 208 |
+
# 3. Conditions
|
| 209 |
+
# 4. Intervention/Treatment
|
| 210 |
+
|
| 211 |
+
# 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.
|
| 212 |
+
|
| 213 |
+
# Reference Papers generation:
|
| 214 |
+
# Please give us NCT IDs and study names from the references list in ### Criteria 1.
|
| 215 |
+
|
| 216 |
+
# Please follow the pattern of the output(### Pattern of the output).
|
| 217 |
+
# --------------------------------------------------
|
| 218 |
+
# ### Clinical Trial Information
|
| 219 |
+
# {study_information}
|
| 220 |
+
# --------------------------------------------------
|
| 221 |
+
# ### Criteria 1
|
| 222 |
+
# {query_response}
|
| 223 |
+
# --------------------------------------------------
|
| 224 |
+
# ### Criteria 2
|
| 225 |
+
# {complete_response}
|
| 226 |
+
# --------------------------------------------------
|
| 227 |
+
# ### Pattern of the output
|
| 228 |
+
# Inclusion Criteria
|
| 229 |
+
# 1.
|
| 230 |
+
# 2.
|
| 231 |
+
# .
|
| 232 |
+
# .
|
| 233 |
+
# .
|
| 234 |
+
|
| 235 |
+
# Exclusion Criteria
|
| 236 |
+
# 1.
|
| 237 |
+
# 2.
|
| 238 |
+
# .
|
| 239 |
+
# .
|
| 240 |
+
# .
|
| 241 |
+
|
| 242 |
+
# Reference Papers
|
| 243 |
+
# 1.NCT ID:
|
| 244 |
+
# Study Name:
|
| 245 |
+
# Condition:
|
| 246 |
+
# Intervention/Treatment:
|
| 247 |
+
# 2.NCT ID:
|
| 248 |
+
# Study Name:
|
| 249 |
+
# Condition:
|
| 250 |
+
# Intervention/Treatment:
|
| 251 |
+
# .
|
| 252 |
+
# .
|
| 253 |
+
# .
|
| 254 |
+
# """
|
| 255 |
)
|
| 256 |
|
| 257 |
+
return query_response
|
| 258 |
+
# return query_response,complete_response,combine_response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
|
| 260 |
# Place holder
|
| 261 |
place_holder = f"""Study Objectives
|
|
|
|
| 407 |
label="Response 1",
|
| 408 |
lines=15,
|
| 409 |
interactive=False)
|
| 410 |
+
# with gr.Column():
|
| 411 |
+
# rag_box = gr.Textbox(
|
| 412 |
+
# label="Response 2",
|
| 413 |
+
# lines=15,
|
| 414 |
+
# interactive=False)
|
| 415 |
+
# with gr.Column():
|
| 416 |
+
# combine_box = gr.Textbox(
|
| 417 |
+
# label="Response 3",
|
| 418 |
+
# lines=15,
|
| 419 |
+
# interactive=False)
|
| 420 |
|
| 421 |
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]
|
| 422 |
+
outputs_information = [base_box]
|
| 423 |
+
# outputs_information = [base_box, rag_box,combine_box]
|
| 424 |
|
| 425 |
submit_button.click(
|
| 426 |
run_function_on_text,
|
|
|
|
| 430 |
|
| 431 |
clear_button.click(lambda : [None] * len(inputs_information), outputs=inputs_information)
|
| 432 |
|
| 433 |
+
# with gr.Row():
|
| 434 |
+
# selected_response = gr.Radio(
|
| 435 |
+
# choices=[
|
| 436 |
+
# "Response 1",
|
| 437 |
+
# "Response 2",
|
| 438 |
+
# "Response 3",
|
| 439 |
+
# "All responses are equally good",
|
| 440 |
+
# "Neither response is satisfactory"
|
| 441 |
+
# ],
|
| 442 |
+
# label="Select the best response"
|
| 443 |
+
# )
|
| 444 |
+
# with gr.Row():
|
| 445 |
+
# flag_button = gr.Button("Flag Selected Response")
|
| 446 |
+
|
| 447 |
+
# #Flagging
|
| 448 |
+
# dataset_name = "ravistech/feedback-demo-space"
|
| 449 |
+
# hf_writer = gr.HuggingFaceDatasetSaver(hf_token=token_w, dataset_name=dataset_name, private=True)
|
| 450 |
+
# hf_writer.setup([selected_response, 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, top_k_box, base_box, rag_box, combine_box],dataset_name)
|
| 451 |
+
|
| 452 |
+
# flag_button.click(lambda *args: hf_writer.flag(list(args)), [selected_response, 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, top_k_box, base_box, rag_box, combine_box], None, preprocess=False)
|
| 453 |
|
| 454 |
#Clear all
|
| 455 |
with gr.Row():
|