@ax-llm/ax 10.0.28 → 10.0.29
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 +23 -23
- package/index.cjs.map +1 -1
- package/index.js +23 -23
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -4111,8 +4111,7 @@ var AxPromptTemplate = class {
|
|
|
4111
4111
|
const inArgs = this.renderDescFields(this.sig.getInputFields());
|
|
4112
4112
|
const outArgs = this.renderDescFields(this.sig.getOutputFields());
|
|
4113
4113
|
const task = [
|
|
4114
|
-
|
|
4115
|
-
Given the fields ${inArgs}, produce the fields ${outArgs}.`
|
|
4114
|
+
`You will be provided with the following fields: ${inArgs}. Your task is to generate two new fields: ${outArgs}.`
|
|
4116
4115
|
];
|
|
4117
4116
|
const fnNames = functions?.map((f) => {
|
|
4118
4117
|
if ("toFunction" in f) {
|
|
@@ -4120,34 +4119,31 @@ Given the fields ${inArgs}, produce the fields ${outArgs}.`
|
|
|
4120
4119
|
}
|
|
4121
4120
|
return f.name;
|
|
4122
4121
|
});
|
|
4123
|
-
const funcList = fnNames?.map((fname) =>
|
|
4122
|
+
const funcList = fnNames?.map((fname) => `\`${fname}\``).join(", ");
|
|
4124
4123
|
if (funcList && funcList.length > 0) {
|
|
4125
4124
|
task.push(
|
|
4126
|
-
`
|
|
4125
|
+
`Complete the task, using the following functions as needed: ${funcList}. Refer to the function descriptions for proper usage. The output field values may be generated by applying these functions if appropriate for the task.`
|
|
4127
4126
|
);
|
|
4128
4127
|
}
|
|
4129
4128
|
const desc = this.sig.getDescription();
|
|
4130
4129
|
if (desc) {
|
|
4131
|
-
task.push(desc.endsWith(".") ? desc : desc + ".");
|
|
4130
|
+
task.push(capitalizeFirstLetter(desc.endsWith(".") ? desc : desc + "."));
|
|
4132
4131
|
}
|
|
4133
|
-
task.push(
|
|
4134
|
-
"Ensure the output strictly follows a plain text format, `key: value` separated by a new line."
|
|
4135
|
-
);
|
|
4136
4132
|
const inputFields = this.renderFields(this.sig.getInputFields());
|
|
4133
|
+
task.push(`## Input Fields
|
|
4134
|
+
${inputFields}`);
|
|
4137
4135
|
const outputFields = this.renderFields(this.sig.getOutputFields());
|
|
4136
|
+
task.push(`## Output Fields
|
|
4137
|
+
${outputFields}`);
|
|
4138
|
+
task.push(
|
|
4139
|
+
"Output must be in plain text, with each `key: value` pair on a new line. The format of each `value` should strictly adhere to the formatting instructions for its corresponding `key`, as defined earlier in this prompt."
|
|
4140
|
+
);
|
|
4138
4141
|
task.push(
|
|
4139
|
-
|
|
4140
|
-
"\n",
|
|
4141
|
-
"## Input Fields",
|
|
4142
|
-
inputFields,
|
|
4143
|
-
"\n",
|
|
4144
|
-
"## Output Fields",
|
|
4145
|
-
outputFields
|
|
4146
|
-
].join("\n")
|
|
4142
|
+
"No additional text or formatting is permitted. The specific formatting rules for each key are provided above; ensure the corresponding values follow those rules precisely."
|
|
4147
4143
|
);
|
|
4148
4144
|
this.task = {
|
|
4149
4145
|
type: "text",
|
|
4150
|
-
text: task.join("
|
|
4146
|
+
text: task.join("\n\n")
|
|
4151
4147
|
};
|
|
4152
4148
|
}
|
|
4153
4149
|
render = (values, {
|
|
@@ -4155,7 +4151,7 @@ Given the fields ${inArgs}, produce the fields ${outArgs}.`
|
|
|
4155
4151
|
demos
|
|
4156
4152
|
}) => {
|
|
4157
4153
|
const renderedExamples = examples ? [
|
|
4158
|
-
{ type: "text", text: "Examples:\n" },
|
|
4154
|
+
{ type: "text", text: "\n## Examples:\n" },
|
|
4159
4155
|
...this.renderExamples(examples)
|
|
4160
4156
|
] : [];
|
|
4161
4157
|
const renderedDemos = demos ? this.renderDemos(demos) : [];
|
|
@@ -4363,16 +4359,14 @@ Given the fields ${inArgs}, produce the fields ${outArgs}.`
|
|
|
4363
4359
|
};
|
|
4364
4360
|
renderDescFields = (list) => list.map((v) => `\`${v.title}\``).join(", ");
|
|
4365
4361
|
renderFields = (fields) => {
|
|
4366
|
-
const header = "Field Name | Field Type | Required/Optional | Description";
|
|
4367
|
-
const separator = "|";
|
|
4368
4362
|
const rows = fields.map((field) => {
|
|
4369
4363
|
const name = field.title;
|
|
4370
4364
|
const type = field.type?.name ? toFieldType(field.type) : "string";
|
|
4371
4365
|
const required = field.isOptional ? "optional" : "required";
|
|
4372
|
-
const description = field.description
|
|
4373
|
-
return
|
|
4366
|
+
const description = field.description ? `: ${capitalizeFirstLetter(field.description)}` : "";
|
|
4367
|
+
return `- \`${name}\` (${type}, ${required})${description}`.trim();
|
|
4374
4368
|
});
|
|
4375
|
-
return
|
|
4369
|
+
return rows.join("\n");
|
|
4376
4370
|
};
|
|
4377
4371
|
};
|
|
4378
4372
|
var processValue = (field, value) => {
|
|
@@ -4447,6 +4441,12 @@ var isEmptyValue = (field, value) => {
|
|
|
4447
4441
|
}
|
|
4448
4442
|
return false;
|
|
4449
4443
|
};
|
|
4444
|
+
function capitalizeFirstLetter(str) {
|
|
4445
|
+
if (str.length === 0) {
|
|
4446
|
+
return "";
|
|
4447
|
+
}
|
|
4448
|
+
return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
|
|
4449
|
+
}
|
|
4450
4450
|
|
|
4451
4451
|
// dsp/validate.ts
|
|
4452
4452
|
var AxValidationError = class extends Error {
|