@ax-llm/ax 11.0.54 → 11.0.55
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 +24 -72
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -9
- package/index.d.ts +1 -9
- package/index.js +24 -72
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -5979,15 +5979,11 @@ var AxPromptTemplate = class {
|
|
|
5979
5979
|
task;
|
|
5980
5980
|
thoughtFieldName;
|
|
5981
5981
|
functions;
|
|
5982
|
-
strictExamples;
|
|
5983
|
-
optionalOutputFields;
|
|
5984
5982
|
constructor(sig, options, fieldTemplates) {
|
|
5985
5983
|
this.sig = sig;
|
|
5986
5984
|
this.fieldTemplates = fieldTemplates;
|
|
5987
5985
|
this.thoughtFieldName = options?.thoughtFieldName ?? "thought";
|
|
5988
5986
|
this.functions = options?.functions;
|
|
5989
|
-
this.strictExamples = options?.strictExamples ?? false;
|
|
5990
|
-
this.optionalOutputFields = options?.optionalOutputFields ?? [];
|
|
5991
5987
|
const task = [];
|
|
5992
5988
|
const inArgs = renderDescFields(this.sig.getInputFields());
|
|
5993
5989
|
const outArgs = renderDescFields(this.sig.getOutputFields());
|
|
@@ -6157,33 +6153,22 @@ ${outputFields}`);
|
|
|
6157
6153
|
};
|
|
6158
6154
|
renderExamples = (data) => {
|
|
6159
6155
|
const list = [];
|
|
6160
|
-
const
|
|
6161
|
-
isExample: true
|
|
6162
|
-
strictExamples: this.strictExamples,
|
|
6163
|
-
optionalOutputFields: this.optionalOutputFields,
|
|
6164
|
-
isInputField: true
|
|
6165
|
-
};
|
|
6166
|
-
const outputExampleContext = {
|
|
6167
|
-
isExample: true,
|
|
6168
|
-
strictExamples: this.strictExamples,
|
|
6169
|
-
optionalOutputFields: this.optionalOutputFields,
|
|
6170
|
-
isInputField: false
|
|
6156
|
+
const exampleContext = {
|
|
6157
|
+
isExample: true
|
|
6171
6158
|
};
|
|
6172
6159
|
for (const [index, item] of data.entries()) {
|
|
6173
|
-
const renderedInputItem = this.sig.getInputFields().map(
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
)
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
}
|
|
6186
|
-
}
|
|
6160
|
+
const renderedInputItem = this.sig.getInputFields().map(
|
|
6161
|
+
(field) => this.renderInField(field, item, {
|
|
6162
|
+
...exampleContext,
|
|
6163
|
+
isInputField: true
|
|
6164
|
+
})
|
|
6165
|
+
).filter((v) => v !== void 0).flat();
|
|
6166
|
+
const renderedOutputItem = this.sig.getOutputFields().map(
|
|
6167
|
+
(field) => this.renderInField(field, item, {
|
|
6168
|
+
...exampleContext,
|
|
6169
|
+
isInputField: false
|
|
6170
|
+
})
|
|
6171
|
+
).filter((v) => v !== void 0).flat();
|
|
6187
6172
|
const renderedItem = [...renderedInputItem, ...renderedOutputItem];
|
|
6188
6173
|
if (index > 0 && renderedItem.length > 0 && renderedItem[0]?.type === "text") {
|
|
6189
6174
|
list.push({ type: "text", text: "---\n\n" });
|
|
@@ -6204,20 +6189,19 @@ ${outputFields}`);
|
|
|
6204
6189
|
const list = [];
|
|
6205
6190
|
const inputFields = this.sig.getInputFields();
|
|
6206
6191
|
const outputFields = this.sig.getOutputFields();
|
|
6192
|
+
const demoContext = {
|
|
6193
|
+
isExample: true
|
|
6194
|
+
};
|
|
6207
6195
|
for (const item of data) {
|
|
6208
6196
|
const inputRenderedItems = inputFields.map(
|
|
6209
6197
|
(field) => this.renderInField(field, item, {
|
|
6210
|
-
|
|
6211
|
-
strictExamples: this.strictExamples,
|
|
6212
|
-
optionalOutputFields: this.optionalOutputFields,
|
|
6198
|
+
...demoContext,
|
|
6213
6199
|
isInputField: true
|
|
6214
6200
|
})
|
|
6215
6201
|
).filter((v) => v !== void 0).flat();
|
|
6216
6202
|
const outputRenderedItems = outputFields.map(
|
|
6217
6203
|
(field) => this.renderInField(field, item, {
|
|
6218
|
-
|
|
6219
|
-
strictExamples: this.strictExamples,
|
|
6220
|
-
optionalOutputFields: this.optionalOutputFields,
|
|
6204
|
+
...demoContext,
|
|
6221
6205
|
isInputField: false
|
|
6222
6206
|
})
|
|
6223
6207
|
).filter((v) => v !== void 0).flat();
|
|
@@ -6433,24 +6417,9 @@ var isEmptyValue = (field, value, context3) => {
|
|
|
6433
6417
|
}
|
|
6434
6418
|
if (!value || (Array.isArray(value) || typeof value === "string") && value.length === 0) {
|
|
6435
6419
|
if (context3?.isExample) {
|
|
6436
|
-
|
|
6437
|
-
if (isInputField) {
|
|
6438
|
-
if (!context3?.strictExamples) {
|
|
6439
|
-
return true;
|
|
6440
|
-
} else {
|
|
6441
|
-
if (field.isOptional || field.isInternal) {
|
|
6442
|
-
return true;
|
|
6443
|
-
}
|
|
6444
|
-
throw new Error(`Value for input field '${field.name}' is required.`);
|
|
6445
|
-
}
|
|
6446
|
-
} else {
|
|
6447
|
-
if (field.isOptional || field.isInternal || context3?.optionalOutputFields?.includes(field.name)) {
|
|
6448
|
-
return true;
|
|
6449
|
-
}
|
|
6450
|
-
throw new Error(`Value for output field '${field.name}' is required.`);
|
|
6451
|
-
}
|
|
6420
|
+
return true;
|
|
6452
6421
|
}
|
|
6453
|
-
if (field.isOptional || field.isInternal
|
|
6422
|
+
if (field.isOptional || field.isInternal) {
|
|
6454
6423
|
return true;
|
|
6455
6424
|
}
|
|
6456
6425
|
const fieldType = context3?.isInputField !== false ? "input" : "output";
|
|
@@ -7781,7 +7750,7 @@ var AxProgramWithSignature = class {
|
|
|
7781
7750
|
const res = {};
|
|
7782
7751
|
for (const f of fields) {
|
|
7783
7752
|
const value = e[f.name];
|
|
7784
|
-
if (value) {
|
|
7753
|
+
if (value !== void 0) {
|
|
7785
7754
|
validateValue(f, value);
|
|
7786
7755
|
res[f.name] = value;
|
|
7787
7756
|
}
|
|
@@ -7914,9 +7883,7 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
7914
7883
|
this.thoughtFieldName = options?.thoughtFieldName ?? "thought";
|
|
7915
7884
|
const promptTemplateOptions = {
|
|
7916
7885
|
functions: options?.functions,
|
|
7917
|
-
thoughtFieldName: this.thoughtFieldName
|
|
7918
|
-
strictExamples: options?.strictExamples,
|
|
7919
|
-
optionalOutputFields: options?.optionalOutputFields
|
|
7886
|
+
thoughtFieldName: this.thoughtFieldName
|
|
7920
7887
|
};
|
|
7921
7888
|
this.promptTemplate = new (options?.promptTemplate ?? AxPromptTemplate)(
|
|
7922
7889
|
this.signature,
|
|
@@ -8280,9 +8247,7 @@ Content: ${result.content}`
|
|
|
8280
8247
|
const promptTemplateClass = this.options?.promptTemplate ?? AxPromptTemplate;
|
|
8281
8248
|
const currentPromptTemplateOptions = {
|
|
8282
8249
|
functions: options.functions,
|
|
8283
|
-
thoughtFieldName: this.thoughtFieldName
|
|
8284
|
-
strictExamples: this.options?.strictExamples,
|
|
8285
|
-
optionalOutputFields: this.options?.optionalOutputFields
|
|
8250
|
+
thoughtFieldName: this.thoughtFieldName
|
|
8286
8251
|
};
|
|
8287
8252
|
this.promptTemplate = new promptTemplateClass(
|
|
8288
8253
|
this.signature,
|
|
@@ -8470,19 +8435,6 @@ Content: ${result.content}`
|
|
|
8470
8435
|
}
|
|
8471
8436
|
setExamples(examples, options) {
|
|
8472
8437
|
super.setExamples(examples, options);
|
|
8473
|
-
if (options?.optionalOutputFields) {
|
|
8474
|
-
const promptTemplateClass = this.options?.promptTemplate ?? AxPromptTemplate;
|
|
8475
|
-
const currentPromptTemplateOptions = {
|
|
8476
|
-
functions: this.functions,
|
|
8477
|
-
thoughtFieldName: this.thoughtFieldName,
|
|
8478
|
-
strictExamples: this.options?.strictExamples,
|
|
8479
|
-
optionalOutputFields: options.optionalOutputFields
|
|
8480
|
-
};
|
|
8481
|
-
this.promptTemplate = new promptTemplateClass(
|
|
8482
|
-
this.signature,
|
|
8483
|
-
currentPromptTemplateOptions
|
|
8484
|
-
);
|
|
8485
|
-
}
|
|
8486
8438
|
}
|
|
8487
8439
|
};
|
|
8488
8440
|
var AxGenerateError = class extends Error {
|