Skip to content

Latest commit

 

History

History
122 lines (96 loc) · 1.7 KB

File metadata and controls

122 lines (96 loc) · 1.7 KB

本地服务 API

默认地址:

http://127.0.0.1:8765

健康检查

GET /api/health

响应:

{
  "status": "ok",
  "version": "0.1.0",
  "platform": "darwin-arm64"
}

模型状态

GET /api/model/status

响应字段:

  • loaded:模型或 mock 引擎是否可用。
  • model_name:模型名称。
  • model_repo:模型仓库。
  • model_file:模型文件名。
  • model_path:模型本地路径。
  • runtime:运行时类型。
  • runtime_feature:运行时必需特性。
  • status:当前状态。
  • license_accepted:许可证是否已确认。
  • detail:状态摘要。

确认许可证

POST /api/license/accept
Content-Type: application/json

请求:

{
  "model": "HY-MT1.5-1.8B",
  "license": "Tencent HY Community License Agreement",
  "accepted": true,
  "accepted_at": "2026-05-15T00:00:00Z"
}

批量翻译

POST /api/translate
Content-Type: application/json

请求:

{
  "source_lang": "auto",
  "target_lang": "zh",
  "texts": ["Hello world"],
  "mode": "plain"
}

响应:

{
  "translations": ["你好,世界"],
  "model": "Hy-MT1.5-1.8B-1.25bit-GGUF",
  "cached": false
}

格式保留翻译

POST /api/translate/formatted
Content-Type: application/json

请求:

{
  "source_lang": "auto",
  "target_lang": "zh",
  "segments": [
    {
      "id": "node-1",
      "text": "<source>Hello <sn>world</sn>.</source>"
    }
  ]
}

错误结构

{
  "error": {
    "code": "MODEL_NOT_LOADED",
    "message": "模型未加载,请检查模型路径或重新加载模型。",
    "detail": "model path does not exist"
  }
}