feat: 增强 AI-Core 文档解析器

- 添加 VLM 客户端支持
- 优化解析器配置
- 添加配置示例文件
- 生成新的 gRPC protobuf 文件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 15:42:35 +08:00
parent ab7131eb05
commit 5012a25f99
10 changed files with 1177 additions and 42 deletions

View File

@@ -75,6 +75,21 @@ class DocumentParserServicer:
content_length=0,
)
# 提取 VLM 配置
vlm_config = None
if hasattr(request, 'vlm_config') and request.vlm_config:
vlm_cfg = request.vlm_config
if vlm_cfg.enabled:
vlm_config = {
"enabled": vlm_cfg.enabled,
"provider": vlm_cfg.provider,
"model": vlm_cfg.model,
"api_key": vlm_cfg.api_key,
"base_url": vlm_cfg.base_url,
"prompt": vlm_cfg.prompt,
}
logger.info(f"VLM config: provider={vlm_cfg.provider}, model={vlm_cfg.model}")
logger.info("Downloading file from URL: %s", file_url)
try:
@@ -95,9 +110,9 @@ class DocumentParserServicer:
content_length=0,
)
logger.info("Parsing file with MarkItDown")
logger.info("Parsing file with MarkItDown + VLM")
result = self.parser.parse_bytes(content, file_name)
result = self.parser.parse_bytes(content, file_name, vlm_config=vlm_config)
if not result.get("success", False):
logger.warning("Parser returned failure: %s", result.get("error", "Unknown error"))