Add deterministic slot constraints with labels and questions
Details (original message): Add deterministic slot constraints with labels and questions, and the planner-facing capability catalog.
This commit is contained in:
+33
-1
@@ -33,6 +33,8 @@ func run(args []string) error {
|
||||
err = cmdExplain(args[1:])
|
||||
case "eval":
|
||||
err = cmdEval(args[1:])
|
||||
case "catalog":
|
||||
err = cmdCatalog(args[1:])
|
||||
default:
|
||||
err = usage()
|
||||
}
|
||||
@@ -40,7 +42,7 @@ func run(args []string) error {
|
||||
}
|
||||
|
||||
func usage() error {
|
||||
return fmt.Errorf("用法:intentctl <lint|explain|eval> ...\n lint -root <dir> [-protected a,b] [-guard a,b]\n explain -root <dir> [-protected a,b] [-guard a,b] <input>\n eval -root <dir> [-protected a,b] [-guard a,b] <corpus.json>")
|
||||
return fmt.Errorf("用法:intentctl <lint|explain|eval|catalog> ...\n lint -root <dir> [-protected a,b] [-guard a,b]\n explain -root <dir> [-protected a,b] [-guard a,b] <input>\n eval -root <dir> [-protected a,b] [-guard a,b] <corpus.json>\n catalog -root <dir> [-protected a,b] [-guard a,b] 输出能力目录(注入规划者/领导提示词用)")
|
||||
}
|
||||
|
||||
type commonOpts struct {
|
||||
@@ -149,6 +151,13 @@ func cmdExplain(args []string) error {
|
||||
if len(res.Top.MissingRequiredSlots) > 0 {
|
||||
fmt.Printf(" 缺失必填槽位:%s\n", strings.Join(res.Top.MissingRequiredSlots, ","))
|
||||
}
|
||||
if len(res.Top.InvalidSlots) > 0 {
|
||||
fmt.Printf(" 非法槽位:")
|
||||
for _, k := range sortedKeys(res.Top.InvalidSlots) {
|
||||
fmt.Printf("%s(%s) ", k, res.Top.InvalidSlots[k])
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
if len(res.Candidates) > 0 {
|
||||
fmt.Printf("候选(%d):\n", len(res.Candidates))
|
||||
@@ -180,6 +189,29 @@ func printStage(name string, scored []intent.ScoredSpec, rejected []intent.Rejec
|
||||
}
|
||||
}
|
||||
|
||||
func cmdCatalog(args []string) error {
|
||||
fs := flag.NewFlagSet("catalog", flag.ContinueOnError)
|
||||
c := parseCommon(fs)
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
reg, err := buildRegistry(c)
|
||||
if err != nil {
|
||||
return fmt.Errorf("配置校验失败:%w", err)
|
||||
}
|
||||
fmt.Print(reg.Snapshot().CatalogMarkdown())
|
||||
return nil
|
||||
}
|
||||
|
||||
func sortedKeys(m map[string]string) []string {
|
||||
keys := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
return keys
|
||||
}
|
||||
|
||||
// evalCase 与 intent 包评测集(testdata/corpus.json)同格式。
|
||||
type evalCase struct {
|
||||
Name string `json:"name"`
|
||||
|
||||
Reference in New Issue
Block a user