- 新增 IntentShortcut:说「我要请假」这类只有意图的短句时,
编排器在调模型前先做窄匹配(去空白标点 + 剥前后缀后正好等于标准说法、
且原句 ≤12 字),命中即直接下发表单并跳过 LLM,消除「偶尔不准」。
- 请假拆两个工具:leave.submit(type=2 学生申请,待审核)与
leave.register(type=1 教师帮助登记,免审,必填 classId+stuId)。
RolePolicy 分别归入 STUDENT_ONLY / STAFF_ONLY,模型视野里只有一个。
- ToolDef.fixed 由 Map<String,String> 改为 Map<String,Object>:
type/continuousLeave 必须按数字下发,字符串会被模块侧 Jackson 判非法。
- ToolParam/FormField 新增 optionsKeys(valueKey,labelKey) 与 dependsOn:
下拉改为下发 BrowserCall optionCall(含 {{占位符}}),由前端带用户登录态
代取后按 valueKey/labelKey 映射;stuId 依赖 classId,选完班级才解锁。
ToolExecutor#prepareOptionCall 不做必填校验,只拼占位查询串。
- 修 leave.types/myClasses/classStudents 描述,明确「填表时不要先调它」。
- README:4.2 能力划分更新 + 新增「请假为何分两个工具」;5.1 增加
5.1.0 裸意图直达(含身份对照表)与表单 JSON 示例。
- 测试:新增 IntentDirectFormTest(5)、LeaveIntentFormTest(9),
以「被调用即失败」的假 LLM 断言「我要请假」不经过大模型;
RolePermissionTest 补 leave.submit/register 的互斥断言。全量 62/62 通过。
This commit is contained in:
@@ -75,6 +75,26 @@ public class ToolParam {
|
||||
*/
|
||||
private String optionsFrom;
|
||||
|
||||
/**
|
||||
* 选项取自字典返回对象的哪个字段(如 {@code classId} / {@code stuId})。
|
||||
*
|
||||
* <p>★ 为什么必须显式声明:模块字典返回的是业务 VO({@code TeachingClassVo{classId,className}}、
|
||||
* {@code ClassStudentVo{stuId,stuName}}),字段名五花八门,靠「猜常见键名」不可靠。
|
||||
* 显式声明后,前端在浏览器里取到原始数据也能**确定性地**映射成下拉项。
|
||||
*/
|
||||
private String optionValueKey;
|
||||
|
||||
/** 选项显示名取自字典返回对象的哪个字段(如 {@code className} / {@code stuName}) */
|
||||
private String optionLabelKey;
|
||||
|
||||
/**
|
||||
* 本字段的选项依赖哪些其它字段(如「学生」下拉依赖先选好「班级」)。
|
||||
*
|
||||
* <p>作用有两个:① 生成表单时把依赖名带给前端,前端据此清空/重新拉取选项;
|
||||
* ② 生成「浏览器代取选项」的地址时,把依赖字段位置留成占位符({@code ?classId={{classId}}})。
|
||||
*/
|
||||
private List<String> dependsOn;
|
||||
|
||||
public ToolParam() {
|
||||
}
|
||||
|
||||
@@ -149,6 +169,22 @@ public class ToolParam {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典返回对象里,取哪个字段做「值」、哪个字段做「显示名」。
|
||||
* <p>例:{@code optionsKeys("classId","className")} 对应 {@code {classId,className}} 这种业务 VO。
|
||||
*/
|
||||
public ToolParam optionsKeys(String valueKey, String labelKey) {
|
||||
this.optionValueKey = valueKey;
|
||||
this.optionLabelKey = labelKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** 本字段的选项依赖的先序字段(用于联动下拉,如「学生」依赖「班级」) */
|
||||
public ToolParam dependsOn(String... fieldNames) {
|
||||
this.dependsOn = Arrays.asList(fieldNames);
|
||||
return this;
|
||||
}
|
||||
|
||||
/** 表单里显示的名字 */
|
||||
public String labelOf() {
|
||||
return StringUtils.isNotBlank(label) ? label : name;
|
||||
@@ -225,6 +261,9 @@ public class ToolParam {
|
||||
f.setOptions(optionList());
|
||||
// 把「动态选项来源」一并下发:前端据此区分「本来就没有选项」和「字典没取到」
|
||||
f.setOptionsFrom(optionsFrom);
|
||||
f.setDependsOn(dependsOn);
|
||||
f.setValueKey(optionValueKey);
|
||||
f.setLabelKey(optionLabelKey);
|
||||
// 选项是内置兜底(不是学校实时字典)时如实告知,前端可提示用户
|
||||
f.setOptionsFallback(isUsingFallbackOptions());
|
||||
return f;
|
||||
|
||||
Reference in New Issue
Block a user