轉換工具強化:失敗診斷訊息 + 舊版格式升版 + 掃描 PDF vision fallback

- convert.py:轉換失敗改印例外型別、批次尾端彙總、--traceback 旗標;
  空白轉換結果示警(避免純圖片 docx 等假成功靜默入庫)
- from_legacy.py(B):.doc/.xls/.ppt 經本地 LibreOffice headless 升版為
  現代格式後再走既有轉換器;raw/originals 仍保存真正的舊格式原始檔
- to_image.py + from_vision.py(A):needs_ocr 的掃描/圖片型 PDF 逐頁
  render → 本地 vision 模型轉錄(--vision);:cloud/未設定防護,
  模型設定走 config/models.yaml 的 tasks.vision(預設不啟用)
- kb.ollama_chat 加 images 參數(向後相容);models.yaml 加 vision 範例
- selfcheck 補 legacy 路由、to_image 真測、from_vision 注入測、
  --vision 端到端,全數 ALL PASS

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
LittleYellow
2026-07-21 07:00:32 +08:00
parent 1d1454e1b9
commit cfd1876359
7 changed files with 428 additions and 37 deletions

View File

@@ -48,11 +48,17 @@ def load_config(root=ROOT):
# ---------- Ollama ----------
def ollama_chat(cfg, model, prompt, temperature, json_format=False):
"""單次呼叫本地 Ollama /api/chatstdlib urllib不需額外依賴"""
def ollama_chat(cfg, model, prompt, temperature, json_format=False, images=None):
"""單次呼叫本地 Ollama /api/chatstdlib urllib不需額外依賴
imagesbase64 影像字串列表(供 vision 模型判讀);附在 user 訊息上。
"""
msg = {"role": "user", "content": prompt}
if images:
msg["images"] = list(images)
body = {
"model": model,
"messages": [{"role": "user", "content": prompt}],
"messages": [msg],
"stream": False,
"options": {"temperature": temperature},
}