@ax-llm/ax 11.0.13 → 11.0.14

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
@@ -1374,6 +1374,7 @@ type AxProgramForwardOptions = {
1374
1374
  functions?: AxFunction[];
1375
1375
  functionCall?: AxChatRequest['functionCall'];
1376
1376
  stopFunction?: string;
1377
+ earlyFail?: boolean;
1377
1378
  };
1378
1379
  type AxProgramStreamingForwardOptions = Omit<AxProgramForwardOptions, 'stream'>;
1379
1380
  type AxGenDeltaOut<OUT> = {
@@ -1576,6 +1577,7 @@ interface AxResponseHandlerArgs<T> {
1576
1577
  sessionId?: string;
1577
1578
  traceId?: string;
1578
1579
  functions?: Readonly<AxFunction[]>;
1580
+ earlyFail?: boolean;
1579
1581
  }
1580
1582
  interface AxStreamingEvent<T> {
1581
1583
  event: 'delta' | 'done' | 'error';
package/index.d.ts CHANGED
@@ -1374,6 +1374,7 @@ type AxProgramForwardOptions = {
1374
1374
  functions?: AxFunction[];
1375
1375
  functionCall?: AxChatRequest['functionCall'];
1376
1376
  stopFunction?: string;
1377
+ earlyFail?: boolean;
1377
1378
  };
1378
1379
  type AxProgramStreamingForwardOptions = Omit<AxProgramForwardOptions, 'stream'>;
1379
1380
  type AxGenDeltaOut<OUT> = {
@@ -1576,6 +1577,7 @@ interface AxResponseHandlerArgs<T> {
1576
1577
  sessionId?: string;
1577
1578
  traceId?: string;
1578
1579
  functions?: Readonly<AxFunction[]>;
1580
+ earlyFail?: boolean;
1579
1581
  }
1580
1582
  interface AxStreamingEvent<T> {
1581
1583
  event: 'delta' | 'done' | 'error';
package/index.js CHANGED
@@ -4724,12 +4724,12 @@ var AxProgram = class {
4724
4724
 
4725
4725
  // dsp/prompt.ts
4726
4726
  var functionCallInstructions = `
4727
- ### Function Call Instructions
4727
+ ## Function Call Instructions
4728
4728
  - Complete the task, using the functions defined earlier in this prompt.
4729
4729
  - Call functions step-by-step, using the output of one function as input to the next.
4730
4730
  - Use the function results to generate the output fields.`;
4731
4731
  var formattingRules = `
4732
- ### Output Formatting Rules
4732
+ ## Output Formatting Rules
4733
4733
  - Output must strictly follow the defined plain-text \`key: value\` field format.
4734
4734
  - Each output key, value must strictly adhere to the specified output field formatting rules.
4735
4735
  - No preamble, postscript, or supplementary information.
@@ -4755,14 +4755,14 @@ var AxPromptTemplate = class {
4755
4755
  (fn) => `- \`${fn.name}\`: ${capitalizeFirstLetter(fn.description)}.`
4756
4756
  ).join("\n");
4757
4757
  if (funcList && funcList.length > 0) {
4758
- task.push(`### Available Functions
4758
+ task.push(`## Available Functions
4759
4759
  ${funcList}`);
4760
4760
  }
4761
4761
  const inputFields = this.renderFields(this.sig.getInputFields());
4762
- task.push(`### Input Fields
4762
+ task.push(`## Input Fields
4763
4763
  ${inputFields}`);
4764
4764
  const outputFields = this.renderFields(this.sig.getOutputFields());
4765
- task.push(`### Output Fields
4765
+ task.push(`## Output Fields
4766
4766
  ${outputFields}`);
4767
4767
  if (funcList && funcList.length > 0) {
4768
4768
  task.push(functionCallInstructions.trim());
@@ -5118,8 +5118,8 @@ var ValidationError = class extends Error {
5118
5118
  getFixingInstructions = () => {
5119
5119
  return this.fields.map((field) => ({
5120
5120
  name: "outputError",
5121
- title: "Errors In Output Fields",
5122
- description: `Please fix and return the field \`${field.title}\` of type \`${toFieldType(field.type)}\`, ${this.message}.`
5121
+ title: "Output Correction Required",
5122
+ 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.`
5123
5123
  }));
5124
5124
  };
5125
5125
  };
@@ -5716,7 +5716,7 @@ var AxGen = class extends AxProgramWithSignature {
5716
5716
  mem,
5717
5717
  options
5718
5718
  }) {
5719
- const { sessionId, traceId, model, functions } = options ?? {};
5719
+ const { sessionId, traceId, model, functions, earlyFail } = options ?? {};
5720
5720
  const usageInfo = {
5721
5721
  ai: ai.getName(),
5722
5722
  model: ai.getModelInfo().name
@@ -5735,7 +5735,8 @@ var AxGen = class extends AxProgramWithSignature {
5735
5735
  mem,
5736
5736
  traceId,
5737
5737
  sessionId,
5738
- functions
5738
+ functions,
5739
+ earlyFail
5739
5740
  });
5740
5741
  } else {
5741
5742
  yield await this.processResponse({
@@ -5758,9 +5759,10 @@ var AxGen = class extends AxProgramWithSignature {
5758
5759
  mem,
5759
5760
  sessionId,
5760
5761
  traceId,
5761
- functions
5762
+ functions,
5763
+ earlyFail
5762
5764
  }) {
5763
- const streamingValidation = ai.getFeatures().functionCot !== true;
5765
+ const streamingValidation = earlyFail ?? ai.getFeatures().functionCot !== true;
5764
5766
  const functionCalls = [];
5765
5767
  const values = {};
5766
5768
  const xstate = {