根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
``` docs(readme): 更新文档说明 - 添加项目使用指南 - 完善API接口说明 - 修正错误的配置示例 ```
This commit is contained in:
@@ -178,7 +178,7 @@ actor CaptureService {
|
||||
///
|
||||
/// hybrid 双路:
|
||||
/// - **云端可用(Gemini)**:图片直传 Gemini 多模态读图(真·VL,恢复 source_box 证据高亮),
|
||||
/// OCR 文本作数字「抄写员」一并注入。这是端侧 Gemma-3n(MLX 文本版,无视觉)拿不到的能力。
|
||||
/// OCR 文本作数字「抄写员」一并注入。这是端侧 Gemma 4(MLX 文本版,无视觉)拿不到的能力。
|
||||
/// - **离线/未开云端**:回退 Vision OCR(本地,<1s/页)→ 端侧 Gemma 文本 LLM 抽 meta+指标。
|
||||
/// 云端任何失败(离线/超时/解析失败)都静默回退端侧,绝不卡死(§3.2 失败回退红线)。
|
||||
private func runVL(on assets: [FileVault.SavedAsset]) async throws -> ParsedReport {
|
||||
|
||||
@@ -88,17 +88,38 @@ final class ModelDownloadService {
|
||||
if Task.isCancelled { return }
|
||||
let destination = store.fileURL(for: kind, relativePath: file.path)
|
||||
let base = completedBefore
|
||||
try await downloader.download(
|
||||
from: ModelManifest.fileURL(for: kind, file: file),
|
||||
to: destination,
|
||||
expectedBytes: file.bytes,
|
||||
onProgress: { [weak self] received in
|
||||
guard let self else { return }
|
||||
Task { @MainActor in
|
||||
self.applyProgress(kind, currentTotal: base + received)
|
||||
}
|
||||
|
||||
// 魔搭优先 + hf-mirror 回退:按序尝试候选源,任一成功即止;
|
||||
// 换源续传复用同一 .part(两源字节一致,Range 续传穿透)。
|
||||
let sources = ModelManifest.fileURLs(for: kind, file: file)
|
||||
var lastError: Error?
|
||||
var downloaded = false
|
||||
for (idx, source) in sources.enumerated() {
|
||||
if Task.isCancelled { return }
|
||||
do {
|
||||
try await downloader.download(
|
||||
from: source,
|
||||
to: destination,
|
||||
expectedBytes: file.bytes,
|
||||
onProgress: { [weak self] received in
|
||||
guard let self else { return }
|
||||
Task { @MainActor in
|
||||
self.applyProgress(kind, currentTotal: base + received)
|
||||
}
|
||||
}
|
||||
)
|
||||
downloaded = true
|
||||
break
|
||||
} catch {
|
||||
lastError = error
|
||||
#if DEBUG
|
||||
let more = idx + 1 < sources.count ? ",回退下一个源" : ""
|
||||
print("[ModelDownload] \(file.path) 源 \(idx + 1)/\(sources.count) 失败:"
|
||||
+ "\(error.localizedDescription)\(more)")
|
||||
#endif
|
||||
}
|
||||
)
|
||||
}
|
||||
if !downloaded { throw lastError ?? DownloadError.badStatus(0) }
|
||||
completedBefore += file.bytes
|
||||
}
|
||||
finish(kind, success: true, message: nil)
|
||||
|
||||
Reference in New Issue
Block a user