afm-de)与 Decoder(afm-dd)。
安装
从下载页下载你所在平台的最新发布版。配置与下载
aria-engine setup # 写入 ~/.ariacompute/engine.yml
aria-engine download afm-de # 按 site_url:.com → HF;.cn → ModelScope
aria-engine download afm-dd
aria-engine list # 本地 ∪ Hub 组织(ariacompute / AriaCompute)
~/.ariacompute/models/<model-name>(例如 afm-de、afm-dd)。
System One:serve
用已下载的 AFM checkpoint 启动本地 System One HTTP 服务。| 参数 | 默认 | 含义 |
|---|---|---|
--track | encoder | encoder | decoder |
--model-name | afm-de / afm-dd(随 --track) | 响应中的 model id;省略 --checkpoint 时兼作 checkpoint |
--checkpoint | ~/.ariacompute/models/<model-name> | checkpoint 目录或缓存名 |
--bind | 127.0.0.1:8010(encoder)/ 127.0.0.1:8011(decoder) | 监听地址 |
--compute | 来自 engine.yml(auto) | auto | cpu | cuda |
| 方法 | 路径 | 响应 |
|---|---|---|
GET | /health 或 / | { "ok": true, "service": "afm-engine", "model": "<model-name>" } |
GET | /v1/models | OpenAI 风格列表,含一条 --model-name |
POST | /v1/systemone | { "answers": { … }, "model": "<model-name>" } |
aria-engine setup
aria-engine download afm-de
aria-engine serve --model-name afm-de
# → http://127.0.0.1:8010
# Decoder
aria-engine download afm-dd
aria-engine serve --track decoder --model-name afm-dd
# → http://127.0.0.1:8011
curl -s http://127.0.0.1:8010/health
curl -s http://127.0.0.1:8010/v1/systemone \
-H 'content-type: application/json' \
-d '{
"state": "user wants a refund",
"questions": {
"q1": {
"type": "choice",
"instructions": "Pick the best action",
"criteria": {
"refund": "issue a full refund",
"deny": "deny the request"
}
}
}
}'
type 取 choice、score 或 noul。题目不合法返回 422,打分失败返回 500。
System One:decide
对一份 JSON(stdin 或--file)做一次类型化决策。请求的打包方式和 typed-answer 契约与 POST /v1/systemone 一致。
# 真实前向(需已下载完整 checkpoint)
aria-engine decide --track encoder --model-name afm-de --file record.json
# 或通过管道传入 System One 请求体
cat <<'EOF' | aria-engine decide --track encoder --model-name afm-de
{
"state": "user wants a refund",
"questions": {
"q1": {
"type": "choice",
"instructions": "Pick the best action",
"criteria": {"refund": "issue a full refund", "deny": "deny the request"}
}
}
}
EOF
通过 libaria-engine_ffi 嵌入
每个发布版都随 CLI 附带libaria-engine_ffi,各语言 SDK 也随发布版提供:Python aria-engine、npm @ariacompute/engine-ts / @ariacompute/engine-rn、Rust ariacompute-engine、Flutter aria_engine、Swift AriaEngine、Kotlin com.ariacompute.engine、Go github.com/ariacompute/engine/bindings/go。
# pip install aria-engine
from aria_engine import AriaEngine
eng = AriaEngine("~/.ariacompute/models/afm-de", "encoder")
out = eng.systemone({
"state": "user wants a refund",
"questions": {
"q1": {
"type": "choice",
"instructions": "Pick the best action",
"criteria": {
"refund": "issue a full refund",
"deny": "deny the request",
},
}
},
})
print(out["answers"]["q1"])
eng.destroy()
// npm install @ariacompute/engine-ts
import { AriaEngine } from "@ariacompute/engine-ts";
const eng = new AriaEngine("~/.ariacompute/models/afm-de", "encoder");
const out = eng.systemone({
state: "user wants a refund",
questions: {
q1: {
type: "choice",
instructions: "Pick the best action",
criteria: {
refund: "issue a full refund",
deny: "deny the request",
},
},
},
}) as { answers: Record<string, unknown> };
console.log(out.answers.q1);
eng.destroy();
// npm install @ariacompute/engine-rn
import { AriaEngine } from '@ariacompute/engine-rn';
const eng = new AriaEngine("~/.ariacompute/models/afm-de", "encoder");
const out = await eng.systemone({
state: "user wants a refund",
questions: {
q1: {
type: "choice",
instructions: "Pick the best action",
criteria: {
refund: "issue a full refund",
deny: "deny the request",
},
},
},
});
console.log(out.answers.q1);
eng.destroy();
// go get github.com/ariacompute/engine/bindings/go@latest
package main
import (
"fmt"
aria "github.com/ariacompute/engine/bindings/go"
)
func main() {
eng, err := aria.Open("~/.ariacompute/models/afm-de", "encoder")
if err != nil {
panic(err)
}
defer eng.Destroy()
out, err := eng.SystemOne(map[string]any{
"state": "user wants a refund",
"questions": map[string]any{
"q1": map[string]any{
"type": "choice",
"instructions": "Pick the best action",
"criteria": map[string]any{
"refund": "issue a full refund",
"deny": "deny the request",
},
},
},
})
if err != nil {
panic(err)
}
fmt.Println(out["answers"])
}
// cargo add ariacompute-engine
use aria_engine::{Engine, EngineTrack, SystemOneRequest};
use serde_json::json;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let eng = Engine::open("~/.ariacompute/models/afm-de", EngineTrack::Encoder)?;
let req: SystemOneRequest = serde_json::from_value(json!({
"state": "user wants a refund",
"questions": {
"q1": {
"type": "choice",
"instructions": "Pick the best action",
"criteria": {
"refund": "issue a full refund",
"deny": "deny the request"
}
}
}
}))?;
let out = eng.systemone(&req)?;
println!("{out}");
Ok(())
}
// pubspec.yaml: aria_engine: ^0.1.0
import 'package:aria_engine/aria_engine.dart';
final eng = AriaEngine('~/.ariacompute/models/afm-de', track: 'encoder');
final out = eng.systemone({
'state': 'user wants a refund',
'questions': {
'q1': {
'type': 'choice',
'instructions': 'Pick the best action',
'criteria': {
'refund': 'issue a full refund',
'deny': 'deny the request',
},
},
},
});
print(out['answers']);
eng.destroy();
// pod 'AriaEngine'
import AriaEngine
let eng = AriaEngine(checkpoint: "~/.ariacompute/models/afm-de", track: "encoder")
let req = """
{
"state": "user wants a refund",
"questions": {
"q1": {
"type": "choice",
"instructions": "Pick the best action",
"criteria": {
"refund": "issue a full refund",
"deny": "deny the request"
}
}
}
}
"""
let out = try eng.systemone(requestJson: req)
print(out)
eng.destroy()
// build.gradle: implementation("com.ariacompute:engine:0.1.0")
import com.ariacompute.engine.AriaEngine
import org.json.JSONObject
val eng = AriaEngine("~/.ariacompute/models/afm-de", "encoder")
val out = eng.systemone(
JSONObject(
"""
{
"state": "user wants a refund",
"questions": {
"q1": {
"type": "choice",
"instructions": "Pick the best action",
"criteria": {
"refund": "issue a full refund",
"deny": "deny the request"
}
}
}
}
""".trimIndent()
)
)
println(out.getJSONObject("answers"))
eng.destroy()
aria-engine download afm-de 后,把 checkpoint 指向已下载的 AFM 目录;Decoder 传 decoder 和 ~/.ariacompute/models/afm-dd。共享库不在默认搜索路径时,用 ARIA_FFI_LIB 指定路径。
相关
- AFM-D:Encoder / Decoder、Hub、原语
- Ollaya:另一个本地 System One 守护进程
- ROUTER 运行时:通过
AFM_ENGINE_URL使用ariacompute/afm-d-auto