@ax-llm/ax 11.0.32 → 11.0.34
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 +44 -2
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -0
- package/index.d.ts +2 -0
- package/index.js +44 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -4134,6 +4134,12 @@ var AxAssertionError = class extends Error {
|
|
|
4134
4134
|
});
|
|
4135
4135
|
return extraFields;
|
|
4136
4136
|
};
|
|
4137
|
+
toString() {
|
|
4138
|
+
return `${this.name}: ${this.message}`;
|
|
4139
|
+
}
|
|
4140
|
+
[Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
|
|
4141
|
+
return this.toString();
|
|
4142
|
+
}
|
|
4137
4143
|
};
|
|
4138
4144
|
var assertAssertions = async (asserts, values) => {
|
|
4139
4145
|
for (const assert of asserts) {
|
|
@@ -4917,6 +4923,9 @@ function matchesContent(content, prefix, startIndex = 0, prefixCache = globalPre
|
|
|
4917
4923
|
);
|
|
4918
4924
|
for (let i = 0; i < prefixes.length - 1; i++) {
|
|
4919
4925
|
const partialPrefix = prefixes[i];
|
|
4926
|
+
if (partialPrefix === "\n" || partialPrefix === ":") {
|
|
4927
|
+
continue;
|
|
4928
|
+
}
|
|
4920
4929
|
if (partialPrefix && contentEnd.endsWith(partialPrefix)) {
|
|
4921
4930
|
return -2;
|
|
4922
4931
|
}
|
|
@@ -5571,6 +5580,17 @@ var ValidationError = class extends Error {
|
|
|
5571
5580
|
description: `The section labeled '${field.title}' either was not generated by the LLM or does not match the expected format of '${toFieldType(field.type)}'. ${this.message} Please revise your response to ensure it conforms to the specified format.`
|
|
5572
5581
|
}));
|
|
5573
5582
|
};
|
|
5583
|
+
toString() {
|
|
5584
|
+
return [
|
|
5585
|
+
`${this.name}: ${this.message}`,
|
|
5586
|
+
...this.fields.map(
|
|
5587
|
+
(field) => ` - ${field.title}: Expected format '${toFieldType(field.type)}'`
|
|
5588
|
+
)
|
|
5589
|
+
].join("\n");
|
|
5590
|
+
}
|
|
5591
|
+
[Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
|
|
5592
|
+
return this.toString();
|
|
5593
|
+
}
|
|
5574
5594
|
};
|
|
5575
5595
|
function handleValidationError(mem, errorFields, ai, promptTemplate, sessionId) {
|
|
5576
5596
|
mem.add(
|
|
@@ -5688,7 +5708,7 @@ var streamingExtractValues = (sig, values, xstate, content, streamingValidation
|
|
|
5688
5708
|
}
|
|
5689
5709
|
const isFirst = xstate.extractedFields.length === 0;
|
|
5690
5710
|
const prefix = (isFirst ? "" : "\n") + field.title + ":";
|
|
5691
|
-
let e = matchesContent(content, prefix, xstate.s
|
|
5711
|
+
let e = matchesContent(content, prefix, xstate.s);
|
|
5692
5712
|
switch (e) {
|
|
5693
5713
|
case -1:
|
|
5694
5714
|
if (streamingValidation && values.length == 0 && !field.isOptional) {
|
|
@@ -6054,6 +6074,15 @@ var AxFunctionError = class extends Error {
|
|
|
6054
6074
|
this.name = this.constructor.name;
|
|
6055
6075
|
}
|
|
6056
6076
|
getFields = () => this.fields;
|
|
6077
|
+
toString() {
|
|
6078
|
+
return [
|
|
6079
|
+
`${this.name}: Function validation error`,
|
|
6080
|
+
...this.fields.map((field) => ` - ${field.field}: ${field.message}`)
|
|
6081
|
+
].join("\n");
|
|
6082
|
+
}
|
|
6083
|
+
[Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
|
|
6084
|
+
return this.toString();
|
|
6085
|
+
}
|
|
6057
6086
|
};
|
|
6058
6087
|
var FunctionError = class extends Error {
|
|
6059
6088
|
constructor(fields, func, funcId) {
|
|
@@ -6082,6 +6111,19 @@ var FunctionError = class extends Error {
|
|
|
6082
6111
|
return `Errors In Function Arguments: Fix the following invalid arguments to '${this.func.name}'
|
|
6083
6112
|
${bulletPoints.join("\n")}`;
|
|
6084
6113
|
};
|
|
6114
|
+
toString() {
|
|
6115
|
+
return [
|
|
6116
|
+
`${this.name}: Function execution error in '${this.func.name}'`,
|
|
6117
|
+
...this.fields.map((field) => {
|
|
6118
|
+
const description = this.getFieldDescription(field.field);
|
|
6119
|
+
return ` - ${field.field}: ${field.message}${description ? ` (${description})` : ""}`;
|
|
6120
|
+
}),
|
|
6121
|
+
this.funcId ? ` Function ID: ${this.funcId}` : ""
|
|
6122
|
+
].join("\n");
|
|
6123
|
+
}
|
|
6124
|
+
[Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
|
|
6125
|
+
return this.toString();
|
|
6126
|
+
}
|
|
6085
6127
|
};
|
|
6086
6128
|
var AxFunctionProcessor = class {
|
|
6087
6129
|
funcList = [];
|
|
@@ -6596,7 +6638,7 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
6596
6638
|
}
|
|
6597
6639
|
}
|
|
6598
6640
|
}
|
|
6599
|
-
throw new Error(`Unable to fix validation error: ${err?.
|
|
6641
|
+
throw new Error(`Unable to fix validation error: ${err?.toString()}`);
|
|
6600
6642
|
}
|
|
6601
6643
|
throw new Error(`Max steps reached: ${maxSteps}`);
|
|
6602
6644
|
}
|