@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.d.cts CHANGED
@@ -1680,6 +1680,7 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut = AxGenOut> imple
1680
1680
  * @throws Error if description is too short
1681
1681
  */
1682
1682
  setDescription(description: string): void;
1683
+ setDefinition(definition: string): void;
1683
1684
  }
1684
1685
 
1685
1686
  interface AxApacheTikaArgs {
package/index.d.ts CHANGED
@@ -1680,6 +1680,7 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut = AxGenOut> imple
1680
1680
  * @throws Error if description is too short
1681
1681
  */
1682
1682
  setDescription(description: string): void;
1683
+ setDefinition(definition: string): void;
1683
1684
  }
1684
1685
 
1685
1686
  interface AxApacheTikaArgs {
package/index.js CHANGED
@@ -4743,16 +4743,10 @@ var AxPromptTemplate = class {
4743
4743
  this.sig = sig;
4744
4744
  this.fieldTemplates = fieldTemplates;
4745
4745
  const task = [];
4746
- const desc = this.sig.getDescription();
4747
- if (desc) {
4748
- const capitalized = capitalizeFirstLetter(desc.trim());
4749
- task.push(capitalized.endsWith(".") ? capitalized : capitalized + ".");
4750
- }
4751
4746
  const inArgs = this.renderDescFields(this.sig.getInputFields());
4752
4747
  const outArgs = this.renderDescFields(this.sig.getOutputFields());
4753
4748
  task.push(
4754
- `## Processing Instructions
4755
- You will be provided with the following fields: ${inArgs}. Your task is to generate new fields: ${outArgs}.`
4749
+ `You will be provided with the following fields: ${inArgs}. Your task is to generate new fields: ${outArgs}.`
4756
4750
  );
4757
4751
  const funcs = functions?.map(
4758
4752
  (f) => "toFunction" in f ? f.toFunction() : f
@@ -4774,6 +4768,13 @@ ${outputFields}`);
4774
4768
  task.push(functionCallInstructions.trim());
4775
4769
  }
4776
4770
  task.push(formattingRules.trim());
4771
+ const desc = this.sig.getDescription();
4772
+ if (desc) {
4773
+ const capitalized = capitalizeFirstLetter(desc.trim());
4774
+ const text = capitalized.endsWith(".") ? capitalized : capitalized + ".";
4775
+ task.push(`---
4776
+ ${text}`);
4777
+ }
4777
4778
  this.task = {
4778
4779
  type: "text",
4779
4780
  text: task.join("\n\n")
@@ -5018,7 +5019,7 @@ ${outputFields}`);
5018
5019
  const type = field.type?.name ? toFieldType(field.type) : "string";
5019
5020
  const required = field.isOptional ? "optional" : "required";
5020
5021
  const description = field.description ? `: ${capitalizeFirstLetter(field.description)}` : "";
5021
- return `- \`${name}\` (${type}, ${required})${description}.`.trim();
5022
+ return `- \`${name}:\` (${type}, ${required}) ${description}.`.trim();
5022
5023
  });
5023
5024
  return rows.join("\n");
5024
5025
  };
@@ -6053,6 +6054,12 @@ function processChildAgentFunction(childFunction, parentValues, parentInputKeys,
6053
6054
  }
6054
6055
  return processedFunction;
6055
6056
  }
6057
+ var descriptionError = new Error(
6058
+ "Agent description must be at least 20 characters (explain in detail what the agent does)"
6059
+ );
6060
+ var definitionError = new Error(
6061
+ "Agent definition is the prompt you give to the LLM for the agent. It must be detailed and at least 100 characters"
6062
+ );
6056
6063
  var AxAgent = class {
6057
6064
  ai;
6058
6065
  program;
@@ -6080,22 +6087,18 @@ var AxAgent = class {
6080
6087
  this.excludeFieldsFromPassthrough = excludeFieldsFromPassthrough ?? [];
6081
6088
  if (!name || name.length < 5) {
6082
6089
  throw new Error(
6083
- `Agent name must be at least 10 characters (more descriptive): ${name}`
6090
+ `Agent name must be at least 10 characters (more descriptive)`
6084
6091
  );
6085
6092
  }
6086
6093
  if (!description || description.length < 20) {
6087
- throw new Error(
6088
- `Agent description must be at least 20 characters (explain in detail what the agent does): ${description}`
6089
- );
6094
+ throw descriptionError;
6090
6095
  }
6091
6096
  if (definition && definition.length < 100) {
6092
- throw new Error(
6093
- `Agent definition is the prompt you give to the LLM for the agent. It must be detailed and at least 100 characters`
6094
- );
6097
+ throw definitionError;
6095
6098
  }
6096
6099
  this.program = new AxGen(signature, {
6097
6100
  ...options,
6098
- description: definition
6101
+ description: definition ?? description
6099
6102
  });
6100
6103
  for (const agent of agents ?? []) {
6101
6104
  this.program.register(agent);
@@ -6217,13 +6220,17 @@ var AxAgent = class {
6217
6220
  */
6218
6221
  setDescription(description) {
6219
6222
  if (!description || description.length < 20) {
6220
- throw new Error(
6221
- "Agent description must be at least 20 characters (explain in detail what the agent does)"
6222
- );
6223
+ throw descriptionError;
6223
6224
  }
6224
6225
  this.program.getSignature().setDescription(description);
6225
6226
  this.func.description = description;
6226
6227
  }
6228
+ setDefinition(definition) {
6229
+ if (!definition || definition.length < 100) {
6230
+ throw definitionError;
6231
+ }
6232
+ this.program.getSignature().setDescription(definition);
6233
+ }
6227
6234
  };
6228
6235
  function toCamelCase(inputString) {
6229
6236
  const words = inputString.split(/[^a-zA-Z0-9]/);