@ax-llm/ax 11.0.32 → 11.0.33

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.d.cts CHANGED
@@ -1488,6 +1488,7 @@ declare class AxFunctionError extends Error {
1488
1488
  field: string;
1489
1489
  message: string;
1490
1490
  }[];
1491
+ toString(): string;
1491
1492
  }
1492
1493
  type AxChatResponseFunctionCall = {
1493
1494
  id: string;
@@ -1671,6 +1672,7 @@ declare class AxAssertionError extends Error {
1671
1672
  title: string;
1672
1673
  description: string;
1673
1674
  }[];
1675
+ toString(): string;
1674
1676
  }
1675
1677
 
1676
1678
  type AxFieldProcessorProcess = (value: AxFieldValue, context?: Readonly<{
package/index.d.ts CHANGED
@@ -1488,6 +1488,7 @@ declare class AxFunctionError extends Error {
1488
1488
  field: string;
1489
1489
  message: string;
1490
1490
  }[];
1491
+ toString(): string;
1491
1492
  }
1492
1493
  type AxChatResponseFunctionCall = {
1493
1494
  id: string;
@@ -1671,6 +1672,7 @@ declare class AxAssertionError extends Error {
1671
1672
  title: string;
1672
1673
  description: string;
1673
1674
  }[];
1675
+ toString(): string;
1674
1676
  }
1675
1677
 
1676
1678
  type AxFieldProcessorProcess = (value: AxFieldValue, context?: Readonly<{
package/index.js CHANGED
@@ -3984,6 +3984,12 @@ var AxAssertionError = class extends Error {
3984
3984
  });
3985
3985
  return extraFields;
3986
3986
  };
3987
+ toString() {
3988
+ return `${this.name}: ${this.message}`;
3989
+ }
3990
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
3991
+ return this.toString();
3992
+ }
3987
3993
  };
3988
3994
  var assertAssertions = async (asserts, values) => {
3989
3995
  for (const assert of asserts) {
@@ -5421,6 +5427,17 @@ var ValidationError = class extends Error {
5421
5427
  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.`
5422
5428
  }));
5423
5429
  };
5430
+ toString() {
5431
+ return [
5432
+ `${this.name}: ${this.message}`,
5433
+ ...this.fields.map(
5434
+ (field) => ` - ${field.title}: Expected format '${toFieldType(field.type)}'`
5435
+ )
5436
+ ].join("\n");
5437
+ }
5438
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
5439
+ return this.toString();
5440
+ }
5424
5441
  };
5425
5442
  function handleValidationError(mem, errorFields, ai, promptTemplate, sessionId) {
5426
5443
  mem.add(
@@ -5904,6 +5921,15 @@ var AxFunctionError = class extends Error {
5904
5921
  this.name = this.constructor.name;
5905
5922
  }
5906
5923
  getFields = () => this.fields;
5924
+ toString() {
5925
+ return [
5926
+ `${this.name}: Function validation error`,
5927
+ ...this.fields.map((field) => ` - ${field.field}: ${field.message}`)
5928
+ ].join("\n");
5929
+ }
5930
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
5931
+ return this.toString();
5932
+ }
5907
5933
  };
5908
5934
  var FunctionError = class extends Error {
5909
5935
  constructor(fields, func, funcId) {
@@ -5932,6 +5958,19 @@ var FunctionError = class extends Error {
5932
5958
  return `Errors In Function Arguments: Fix the following invalid arguments to '${this.func.name}'
5933
5959
  ${bulletPoints.join("\n")}`;
5934
5960
  };
5961
+ toString() {
5962
+ return [
5963
+ `${this.name}: Function execution error in '${this.func.name}'`,
5964
+ ...this.fields.map((field) => {
5965
+ const description = this.getFieldDescription(field.field);
5966
+ return ` - ${field.field}: ${field.message}${description ? ` (${description})` : ""}`;
5967
+ }),
5968
+ this.funcId ? ` Function ID: ${this.funcId}` : ""
5969
+ ].join("\n");
5970
+ }
5971
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
5972
+ return this.toString();
5973
+ }
5935
5974
  };
5936
5975
  var AxFunctionProcessor = class {
5937
5976
  funcList = [];
@@ -6446,7 +6485,7 @@ var AxGen = class extends AxProgramWithSignature {
6446
6485
  }
6447
6486
  }
6448
6487
  }
6449
- throw new Error(`Unable to fix validation error: ${err?.message}`);
6488
+ throw new Error(`Unable to fix validation error: ${err}`);
6450
6489
  }
6451
6490
  throw new Error(`Max steps reached: ${maxSteps}`);
6452
6491
  }