Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,14 +86,29 @@ Lab Values:
|
|
| 86 |
# Call LLM
|
| 87 |
result = pipe(
|
| 88 |
prompt,
|
| 89 |
-
max_new_tokens=
|
| 90 |
do_sample=True,
|
| 91 |
temperature=0.3,
|
| 92 |
top_p=0.9,
|
| 93 |
return_full_text=False
|
| 94 |
)
|
| 95 |
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
|
| 99 |
# -----------------------
|
|
@@ -130,14 +145,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 130 |
|
| 131 |
analyze_btn = gr.Button("π¬ Generate Report", variant="primary")
|
| 132 |
|
| 133 |
-
gr.
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
analyze_btn.click(
|
| 137 |
fn=analyze,
|
| 138 |
inputs=[albumin, creatinine, glucose, crp, mcv, rdw, alp,
|
| 139 |
wbc, lymph, age, gender, height, weight],
|
| 140 |
-
outputs=
|
| 141 |
)
|
| 142 |
|
| 143 |
gr.Markdown(
|
|
|
|
| 86 |
# Call LLM
|
| 87 |
result = pipe(
|
| 88 |
prompt,
|
| 89 |
+
max_new_tokens=2000,
|
| 90 |
do_sample=True,
|
| 91 |
temperature=0.3,
|
| 92 |
top_p=0.9,
|
| 93 |
return_full_text=False
|
| 94 |
)
|
| 95 |
|
| 96 |
+
text = result[0]["generated_text"].strip()
|
| 97 |
+
|
| 98 |
+
# Split into left (sections 1β3) and right (sections 5β6)
|
| 99 |
+
left_sections = []
|
| 100 |
+
right_sections = []
|
| 101 |
+
capture_left = True
|
| 102 |
+
|
| 103 |
+
for line in text.splitlines():
|
| 104 |
+
if line.strip().startswith("5. Tabular Mapping"):
|
| 105 |
+
capture_left = False
|
| 106 |
+
if capture_left:
|
| 107 |
+
left_sections.append(line)
|
| 108 |
+
else:
|
| 109 |
+
right_sections.append(line)
|
| 110 |
+
|
| 111 |
+
return "\n".join(left_sections), "\n".join(right_sections)
|
| 112 |
|
| 113 |
|
| 114 |
# -----------------------
|
|
|
|
| 145 |
|
| 146 |
analyze_btn = gr.Button("π¬ Generate Report", variant="primary")
|
| 147 |
|
| 148 |
+
with gr.Row():
|
| 149 |
+
with gr.Column(scale=1):
|
| 150 |
+
gr.Markdown("### π Summary & Action Plan")
|
| 151 |
+
left_output = gr.Markdown()
|
| 152 |
+
with gr.Column(scale=1):
|
| 153 |
+
gr.Markdown("### π Tabular & AI Insights")
|
| 154 |
+
right_output = gr.Markdown()
|
| 155 |
|
| 156 |
analyze_btn.click(
|
| 157 |
fn=analyze,
|
| 158 |
inputs=[albumin, creatinine, glucose, crp, mcv, rdw, alp,
|
| 159 |
wbc, lymph, age, gender, height, weight],
|
| 160 |
+
outputs=[left_output, right_output]
|
| 161 |
)
|
| 162 |
|
| 163 |
gr.Markdown(
|