service-api.md 1.83 KB

ACR Service API

更新:2026-06-02

一页结论

  • 当前服务是工业化骨架,不是最终生产网关
  • 已提供最小可调用能力:
    1. health
    2. config
    3. recognize
    4. index build
  • 下一阶段重点是:鉴权、异步任务、ANN 索引、监控、错误码规范化

1. 服务结构图

flowchart LR
    C[Client] --> H[/health]
    C --> G[/config]
    C --> R[/recognize]
    C --> I[/index/build]

    R --> E[Hybrid Engine]
    I --> B[Index Builders]

2. Endpoint 表

Endpoint 方法 作用
/health GET 健康检查
/config GET 查看默认配置
/recognize POST 输入 query,输出候选
/index/build POST 触发离线索引构建

3. 请求流程图

sequenceDiagram
    participant Client
    participant API
    participant Engine

    Client->>API: POST /recognize
    API->>Engine: load matcher/index/model
    Engine-->>API: top-k candidates
    API-->>Client: JSON result

4. 文字说明

4.1 为什么先暴露文件路径 API

当前阶段优先验证系统闭环,不急于引入上传存储层与异步 job orchestration。

4.2 /config 的作用

帮助服务侧和调用侧快速确认当前默认数据目录、模型路径与索引前缀。

4.3 后续生产化差距

  • 缺鉴权
  • 缺对象存储上传
  • 缺异步索引任务
  • 缺可观测性
  • 缺错误码与 SLA 规范

5. 细节附录

/health

返回:

{"status":"ok","service":"acr","version":"0.2.0"}

/config

返回:

{
  "data_dir":"data/synthetic_v2",
  "model_path":"data/models_v3/best_model.pt",
  "index_prefix":"data/index_v3/reference",
  "device":"cpu"
}

Sources