Files
operating-room-monitor-server/app/terminal_markdown.py
Kevin 0c05463617 feat: 语音确认、联调与运维增强
- 语音:序数解析(第一个/第二个等)、解析失败计数与 API detail.retry_remaining;
  百度 ASR 固定 dev_pid 为普通话;SurgeryPipelineError 支持 extra 并入 HTTP detail。
- Demo:demo 路由与假 RTSP、客户端 index 与 README;BackendResolver 与配置调整。
- 可观测:消耗 TSV 日志、语音文件日志、终端 Markdown 辅助;相关测试与依赖更新。
- 注意:.env 仍被 gitignore,本地密钥不会进入本提交。

Made-with: Cursor
2026-04-23 14:24:20 +08:00

21 lines
731 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""在终端中渲染 Markdown含 GFM 表格),依赖 Rich。非 TTY 时仍尽量输出为可读表格。"""
from __future__ import annotations
from loguru import logger
from rich.console import Console
from rich.markdown import Markdown
def print_markdown_stderr(content: str) -> None:
text = (content or "").rstrip()
if not text:
return
try:
# stderr=True 与 loguru 的默认输出一致,便于在同一终端里对齐其它日志
console = Console(stderr=True, soft_wrap=True)
console.print(Markdown(text))
except Exception as exc: # pragma: no cover
logger.warning("Rich Markdown 渲染失败 ({}), 回退为纯文本", exc)
logger.info("{}", text)