請求參數 Content-Type · String · Header · 必選 請求類型:application/json。 Authorization · String · Header · 必選 API-Key,格式:Bearer $DASHSCOPE_API_KEY。 model · String · Body · 必選 模型名,取值 decision-model-preview。 state · String / Object / Array · Body · 必選 待決策的業務狀態:工單文本、對話或結構化對象(對象會被序列化後送模型)。 questions · Object · Body · 必選 問題表。key 為呼叫方自定義的問題 id;value 為問題對象,字段如下。 問題對象屬性 type · String · 必選 問題類型,取值:
choice:多選一
noul:是否判斷
score:有序量表
instructions · String · 可選 問題描述或評判標準。 criteria · Object / Array · 視類型
choice:選項名 → 選項描述 的映射(1–255 項,建議給全量選項並補 other 兜底)。
noul:可選 {"true":…, "false":…} 描述。
score:從低到高的等級描述數組(2–10 級,建議 3–7 級且每級可清晰區分)。
介面限制與建議
- 問題數介面不設上限(建議 ≤ 16,延遲隨問題數近線性增長)。
choice 選項 ≤ 255。
score 等級 2–255(建議 3–7 級)。
- 上下文上限 65536 token,超長
state 會被拒絕或截斷。
| 請求示例 Python 示例使用 TypeSafe SDK(typesafe-sdk)呼叫,base_url 指向百鍊閘道,SDK 會自動拼接 /v1/systemone 並解析返回體。安裝:pip install typesafe-sdk。 工單分流示例一次請求同時完成「派單團隊 choice」「是否升級 noul」「嚴重度 score」三項決策。以下以新加坡地域為例。 curl -sS -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/systemone \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "decision-model-preview",
"state": {"ticket_id": "T-1001", "content": "订单支付后超过 24 小时仍未到账,用户无法继续使用核心服务,要求立即处理。"},
"questions": {
"department": {"type": "choice", "instructions": "应该由哪个团队处理?",
"criteria": {"billing": "支付、退款和账单问题", "technical": "产品故障和集成问题"}},
"escalate": {"type": "noul", "instructions": "是否需要立即通知值班人员?"},
"severity": {"type": "score", "instructions": "这个问题有多严重?",
"criteria": ["轻微问题,不影响功能", "部分功能受影响,但存在替代方案",
"核心功能不可用,没有替代方案", "造成严重业务或安全影响"]}
}
}'
import os
from typesafe_sdk import TypeSafeClient
client = TypeSafeClient(
api_key=os.environ["DASHSCOPE_API_KEY"],
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode",
)
result = client.system_one(
model="decision-model-preview",
state={"ticket_id": "T-1001", "content": "订单支付后超过 24 小时仍未到账,用户无法继续使用核心服务。"},
questions={
"department": {"type": "choice", "instructions": "应该由哪个团队处理?",
"criteria": {"billing": "支付、退款和账单问题", "technical": "产品故障和集成问题"}},
"escalate": {"type": "noul", "instructions": "是否需要立即通知值班人员?"},
"severity": {"type": "score", "instructions": "这个问题有多严重?",
"criteria": ["轻微问题,不影响功能", "部分功能受影响,但存在替代方案",
"核心功能不可用,没有替代方案", "造成严重业务或安全影响"]},
},
)
print(result.answers["department"]) # choice, confidence, probabilities
print(result.answers["escalate"]) # noul P(yes)
print(result.answers["severity"]) # score, legend, probabilities
是非判斷示例對一個 noul 問題返回 P(yes) 概率,0=否 1=是。以下以新加坡地域為例。 |