@ax-llm/ax 11.0.39 → 11.0.42

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 CHANGED
@@ -90,6 +90,7 @@ __export(index_exports, {
90
90
  AxFunctionError: () => AxFunctionError,
91
91
  AxFunctionProcessor: () => AxFunctionProcessor,
92
92
  AxGen: () => AxGen,
93
+ AxGenerateError: () => AxGenerateError,
93
94
  AxHFDataLoader: () => AxHFDataLoader,
94
95
  AxInstanceRegistry: () => AxInstanceRegistry,
95
96
  AxJSInterpreter: () => AxJSInterpreter,
@@ -900,6 +901,7 @@ var AxBaseAI = class {
900
901
  rt;
901
902
  fetch;
902
903
  tracer;
904
+ timeout;
903
905
  models;
904
906
  modelInfo;
905
907
  modelUsage;
@@ -958,6 +960,7 @@ var AxBaseAI = class {
958
960
  this.debug = options.debug ?? false;
959
961
  this.rt = options.rateLimiter;
960
962
  this.fetch = options.fetch;
963
+ this.timeout = options.timeout;
961
964
  this.tracer = options.tracer;
962
965
  }
963
966
  getOptions() {
@@ -1141,6 +1144,7 @@ var AxBaseAI = class {
1141
1144
  url: this.apiURL,
1142
1145
  headers: await this.buildHeaders(apiConfig.headers),
1143
1146
  stream: modelConfig.stream,
1147
+ timeout: this.timeout,
1144
1148
  debug,
1145
1149
  fetch: this.fetch,
1146
1150
  span
@@ -1270,6 +1274,7 @@ var AxBaseAI = class {
1270
1274
  headers: await this.buildHeaders(apiConfig.headers),
1271
1275
  debug,
1272
1276
  fetch: this.fetch,
1277
+ timeout: this.timeout,
1273
1278
  span
1274
1279
  },
1275
1280
  reqValue
@@ -5948,7 +5953,7 @@ function* streamValues(sig, content, values, xstate) {
5948
5953
  const v = value.slice(s);
5949
5954
  if (v && v.length > 0) {
5950
5955
  yield { [key]: v };
5951
- xstate.streamedIndex[key] = s + 1;
5956
+ xstate.streamedIndex[key] = s + v.length;
5952
5957
  }
5953
5958
  continue;
5954
5959
  }
@@ -6794,21 +6799,31 @@ Content: ${result.content}`
6794
6799
  });
6795
6800
  }
6796
6801
  };
6802
+ var AxGenerateError = class extends Error {
6803
+ details;
6804
+ constructor(message, details, options) {
6805
+ super(message, options);
6806
+ this.name = "AxGenerateError";
6807
+ this.details = details;
6808
+ }
6809
+ };
6797
6810
  function enhanceError(e, ai, signature) {
6798
6811
  const originalError = e instanceof Error ? e : new Error(String(e));
6799
6812
  const model = ai.getLastUsedChatModel();
6800
6813
  const modelConfig = ai.getLastUsedModelConfig();
6801
- const details = [
6802
- `name=${ai.getName()}`,
6803
- `model=${model}`,
6804
- `maxTokens=${modelConfig?.maxTokens ?? "N/A"}`,
6805
- `streaming=${modelConfig?.stream ?? false}`
6806
- ].join(", ");
6807
- return new Error(
6808
- `Generate Failed:${signature.toString()}
6809
- Details: ${details}`,
6810
- { cause: originalError }
6811
- );
6814
+ const details = {
6815
+ model,
6816
+ maxTokens: modelConfig?.maxTokens,
6817
+ streaming: modelConfig?.stream ?? false,
6818
+ signature: {
6819
+ input: signature.getInputFields(),
6820
+ output: signature.getOutputFields(),
6821
+ description: signature.getDescription()
6822
+ }
6823
+ };
6824
+ return new AxGenerateError("Generate failed", details, {
6825
+ cause: originalError
6826
+ });
6812
6827
  }
6813
6828
 
6814
6829
  // prompts/agent.ts
@@ -11560,6 +11575,7 @@ var AxRAG = class extends AxChainOfThought {
11560
11575
  AxFunctionError,
11561
11576
  AxFunctionProcessor,
11562
11577
  AxGen,
11578
+ AxGenerateError,
11563
11579
  AxHFDataLoader,
11564
11580
  AxInstanceRegistry,
11565
11581
  AxJSInterpreter,