新用户名 commited on
Commit
4a3a6d8
·
1 Parent(s): b1b2cec

sidebar rm

Browse files
Files changed (2) hide show
  1. __pycache__/api_client.cpython-310.pyc +0 -0
  2. app.py +3 -51
__pycache__/api_client.cpython-310.pyc CHANGED
Binary files a/__pycache__/api_client.cpython-310.pyc and b/__pycache__/api_client.cpython-310.pyc differ
 
app.py CHANGED
@@ -26,7 +26,6 @@ import gradio as gr
26
  from api_client import (
27
  DEFAULT_BASE,
28
  SMARTDOC_URL,
29
- health_ok,
30
  parse_document,
31
  resolve_api_key,
32
  stream_translate,
@@ -280,40 +279,6 @@ def _resolve_base(api_base: str) -> str:
280
  return (api_base or DEFAULT_BASE).strip().rstrip("/")
281
 
282
 
283
- def _has_health_endpoint(base: str) -> bool:
284
- """Only the internal gateway exposes /health; the public connect gateway does not.
285
-
286
- The public OpenAPI gateway (connect.zhihuiya.com) only routes the purchased
287
- endpoints (e.g. /translate); probing /health there returns a permission/quota
288
- error, not a real health signal.
289
- """
290
- return "/compute/hiro_translation_api" in base
291
-
292
-
293
- def check_service() -> str:
294
- base = _resolve_base(DEFAULT_BASE)
295
- key = resolve_api_key()
296
- key_hint = "HIRO_API_KEY / RD_LLM_API_KEY" if not key else "API key loaded from env"
297
-
298
- if not _has_health_endpoint(base):
299
- return (
300
- f'<span class="status-pill ok">● Public gateway<br>'
301
- f'<span style="opacity:0.85">{html.escape(base)} · {html.escape(key_hint)}</span>'
302
- f"</span>"
303
- )
304
-
305
- ok, msg = health_ok(base, api_key=key or None)
306
- if ok:
307
- return (
308
- f'<span class="status-pill ok">● Online<br>'
309
- f'<span style="opacity:0.85">{html.escape(base)} · {html.escape(key_hint)}</span></span>'
310
- )
311
- return (
312
- f'<span class="status-pill err">● Unavailable<br>'
313
- f'<span style="opacity:0.85">{html.escape(msg)}</span></span>'
314
- )
315
-
316
-
317
  def _parse_progress(progress: str | None) -> tuple[int, int]:
318
  if not progress or "/" not in progress:
319
  return 0, 0
@@ -751,18 +716,11 @@ def build_theme() -> gr.Theme:
751
 
752
  def build_ui() -> gr.Blocks:
753
  with gr.Blocks(
754
- title="Document Processing",
755
  css=CUSTOM_CSS,
756
  theme=build_theme(),
757
  ) as demo:
758
- with gr.Sidebar():
759
- gr.HTML('<p class="main-title">Document Processing</p>')
760
- gr.Markdown(
761
- "Smart Doc + Translation · shared Bearer key from "
762
- "`HIRO_API_KEY` (fallback `RD_LLM_API_KEY`)"
763
- )
764
- gateway_status = gr.HTML(value=check_service())
765
- refresh_btn = gr.Button("Refresh status", size="sm", variant="secondary")
766
 
767
  with gr.Tabs():
768
  with gr.Tab("Smart Doc"):
@@ -884,8 +842,6 @@ def build_ui() -> gr.Blocks:
884
  elem_id="hiro-stream-state",
885
  )
886
 
887
- refresh_btn.click(check_service, outputs=[gateway_status])
888
-
889
  def _combine_lang(src: str, tgt: str) -> str:
890
  return f"{src}2{tgt}"
891
 
@@ -961,11 +917,7 @@ def build_ui() -> gr.Blocks:
961
  outputs=[doc_file, smartdoc_status, smartdoc_md, smartdoc_json],
962
  )
963
 
964
- demo.load(
965
- check_service,
966
- outputs=[gateway_status],
967
- js=INIT_STREAM_WATCH_JS,
968
- )
969
 
970
  return demo
971
 
 
26
  from api_client import (
27
  DEFAULT_BASE,
28
  SMARTDOC_URL,
 
29
  parse_document,
30
  resolve_api_key,
31
  stream_translate,
 
279
  return (api_base or DEFAULT_BASE).strip().rstrip("/")
280
 
281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  def _parse_progress(progress: str | None) -> tuple[int, int]:
283
  if not progress or "/" not in progress:
284
  return 0, 0
 
716
 
717
  def build_ui() -> gr.Blocks:
718
  with gr.Blocks(
719
+ title="Document Processing Demo",
720
  css=CUSTOM_CSS,
721
  theme=build_theme(),
722
  ) as demo:
723
+ gr.HTML('<p class="main-title">Document Processing Demo</p>')
 
 
 
 
 
 
 
724
 
725
  with gr.Tabs():
726
  with gr.Tab("Smart Doc"):
 
842
  elem_id="hiro-stream-state",
843
  )
844
 
 
 
845
  def _combine_lang(src: str, tgt: str) -> str:
846
  return f"{src}2{tgt}"
847
 
 
917
  outputs=[doc_file, smartdoc_status, smartdoc_md, smartdoc_json],
918
  )
919
 
920
+ demo.load(fn=None, js=INIT_STREAM_WATCH_JS)
 
 
 
 
921
 
922
  return demo
923