refactor: 优化解析器日志与API检查逻辑,简化异常处理

This commit is contained in:
begoniezhao
2025-11-20 15:01:14 +08:00
parent 587d1b2bd3
commit 154025f723
2 changed files with 12 additions and 11 deletions
+4 -1
View File
@@ -28,7 +28,6 @@ class StdMinerUParser(BaseParser):
self.image_helper = MarkdownImageUtil()
self.base64_pattern = re.compile(r"data:image/(\w+);base64,(.*)")
self.enable = self.ping()
assert self.ping(), "MinerU API is not reachable"
def ping(self, timeout: int = 5) -> bool:
try:
@@ -41,6 +40,10 @@ class StdMinerUParser(BaseParser):
return False
def parse_into_text(self, content: bytes) -> Document:
if not self.enable:
logger.debug("MinerU API is not enabled")
return Document()
logger.info(f"Parsing scanned PDF via MinerU API (size: {len(content)} bytes)")
md_content: str = ""
images_b64: Dict[str, str] = {}