伪代码:抽取 → 校验 → 追问 → 填充
SCHEMA = {
"申请人姓名": {"type": "str", "required": True},
"被申请人公司": {"type": "str", "required": True},
"入职日期": {"type": "date", "required": True},
"离职日期": {"type": "date", "required": False},
"欠薪金额": {"type": "money", "required": True},
"欠薪区间": {"type": "date_range", "required": True},
"事实与理由": {"type": "text", "required": True},
}
1. 模型只做抽取,输出 JSON,不做任何"补全想象"
extracted = llm_gateway.chat(
model="light", # 简单字段用轻量档
prompt=EXTRACT_PROMPT.render(schema=SCHEMA, user_input=desc),
response_format="json",
)
陈述类字段单独用强模型生成
extracted["事实与理由"] = llm_gateway.chat(
model="strong",
prompt=NARRATIVE_PROMPT.render(facts=extracted),
)
2. 确定性校验:规则代码兜底,模型不碰
missing = validate(extracted, SCHEMA) # 必填缺失、日期逻辑、金额格式
if missing:
return followup_questions(missing) # 缺什么问什么,不猜
3. 代码填充模板,原文条款一个字符不动
return render_template("劳动仲裁申请书.docx", extracted)
After launching the rebuilt version, mid-process drop-off dropped significantly. The most direct reason: users no longer experienced the "surprise of wrongly filled fields"—instead they got "follow-up questions about what's missing." The experience went from unpredictable to expected.
## Final Thoughts
The biggest lesson this project taught me: in AI applications, the model's boundary should be drawn smaller than you think. Let the model only do understanding and narrative generation, leave validation and assembly to code, and hand multi-model management over to a gateway—only then can a small team truly move fast and sleep well.
If you're also building a similar multi-model AI application and don't want to reinvent the wheel on key management, model routing, and failure fallback, try a unified AI API gateway: https://api.thistoken.ai/register
---
Tired of juggling provider integrations? Register at https://api.thistoken.ai/register and call every model through one base_url.Bạn muốn thử Token.AI?
Tạo API Key cấp dự án, bật kênh trong bảng điều khiển và định cấu hình định tuyến, ngân sách và nhật ký kiểm tra.
注册 ThisToken.AI 并获取 API Key