Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,8 @@ from pypdf import PdfReader
|
|
| 13 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 14 |
|
| 15 |
from openai import OpenAI
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
# =============================
|
|
@@ -830,6 +832,7 @@ def render_summary_card(record_id: str, records: List[Dict[str, Any]]) -> str:
|
|
| 830 |
key_findings = _safe_str(row.get("key_findings", "")).strip()
|
| 831 |
dose_metrics = _safe_str(row.get("dose_metrics", "")).strip()
|
| 832 |
conclusion = _safe_str(row.get("conclusion", "")).strip()
|
|
|
|
| 833 |
|
| 834 |
# Keep compact
|
| 835 |
def _clip(s: str, n: int = 380) -> str:
|
|
@@ -867,6 +870,10 @@ def render_summary_card(record_id: str, records: List[Dict[str, Any]]) -> str:
|
|
| 867 |
<div style="font-weight:650;margin-bottom:4px;">Conclusion</div>
|
| 868 |
<div style="color:#222;">{_clip(conclusion) if conclusion else "<span style='color:#666'>(not reported)</span>"}</div>
|
| 869 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 870 |
</div>
|
| 871 |
</div>
|
| 872 |
"""
|
|
@@ -1038,7 +1045,7 @@ def run_extraction(
|
|
| 1038 |
|
| 1039 |
for k in field_props.keys():
|
| 1040 |
m = field_key_to_module.get(k, "Custom")
|
| 1041 |
-
include = (
|
| 1042 |
if include:
|
| 1043 |
if k == "chemicals":
|
| 1044 |
row[k] = chem
|
|
@@ -1449,6 +1456,9 @@ with gr.Blocks(title="Toxicology PDF → Grounded Extractor") as demo:
|
|
| 1449 |
]
|
| 1450 |
)
|
| 1451 |
|
|
|
|
|
|
|
|
|
|
| 1452 |
with gr.Tab("Cross-paper Synthesis"):
|
| 1453 |
gr.Markdown("Upload `extraction_details.json` from Extract tab. Synthesis is based strictly on grounded extractions.")
|
| 1454 |
api_key2 = gr.Textbox(label="OpenAI API key (optional if set as OPENAI_API_KEY secret)", type="password")
|
|
|
|
| 13 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 14 |
|
| 15 |
from openai import OpenAI
|
| 16 |
+
from literature_explorer import build_literature_explorer_tab
|
| 17 |
+
|
| 18 |
|
| 19 |
|
| 20 |
# =============================
|
|
|
|
| 832 |
key_findings = _safe_str(row.get("key_findings", "")).strip()
|
| 833 |
dose_metrics = _safe_str(row.get("dose_metrics", "")).strip()
|
| 834 |
conclusion = _safe_str(row.get("conclusion", "")).strip()
|
| 835 |
+
risk_summary = _safe_str(row.get("risk_summary", "")).strip()
|
| 836 |
|
| 837 |
# Keep compact
|
| 838 |
def _clip(s: str, n: int = 380) -> str:
|
|
|
|
| 870 |
<div style="font-weight:650;margin-bottom:4px;">Conclusion</div>
|
| 871 |
<div style="color:#222;">{_clip(conclusion) if conclusion else "<span style='color:#666'>(not reported)</span>"}</div>
|
| 872 |
</div>
|
| 873 |
+
<div>
|
| 874 |
+
<div style="font-weight:650;margin-bottom:4px;">Risk Summary</div>
|
| 875 |
+
<div style="color:#222;">{_clip(risk_summary) if risk_summary else "<span style='color:#666'>(not reported)</span>"}</div>
|
| 876 |
+
</div>
|
| 877 |
</div>
|
| 878 |
</div>
|
| 879 |
"""
|
|
|
|
| 1045 |
|
| 1046 |
for k in field_props.keys():
|
| 1047 |
m = field_key_to_module.get(k, "Custom")
|
| 1048 |
+
include = (m == module) or admin_mode
|
| 1049 |
if include:
|
| 1050 |
if k == "chemicals":
|
| 1051 |
row[k] = chem
|
|
|
|
| 1456 |
]
|
| 1457 |
)
|
| 1458 |
|
| 1459 |
+
with gr.Tab("Literature Explorer"):
|
| 1460 |
+
build_literature_explorer_tab()
|
| 1461 |
+
|
| 1462 |
with gr.Tab("Cross-paper Synthesis"):
|
| 1463 |
gr.Markdown("Upload `extraction_details.json` from Extract tab. Synthesis is based strictly on grounded extractions.")
|
| 1464 |
api_key2 = gr.Textbox(label="OpenAI API key (optional if set as OPENAI_API_KEY secret)", type="password")
|