@ax-llm/ax 11.0.11 → 11.0.13
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 +26 -19
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/index.js +26 -19
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -4845,16 +4845,10 @@ var AxPromptTemplate = class {
|
|
|
4845
4845
|
this.sig = sig;
|
|
4846
4846
|
this.fieldTemplates = fieldTemplates;
|
|
4847
4847
|
const task = [];
|
|
4848
|
-
const desc = this.sig.getDescription();
|
|
4849
|
-
if (desc) {
|
|
4850
|
-
const capitalized = capitalizeFirstLetter(desc.trim());
|
|
4851
|
-
task.push(capitalized.endsWith(".") ? capitalized : capitalized + ".");
|
|
4852
|
-
}
|
|
4853
4848
|
const inArgs = this.renderDescFields(this.sig.getInputFields());
|
|
4854
4849
|
const outArgs = this.renderDescFields(this.sig.getOutputFields());
|
|
4855
4850
|
task.push(
|
|
4856
|
-
|
|
4857
|
-
You will be provided with the following fields: ${inArgs}. Your task is to generate new fields: ${outArgs}.`
|
|
4851
|
+
`You will be provided with the following fields: ${inArgs}. Your task is to generate new fields: ${outArgs}.`
|
|
4858
4852
|
);
|
|
4859
4853
|
const funcs = functions?.map(
|
|
4860
4854
|
(f) => "toFunction" in f ? f.toFunction() : f
|
|
@@ -4876,6 +4870,13 @@ ${outputFields}`);
|
|
|
4876
4870
|
task.push(functionCallInstructions.trim());
|
|
4877
4871
|
}
|
|
4878
4872
|
task.push(formattingRules.trim());
|
|
4873
|
+
const desc = this.sig.getDescription();
|
|
4874
|
+
if (desc) {
|
|
4875
|
+
const capitalized = capitalizeFirstLetter(desc.trim());
|
|
4876
|
+
const text = capitalized.endsWith(".") ? capitalized : capitalized + ".";
|
|
4877
|
+
task.push(`---
|
|
4878
|
+
${text}`);
|
|
4879
|
+
}
|
|
4879
4880
|
this.task = {
|
|
4880
4881
|
type: "text",
|
|
4881
4882
|
text: task.join("\n\n")
|
|
@@ -5120,7 +5121,7 @@ ${outputFields}`);
|
|
|
5120
5121
|
const type = field.type?.name ? toFieldType(field.type) : "string";
|
|
5121
5122
|
const required = field.isOptional ? "optional" : "required";
|
|
5122
5123
|
const description = field.description ? `: ${capitalizeFirstLetter(field.description)}` : "";
|
|
5123
|
-
return `- \`${name}
|
|
5124
|
+
return `- \`${name}:\` (${type}, ${required}) ${description}.`.trim();
|
|
5124
5125
|
});
|
|
5125
5126
|
return rows.join("\n");
|
|
5126
5127
|
};
|
|
@@ -6155,6 +6156,12 @@ function processChildAgentFunction(childFunction, parentValues, parentInputKeys,
|
|
|
6155
6156
|
}
|
|
6156
6157
|
return processedFunction;
|
|
6157
6158
|
}
|
|
6159
|
+
var descriptionError = new Error(
|
|
6160
|
+
"Agent description must be at least 20 characters (explain in detail what the agent does)"
|
|
6161
|
+
);
|
|
6162
|
+
var definitionError = new Error(
|
|
6163
|
+
"Agent definition is the prompt you give to the LLM for the agent. It must be detailed and at least 100 characters"
|
|
6164
|
+
);
|
|
6158
6165
|
var AxAgent = class {
|
|
6159
6166
|
ai;
|
|
6160
6167
|
program;
|
|
@@ -6182,22 +6189,18 @@ var AxAgent = class {
|
|
|
6182
6189
|
this.excludeFieldsFromPassthrough = excludeFieldsFromPassthrough ?? [];
|
|
6183
6190
|
if (!name || name.length < 5) {
|
|
6184
6191
|
throw new Error(
|
|
6185
|
-
`Agent name must be at least 10 characters (more descriptive)
|
|
6192
|
+
`Agent name must be at least 10 characters (more descriptive)`
|
|
6186
6193
|
);
|
|
6187
6194
|
}
|
|
6188
6195
|
if (!description || description.length < 20) {
|
|
6189
|
-
throw
|
|
6190
|
-
`Agent description must be at least 20 characters (explain in detail what the agent does): ${description}`
|
|
6191
|
-
);
|
|
6196
|
+
throw descriptionError;
|
|
6192
6197
|
}
|
|
6193
6198
|
if (definition && definition.length < 100) {
|
|
6194
|
-
throw
|
|
6195
|
-
`Agent definition is the prompt you give to the LLM for the agent. It must be detailed and at least 100 characters`
|
|
6196
|
-
);
|
|
6199
|
+
throw definitionError;
|
|
6197
6200
|
}
|
|
6198
6201
|
this.program = new AxGen(signature, {
|
|
6199
6202
|
...options,
|
|
6200
|
-
description: definition
|
|
6203
|
+
description: definition ?? description
|
|
6201
6204
|
});
|
|
6202
6205
|
for (const agent of agents ?? []) {
|
|
6203
6206
|
this.program.register(agent);
|
|
@@ -6319,13 +6322,17 @@ var AxAgent = class {
|
|
|
6319
6322
|
*/
|
|
6320
6323
|
setDescription(description) {
|
|
6321
6324
|
if (!description || description.length < 20) {
|
|
6322
|
-
throw
|
|
6323
|
-
"Agent description must be at least 20 characters (explain in detail what the agent does)"
|
|
6324
|
-
);
|
|
6325
|
+
throw descriptionError;
|
|
6325
6326
|
}
|
|
6326
6327
|
this.program.getSignature().setDescription(description);
|
|
6327
6328
|
this.func.description = description;
|
|
6328
6329
|
}
|
|
6330
|
+
setDefinition(definition) {
|
|
6331
|
+
if (!definition || definition.length < 100) {
|
|
6332
|
+
throw definitionError;
|
|
6333
|
+
}
|
|
6334
|
+
this.program.getSignature().setDescription(definition);
|
|
6335
|
+
}
|
|
6329
6336
|
};
|
|
6330
6337
|
function toCamelCase(inputString) {
|
|
6331
6338
|
const words = inputString.split(/[^a-zA-Z0-9]/);
|