@ax-llm/ax 11.0.13 → 11.0.15
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 +15 -11
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -0
- package/index.d.ts +2 -0
- package/index.js +15 -11
- package/index.js.map +1 -1
- package/package.json +1 -1
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
|
@@ -4358,6 +4358,8 @@ var validateValue = (field, value) => {
|
|
|
4358
4358
|
return val instanceof Date || typeof val === "string";
|
|
4359
4359
|
case "datetime":
|
|
4360
4360
|
return val instanceof Date || typeof val === "string";
|
|
4361
|
+
case "json":
|
|
4362
|
+
return typeof val === "object" || typeof val === "string";
|
|
4361
4363
|
default:
|
|
4362
4364
|
return false;
|
|
4363
4365
|
}
|
|
@@ -4724,12 +4726,12 @@ var AxProgram = class {
|
|
|
4724
4726
|
|
|
4725
4727
|
// dsp/prompt.ts
|
|
4726
4728
|
var functionCallInstructions = `
|
|
4727
|
-
|
|
4729
|
+
## Function Call Instructions
|
|
4728
4730
|
- Complete the task, using the functions defined earlier in this prompt.
|
|
4729
4731
|
- Call functions step-by-step, using the output of one function as input to the next.
|
|
4730
4732
|
- Use the function results to generate the output fields.`;
|
|
4731
4733
|
var formattingRules = `
|
|
4732
|
-
|
|
4734
|
+
## Output Formatting Rules
|
|
4733
4735
|
- Output must strictly follow the defined plain-text \`key: value\` field format.
|
|
4734
4736
|
- Each output key, value must strictly adhere to the specified output field formatting rules.
|
|
4735
4737
|
- No preamble, postscript, or supplementary information.
|
|
@@ -4755,14 +4757,14 @@ var AxPromptTemplate = class {
|
|
|
4755
4757
|
(fn) => `- \`${fn.name}\`: ${capitalizeFirstLetter(fn.description)}.`
|
|
4756
4758
|
).join("\n");
|
|
4757
4759
|
if (funcList && funcList.length > 0) {
|
|
4758
|
-
task.push(
|
|
4760
|
+
task.push(`## Available Functions
|
|
4759
4761
|
${funcList}`);
|
|
4760
4762
|
}
|
|
4761
4763
|
const inputFields = this.renderFields(this.sig.getInputFields());
|
|
4762
|
-
task.push(
|
|
4764
|
+
task.push(`## Input Fields
|
|
4763
4765
|
${inputFields}`);
|
|
4764
4766
|
const outputFields = this.renderFields(this.sig.getOutputFields());
|
|
4765
|
-
task.push(
|
|
4767
|
+
task.push(`## Output Fields
|
|
4766
4768
|
${outputFields}`);
|
|
4767
4769
|
if (funcList && funcList.length > 0) {
|
|
4768
4770
|
task.push(functionCallInstructions.trim());
|
|
@@ -5118,8 +5120,8 @@ var ValidationError = class extends Error {
|
|
|
5118
5120
|
getFixingInstructions = () => {
|
|
5119
5121
|
return this.fields.map((field) => ({
|
|
5120
5122
|
name: "outputError",
|
|
5121
|
-
title: "
|
|
5122
|
-
description: `
|
|
5123
|
+
title: "Output Correction Required",
|
|
5124
|
+
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
5125
|
}));
|
|
5124
5126
|
};
|
|
5125
5127
|
};
|
|
@@ -5716,7 +5718,7 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5716
5718
|
mem,
|
|
5717
5719
|
options
|
|
5718
5720
|
}) {
|
|
5719
|
-
const { sessionId, traceId, model, functions } = options ?? {};
|
|
5721
|
+
const { sessionId, traceId, model, functions, earlyFail } = options ?? {};
|
|
5720
5722
|
const usageInfo = {
|
|
5721
5723
|
ai: ai.getName(),
|
|
5722
5724
|
model: ai.getModelInfo().name
|
|
@@ -5735,7 +5737,8 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5735
5737
|
mem,
|
|
5736
5738
|
traceId,
|
|
5737
5739
|
sessionId,
|
|
5738
|
-
functions
|
|
5740
|
+
functions,
|
|
5741
|
+
earlyFail
|
|
5739
5742
|
});
|
|
5740
5743
|
} else {
|
|
5741
5744
|
yield await this.processResponse({
|
|
@@ -5758,9 +5761,10 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
5758
5761
|
mem,
|
|
5759
5762
|
sessionId,
|
|
5760
5763
|
traceId,
|
|
5761
|
-
functions
|
|
5764
|
+
functions,
|
|
5765
|
+
earlyFail
|
|
5762
5766
|
}) {
|
|
5763
|
-
const streamingValidation = ai.getFeatures().functionCot !== true;
|
|
5767
|
+
const streamingValidation = earlyFail ?? ai.getFeatures().functionCot !== true;
|
|
5764
5768
|
const functionCalls = [];
|
|
5765
5769
|
const values = {};
|
|
5766
5770
|
const xstate = {
|