API容错处理方案
为确保长期稳定运行,建议采用以下保障措施:
- 多API冗余::
- exist
config/
中配置Google Vision和MathPix的备用密钥 - pass (a bill or inspection etc)
--fallback_api mathpix:3,google:2
设置失败重试次数
- exist
- 本地缓存::
- start using
--cache_dir ./api_cache/
自动存储已识别内容 - increase
--cache_ttl 86400
设置1天缓存有效期
- start using
- 流量控制::
- utilization
--rate_limit 50/分钟
避免触发API限制 - 对万页以上文档添加
--sleep_interval 1.2
秒延迟
- utilization
- stop-and-go (computing)::
- 阶段1处理中断后可用
--resume_from temp/last_processed.page
resumption - pass (a bill or inspection etc)
--checkpoint_interval 20
每20页保存进度
- 阶段1处理中断后可用
紧急方案:当API不可用时,可切换至纯本地模式--local_only
,但公式识别准确率会下降15-20%。
This answer comes from the articleVOP: OCR Tool for Extracting Complex Diagrams and Math FormulasThe