Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,57 @@ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float
|
|
10 |
model.to(device)
|
11 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
@spaces.GPU
|
14 |
def generate_response(system_instruction, user_input):
|
15 |
# Format the prompt using the messages structure
|
@@ -35,18 +86,25 @@ with gr.Blocks() as demo:
|
|
35 |
# Left sidebar for inputs
|
36 |
with gr.Column():
|
37 |
system_instruction = gr.Textbox(
|
38 |
-
|
|
|
|
|
|
|
39 |
user_input = gr.Textbox(
|
40 |
-
|
|
|
|
|
|
|
41 |
submit_btn = gr.Button("Submit")
|
42 |
|
43 |
# Right column for displaying bot response
|
44 |
with gr.Column():
|
45 |
response_display = gr.Textbox(
|
46 |
-
label="Bot Response", interactive=False, placeholder="Response will appear here."
|
|
|
47 |
|
48 |
# Link submit button to the generate_response function
|
49 |
submit_btn.click(generate_response, [system_instruction, user_input], response_display)
|
50 |
|
51 |
# Launch the app
|
52 |
-
demo.launch(
|
|
|
10 |
model.to(device)
|
11 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
12 |
|
13 |
+
# Default values for system and user input
|
14 |
+
test_instruction_string = """
|
15 |
+
You're a clinical trial expert. For each trial query, list probable baseline features (each in backticks and comma-separated).
|
16 |
+
Baseline features are demographic characteristics used in primary outcome analysis, often shown by group in clinical publications.
|
17 |
+
"""
|
18 |
+
|
19 |
+
test_input_string = """
|
20 |
+
<Title:>Vinorelbine in Treating Patients With Advanced Solid Tumors That Have Not Responded to Treatment and Liver Dysfunction <BriefSummary:>RATIONALE: Drugs used in chemotherapy, such as vinorelbine, work in different ways to stop the growth of tumor cells, either by killing the cells or by stopping them from dividing.
|
21 |
+
|
22 |
+
PURPOSE: This pilot trial is studying the side effects and best dose of vinorelbine in treating patients with advanced solid tumors that have not responded to treatment and liver dysfunction. <EligibilityCriteria:>DISEASE CHARACTERISTICS:
|
23 |
+
|
24 |
+
* Histologically confirmed advanced solid tumor
|
25 |
+
|
26 |
+
* Any histology allowed
|
27 |
+
* Refractory to standard therapy OR no standard therapy exists
|
28 |
+
|
29 |
+
* Previously untreated non-small cell lung cancer allowed, provided abnormal liver function is present, defined as moderate (group 3) or severe (group 4)
|
30 |
+
* Measurable disease not required
|
31 |
+
|
32 |
+
* Present measurable disease requires baseline measurements within 4 weeks of study entry
|
33 |
+
* Patients with acute hepatitis from viral or drug etiologies should recover to a stable baseline prior to study therapy
|
34 |
+
* History of brain metastasis allowed, provided the following criteria are met:
|
35 |
+
|
36 |
+
* Metastasis has been controlled by radiotherapy or surgery
|
37 |
+
* Patient is not currently on corticosteroids
|
38 |
+
* Neurologic status is stable
|
39 |
+
|
40 |
+
PATIENT CHARACTERISTICS:
|
41 |
+
|
42 |
+
* Karnofsky performance status 70-100%
|
43 |
+
* Life expectancy ≥ 2 months
|
44 |
+
* ANC = 1,500/mm³
|
45 |
+
* Platelet count = 100,000/mm³
|
46 |
+
* Hemoglobin = 10 g/dL (transfusion to this level allowed)
|
47 |
+
* Creatinine \< 1.5 mg/dL OR creatinine clearance \> 60 mL/ min
|
48 |
+
* Patients with EKG evidence of first- or second-degree AV block or left or right bundle branch block are ineligible for the lidocaine bolus, but may otherwise be treated on this protocol
|
49 |
+
* Not pregnant or nursing
|
50 |
+
* Negative pregnancy test
|
51 |
+
* Fertile patients must use effective contraception
|
52 |
+
* No concurrent illness (e.g., cardiovascular, pulmonary, or central nervous system) that is poorly controlled or of such severity that the investigator deems unwise to enter the patient on protocol
|
53 |
+
* Must have ability to comply with study treatment and required tests
|
54 |
+
* Obstructive jaundice requires a drainage procedure prior to study treatment
|
55 |
+
|
56 |
+
PRIOR CONCURRENT THERAPY:
|
57 |
+
|
58 |
+
* See Disease Characteristics
|
59 |
+
* Recovered from prior therapy
|
60 |
+
* At least 3 weeks since prior chemotherapy (6 weeks for mitomycin or nitrosourea therapy)
|
61 |
+
* No prior radiotherapy to \> 30% of the bone marrow or more than standard adjuvant pelvic radiotherapy for rectal cancer <Conditions:>Lung Cancer, Unspecified Adult Solid Tumor, Protocol Specific, <Interventions:>indocyanine green, lidocaine, vinorelbine ditartrate, high performance liquid chromatography, intracellular fluorescence polarization analysis, liquid chromatography, mass spectrometry, pharmacological study <StudyType:>INTERVENTIONAL <PrimaryOutcomes:>Area Under the Curve, Number of Participants With Grade 3 and 4 Toxicities <OverallStatus:>COMPLETED
|
62 |
+
"""
|
63 |
+
|
64 |
@spaces.GPU
|
65 |
def generate_response(system_instruction, user_input):
|
66 |
# Format the prompt using the messages structure
|
|
|
86 |
# Left sidebar for inputs
|
87 |
with gr.Column():
|
88 |
system_instruction = gr.Textbox(
|
89 |
+
value=test_instruction_string,
|
90 |
+
placeholder="Enter system instruction here...",
|
91 |
+
label="System Instruction"
|
92 |
+
)
|
93 |
user_input = gr.Textbox(
|
94 |
+
value=test_input_string,
|
95 |
+
placeholder="Type your message here...",
|
96 |
+
label="Your Message"
|
97 |
+
)
|
98 |
submit_btn = gr.Button("Submit")
|
99 |
|
100 |
# Right column for displaying bot response
|
101 |
with gr.Column():
|
102 |
response_display = gr.Textbox(
|
103 |
+
label="Bot Response", interactive=False, placeholder="Response will appear here."
|
104 |
+
)
|
105 |
|
106 |
# Link submit button to the generate_response function
|
107 |
submit_btn.click(generate_response, [system_instruction, user_input], response_display)
|
108 |
|
109 |
# Launch the app
|
110 |
+
demo.launch()
|