_doc_intel_converter.py · _cu_converter.py(Cloud 整合源碼)兩個 converter 都是「有端點才註冊」(enable_builtins 只在提供
docintel_endpoint/cu_endpoint 時加入,且插到堆疊頂端)。
最複雜的是 Content Understanding 的 analyzer 路由:依檔案型別自動選 analyzer、
處理模態相容性、輸出 YAML front matter。
DocumentIntelligenceFileType 是字串列舉(PDF/JPEG/PNG/DOCX…);
_get_mime_type_prefixes/_get_file_extensions 從列舉產生 accepts 規則。
_analysis_features 依檔型別挑 OCR/table 等 features;convert 呼叫
azure-ai-documentintelligence client 分析並組 Markdown。
ContentUnderstandingFileType 列舉(PDF/JPEG/PNG/MP3/MP4/WAV…)與模態對應;
_clean_mime_type/_canonical_mime_type 正規化 MIME,
_content_type_for 決定送給 CU API 的 content-type。
零設定時要「自動選 analyzer」:_get_modality 把檔案型別歸成 document/image/audio/video;
_resolve_analyzer_modality 用快取或呼叫 get_analyzer() 查 analyzer 的模態;
_is_analyzer_compatible 判斷「文件 analyzer 能否處理音訊」。不相容就自動退回預建 analyzer。
convert 用 analyzer 結果組 Markdown:欄位(vendor、日期…)放在
--- YAML front matter,正文逐頁 <!-- page N -->。
to_llm_input 是 azure-ai-contentunderstanding>=1.2.0b1 提供的 helper,
把結果轉成可直接餵 LLM 的格式(所以 extra 才要求 >=1.2.0b1)。