@ax-llm/ax 11.0.63 → 11.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +17 -7
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/index.js +17 -7
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -6506,7 +6506,17 @@ var renderOutputFields = (fields) => {
|
|
|
6506
6506
|
const name = field.title;
|
|
6507
6507
|
const type = field.type?.name ? toFieldType(field.type) : "string";
|
|
6508
6508
|
const requiredMsg = field.isOptional ? `Only include this ${type} field if its value is available` : `This ${type} field must be included`;
|
|
6509
|
-
|
|
6509
|
+
let description = "";
|
|
6510
|
+
if (field.description && field.description.length > 0) {
|
|
6511
|
+
const value = field.type?.name === "class" ? field.description : formatDescription(field.description);
|
|
6512
|
+
description = ` ${value}`;
|
|
6513
|
+
}
|
|
6514
|
+
if (field.type?.options && field.type.options.length > 0) {
|
|
6515
|
+
if (description.length > 0) {
|
|
6516
|
+
description += `. `;
|
|
6517
|
+
}
|
|
6518
|
+
description += `Allowed values: ${field.type.options.join(", ")}`;
|
|
6519
|
+
}
|
|
6510
6520
|
return `${name}: (${requiredMsg})${description}`.trim();
|
|
6511
6521
|
});
|
|
6512
6522
|
return rows.join("\n");
|
|
@@ -6546,7 +6556,7 @@ var toFieldType = (type) => {
|
|
|
6546
6556
|
case "json":
|
|
6547
6557
|
return "JSON object";
|
|
6548
6558
|
case "class":
|
|
6549
|
-
return
|
|
6559
|
+
return "classification class";
|
|
6550
6560
|
case "code":
|
|
6551
6561
|
return "code";
|
|
6552
6562
|
default:
|
|
@@ -6833,12 +6843,12 @@ var convertValueToType = (field, val, required = false) => {
|
|
|
6833
6843
|
return parseLLMFriendlyDateTime(field, val, required);
|
|
6834
6844
|
case "class":
|
|
6835
6845
|
const className = val;
|
|
6836
|
-
if (field.type.
|
|
6846
|
+
if (field.type.options && !field.type.options.includes(className)) {
|
|
6837
6847
|
if (field.isOptional) {
|
|
6838
6848
|
return;
|
|
6839
6849
|
}
|
|
6840
6850
|
throw new Error(
|
|
6841
|
-
`Invalid class '${val}', expected one of the following: ${field.type.
|
|
6851
|
+
`Invalid class '${val}', expected one of the following: ${field.type.options.join(", ")}`
|
|
6842
6852
|
);
|
|
6843
6853
|
}
|
|
6844
6854
|
return className;
|
|
@@ -7617,13 +7627,13 @@ ${pointer}`;
|
|
|
7617
7627
|
`Output field "${name}": Expected class names in quotes after "class" type. Example: class "MyClass1, MyClass2"`
|
|
7618
7628
|
);
|
|
7619
7629
|
}
|
|
7620
|
-
const
|
|
7621
|
-
if (
|
|
7630
|
+
const options = classNamesString.split(/[,\s]+/).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
7631
|
+
if (options.length === 0) {
|
|
7622
7632
|
throw new Error(
|
|
7623
7633
|
`Output field "${name}": Empty class list provided. At least one class name is required`
|
|
7624
7634
|
);
|
|
7625
7635
|
}
|
|
7626
|
-
type = { name: "class", isArray,
|
|
7636
|
+
type = { name: "class", isArray, options };
|
|
7627
7637
|
} else {
|
|
7628
7638
|
try {
|
|
7629
7639
|
const typeName = this.parseTypeNotClass();
|