@agent-smith/task 0.1.4 → 0.1.6

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/dist/task.js CHANGED
@@ -18,7 +18,7 @@ class Task {
18
18
  //console.log("TASK CONF", conf);
19
19
  //console.log("TOOLS", this.agent.tools);
20
20
  if (!params?.prompt) {
21
- throw new Error("Please provide a prompt parameter");
21
+ throw new Error(`Task ${this.def.name}: no prompt parameter provided. Parameters: ${params}`);
22
22
  }
23
23
  let model = this.def.model;
24
24
  let ctx = this.def.ctx;
@@ -73,7 +73,7 @@ class Task {
73
73
  console.log("----------------------------------------------");
74
74
  console.log("Infer params:", this.def.inferParams);
75
75
  console.log("----------------------------------------------");
76
- options.debug = true;
76
+ //options.debug = true
77
77
  }
78
78
  if (this.agent.lm.providerType == "ollama") {
79
79
  if (!this.def.inferParams?.extra) {
@@ -83,6 +83,10 @@ class Task {
83
83
  this.def.inferParams["extra"]["raw"] = true;
84
84
  }
85
85
  let answer;
86
+ if (options?.debug) {
87
+ // cut debug here. TODO: debug log levels
88
+ options.debug = false;
89
+ }
86
90
  if (!useTemplates) {
87
91
  if (this.def.template?.system) {
88
92
  options.system = this.def.template.system;
package/dist/variables.js CHANGED
@@ -11,9 +11,24 @@ function applyVariables(taskDef, taskInput) {
11
11
  }
12
12
  if (taskDef.variables?.optional) {
13
13
  for (const name of Object.keys(taskDef.variables.optional)) {
14
+ // cleanup unused optional variables
14
15
  if (!(name in taskInput)) {
15
16
  const v = taskDef.variables.optional[name]?.default ?? "";
16
17
  taskDef.prompt = taskDef.prompt.replaceAll(`{${name}}`, v);
18
+ if (taskDef.template?.system) {
19
+ taskDef.template.system = taskDef.template.system.replaceAll(`{${name}}`, v);
20
+ }
21
+ if (taskDef?.shots) {
22
+ const nshots = new Array();
23
+ taskDef.shots.forEach(s => {
24
+ let nshot = s;
25
+ if (s?.user) {
26
+ nshot.user = s.user.replaceAll(`{${name}}`, v);
27
+ }
28
+ nshots.push(nshot);
29
+ });
30
+ taskDef.shots = nshots;
31
+ }
17
32
  }
18
33
  }
19
34
  }
@@ -21,6 +36,20 @@ function applyVariables(taskDef, taskInput) {
21
36
  // apply variables
22
37
  for (const [k, v] of Object.entries(taskInput)) {
23
38
  taskDef.prompt = taskDef.prompt.replaceAll(`{${k}}`, v);
39
+ if (taskDef.template?.system) {
40
+ taskDef.template.system = taskDef.template.system.replaceAll(`{${k}}`, v);
41
+ }
42
+ if (taskDef?.shots) {
43
+ const nshots = new Array();
44
+ taskDef.shots.forEach(s => {
45
+ let nshot = s;
46
+ if (s?.user) {
47
+ nshot.user = s.user.replaceAll(`{${k}}`, v);
48
+ }
49
+ nshots.push(nshot);
50
+ });
51
+ taskDef.shots = nshots;
52
+ }
24
53
  }
25
54
  return taskDef;
26
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-smith/task",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "A toolkit to create human friendly agents: the language model tasks module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,23 +14,23 @@
14
14
  "docs": "typedoc --entryPointStrategy expand"
15
15
  },
16
16
  "dependencies": {
17
- "@agent-smith/agent": "^0.1.3",
17
+ "@agent-smith/agent": "^0.1.4",
18
18
  "@agent-smith/tfm": "^0.2.0",
19
- "modprompt": "^0.12.5",
20
- "yaml": "^2.8.1"
19
+ "modprompt": "^0.12.6",
20
+ "yaml": "^2.8.2"
21
21
  },
22
22
  "devDependencies": {
23
- "openai": "6.9.0",
24
- "@locallm/types": "^0.5.0",
23
+ "openai": "6.10.0",
24
+ "@locallm/types": "^0.6.2",
25
25
  "@rollup/plugin-node-resolve": "^16.0.3",
26
26
  "@rollup/plugin-terser": "^0.4.4",
27
27
  "@rollup/plugin-typescript": "^12.3.0",
28
- "@types/node": "^24.10.1",
28
+ "@types/node": "^24.10.2",
29
29
  "markdown-it-replace-link": "^1.2.2",
30
- "restmix": "^0.5.0",
31
- "rollup": "^4.53.2",
30
+ "restmix": "^0.6.1",
31
+ "rollup": "^4.53.3",
32
32
  "tslib": "^2.8.1",
33
- "typedoc": "^0.28.14",
33
+ "typedoc": "^0.28.15",
34
34
  "typedoc-plugin-markdown": "^4.9.0",
35
35
  "typedoc-plugin-rename-defaults": "^0.7.3",
36
36
  "typescript": "^5.9.3"