@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.js
CHANGED
|
@@ -4017,8 +4017,7 @@ var AxPromptTemplate = class {
|
|
|
4017
4017
|
const inArgs = this.renderDescFields(this.sig.getInputFields());
|
|
4018
4018
|
const outArgs = this.renderDescFields(this.sig.getOutputFields());
|
|
4019
4019
|
const task = [
|
|
4020
|
-
|
|
4021
|
-
Given the fields ${inArgs}, produce the fields ${outArgs}.`
|
|
4020
|
+
`You will be provided with the following fields: ${inArgs}. Your task is to generate two new fields: ${outArgs}.`
|
|
4022
4021
|
];
|
|
4023
4022
|
const fnNames = functions?.map((f) => {
|
|
4024
4023
|
if ("toFunction" in f) {
|
|
@@ -4026,34 +4025,31 @@ Given the fields ${inArgs}, produce the fields ${outArgs}.`
|
|
|
4026
4025
|
}
|
|
4027
4026
|
return f.name;
|
|
4028
4027
|
});
|
|
4029
|
-
const funcList = fnNames?.map((fname) =>
|
|
4028
|
+
const funcList = fnNames?.map((fname) => `\`${fname}\``).join(", ");
|
|
4030
4029
|
if (funcList && funcList.length > 0) {
|
|
4031
4030
|
task.push(
|
|
4032
|
-
`
|
|
4031
|
+
`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.`
|
|
4033
4032
|
);
|
|
4034
4033
|
}
|
|
4035
4034
|
const desc = this.sig.getDescription();
|
|
4036
4035
|
if (desc) {
|
|
4037
|
-
task.push(desc.endsWith(".") ? desc : desc + ".");
|
|
4036
|
+
task.push(capitalizeFirstLetter(desc.endsWith(".") ? desc : desc + "."));
|
|
4038
4037
|
}
|
|
4039
|
-
task.push(
|
|
4040
|
-
"Ensure the output strictly follows a plain text format, `key: value` separated by a new line."
|
|
4041
|
-
);
|
|
4042
4038
|
const inputFields = this.renderFields(this.sig.getInputFields());
|
|
4039
|
+
task.push(`## Input Fields
|
|
4040
|
+
${inputFields}`);
|
|
4043
4041
|
const outputFields = this.renderFields(this.sig.getOutputFields());
|
|
4042
|
+
task.push(`## Output Fields
|
|
4043
|
+
${outputFields}`);
|
|
4044
|
+
task.push(
|
|
4045
|
+
"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."
|
|
4046
|
+
);
|
|
4044
4047
|
task.push(
|
|
4045
|
-
|
|
4046
|
-
"\n",
|
|
4047
|
-
"## Input Fields",
|
|
4048
|
-
inputFields,
|
|
4049
|
-
"\n",
|
|
4050
|
-
"## Output Fields",
|
|
4051
|
-
outputFields
|
|
4052
|
-
].join("\n")
|
|
4048
|
+
"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."
|
|
4053
4049
|
);
|
|
4054
4050
|
this.task = {
|
|
4055
4051
|
type: "text",
|
|
4056
|
-
text: task.join("
|
|
4052
|
+
text: task.join("\n\n")
|
|
4057
4053
|
};
|
|
4058
4054
|
}
|
|
4059
4055
|
render = (values, {
|
|
@@ -4061,7 +4057,7 @@ Given the fields ${inArgs}, produce the fields ${outArgs}.`
|
|
|
4061
4057
|
demos
|
|
4062
4058
|
}) => {
|
|
4063
4059
|
const renderedExamples = examples ? [
|
|
4064
|
-
{ type: "text", text: "Examples:\n" },
|
|
4060
|
+
{ type: "text", text: "\n## Examples:\n" },
|
|
4065
4061
|
...this.renderExamples(examples)
|
|
4066
4062
|
] : [];
|
|
4067
4063
|
const renderedDemos = demos ? this.renderDemos(demos) : [];
|
|
@@ -4269,16 +4265,14 @@ Given the fields ${inArgs}, produce the fields ${outArgs}.`
|
|
|
4269
4265
|
};
|
|
4270
4266
|
renderDescFields = (list) => list.map((v) => `\`${v.title}\``).join(", ");
|
|
4271
4267
|
renderFields = (fields) => {
|
|
4272
|
-
const header = "Field Name | Field Type | Required/Optional | Description";
|
|
4273
|
-
const separator = "|";
|
|
4274
4268
|
const rows = fields.map((field) => {
|
|
4275
4269
|
const name = field.title;
|
|
4276
4270
|
const type = field.type?.name ? toFieldType(field.type) : "string";
|
|
4277
4271
|
const required = field.isOptional ? "optional" : "required";
|
|
4278
|
-
const description = field.description
|
|
4279
|
-
return
|
|
4272
|
+
const description = field.description ? `: ${capitalizeFirstLetter(field.description)}` : "";
|
|
4273
|
+
return `- \`${name}\` (${type}, ${required})${description}`.trim();
|
|
4280
4274
|
});
|
|
4281
|
-
return
|
|
4275
|
+
return rows.join("\n");
|
|
4282
4276
|
};
|
|
4283
4277
|
};
|
|
4284
4278
|
var processValue = (field, value) => {
|
|
@@ -4353,6 +4347,12 @@ var isEmptyValue = (field, value) => {
|
|
|
4353
4347
|
}
|
|
4354
4348
|
return false;
|
|
4355
4349
|
};
|
|
4350
|
+
function capitalizeFirstLetter(str) {
|
|
4351
|
+
if (str.length === 0) {
|
|
4352
|
+
return "";
|
|
4353
|
+
}
|
|
4354
|
+
return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
|
|
4355
|
+
}
|
|
4356
4356
|
|
|
4357
4357
|
// dsp/validate.ts
|
|
4358
4358
|
var AxValidationError = class extends Error {
|