Upload app.py
Browse files
app.py
CHANGED
|
@@ -125,9 +125,13 @@ def run_explain(rows, lang):
|
|
| 125 |
banner += f'<div class="ll-check"{rtl}>⚠️ {html.escape(t(CHECK_NOTE, lang))}</div>'
|
| 126 |
exp, source = explain(analysis, lang)
|
| 127 |
md = render_markdown(analysis, exp, lang)
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
return banner, _results_table(analysis, lang), md, f"<small>{note} {html.escape(t(DISCLAIMER, lang))}</small>"
|
| 132 |
|
| 133 |
|
|
@@ -202,5 +206,8 @@ with gr.Blocks(title="LabLens") as demo:
|
|
| 202 |
lang.change(lambda l: gr.update(rtl=l in RTL), lang, explanation)
|
| 203 |
|
| 204 |
if __name__ == "__main__":
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
| 206 |
demo.launch(css=CSS, theme=gr.themes.Soft(primary_hue="teal"), ssr_mode=False)
|
|
|
|
| 125 |
banner += f'<div class="ll-check"{rtl}>⚠️ {html.escape(t(CHECK_NOTE, lang))}</div>'
|
| 126 |
exp, source = explain(analysis, lang)
|
| 127 |
md = render_markdown(analysis, exp, lang)
|
| 128 |
+
if source == "llm":
|
| 129 |
+
note = "Explanation written by an open model, grounded in the LabLens knowledge base and checked by guardrails."
|
| 130 |
+
elif source == "template:no-api-key":
|
| 131 |
+
note = "Explanation from the LabLens knowledge base (no AI key configured: add LLM_API_KEY or HF_TOKEN)."
|
| 132 |
+
else:
|
| 133 |
+
note = ("Explanation from the LabLens knowledge base (the AI call failed: "
|
| 134 |
+
f"{html.escape(source.removeprefix('template:'))})")
|
| 135 |
return banner, _results_table(analysis, lang), md, f"<small>{note} {html.escape(t(DISCLAIMER, lang))}</small>"
|
| 136 |
|
| 137 |
|
|
|
|
| 206 |
lang.change(lambda l: gr.update(rtl=l in RTL), lang, explanation)
|
| 207 |
|
| 208 |
if __name__ == "__main__":
|
| 209 |
+
import os
|
| 210 |
+
|
| 211 |
+
print("LLM configured:", llm_available(), "| base:", os.getenv("LLM_BASE_URL", "default (HF router)"),
|
| 212 |
+
"| model:", os.getenv("LLM_MODEL", "default"), flush=True)
|
| 213 |
demo.launch(css=CSS, theme=gr.themes.Soft(primary_hue="teal"), ssr_mode=False)
|