@agent-smith/task 0.1.7 → 0.1.9

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.
Files changed (2) hide show
  1. package/dist/task.js +14 -5
  2. package/package.json +7 -7
package/dist/task.js CHANGED
@@ -40,13 +40,18 @@ class Task {
40
40
  }
41
41
  this.def = applyVariables(this.def, params);
42
42
  let tpl = new PromptTemplate("none");
43
- let finalPrompt;
44
43
  const options = {};
44
+ if (conf?.onToolCall) {
45
+ options.onToolCall = conf.onToolCall;
46
+ }
47
+ if (conf?.onToolCallEnd) {
48
+ options.onToolCallEnd = conf.onToolCallEnd;
49
+ }
45
50
  const agentToolsList = Object.values(this.agent.tools);
46
51
  if (useTemplates) {
47
52
  tpl = formatTaskTemplate(this.def, model?.template ? model.template : undefined);
48
53
  this.def.inferParams = formatInferParams(this.def.inferParams ?? {}, conf ?? {}, tpl);
49
- tpl.replacePrompt(this.def.prompt);
54
+ //tpl.replacePrompt(this.def.prompt);
50
55
  if (agentToolsList.length > 0) {
51
56
  if (!tpl?.toolsDef) {
52
57
  throw new Error(`The template ${tpl.name} does not have tools and the task ${this.def.name} specifies some`);
@@ -54,12 +59,15 @@ class Task {
54
59
  agentToolsList.forEach((t) => tpl.addTool(t));
55
60
  }
56
61
  ;
57
- finalPrompt = tpl.prompt(params.prompt);
62
+ //finalPrompt = params.prompt;
58
63
  }
59
64
  else {
60
65
  this.def.inferParams = formatInferParams(this.def.inferParams ?? {}, conf ?? {});
61
- finalPrompt = this.def.prompt.replace("{prompt}", params.prompt);
62
66
  }
67
+ //console.log("DEF", this.def);
68
+ //console.log("P", params.prompt);
69
+ const finalPrompt = this.def.prompt.replace("{prompt}", params.prompt);
70
+ //console.log("FP", finalPrompt);
63
71
  // model
64
72
  if (model) {
65
73
  this.def.inferParams.model = model;
@@ -69,7 +77,7 @@ class Task {
69
77
  }
70
78
  if (conf?.debug) {
71
79
  console.log("-----------", model.name, "- Template:", tpl.name, "- Ctx:", ctx, "-----------");
72
- console.log(finalPrompt);
80
+ console.log(useTemplates ? tpl.prompt(finalPrompt) : finalPrompt);
73
81
  console.log("----------------------------------------------");
74
82
  console.log("Infer params:", this.def.inferParams);
75
83
  console.log("----------------------------------------------");
@@ -104,6 +112,7 @@ class Task {
104
112
  answer = await this.agent.run(finalPrompt, this.def.inferParams, options, tpl);
105
113
  tpl.history = this.agent.history;
106
114
  //console.log("RAW ANSWER", answer);
115
+ //console.log("\nHISTORY", this.agent.history);
107
116
  }
108
117
  //console.log("TASK: ANSWER FINAL:", { answer: answer.result, errors: {}, template: answer.template })
109
118
  return { answer, template: tpl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-smith/task",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "A toolkit to create human friendly agents: the language model tasks module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,22 +14,22 @@
14
14
  "docs": "typedoc --entryPointStrategy expand"
15
15
  },
16
16
  "dependencies": {
17
- "@agent-smith/agent": "^0.1.5",
17
+ "@agent-smith/agent": "^0.1.8",
18
18
  "@agent-smith/tfm": "^0.2.0",
19
19
  "modprompt": "^0.12.6",
20
20
  "yaml": "^2.8.2"
21
21
  },
22
22
  "devDependencies": {
23
- "@locallm/api": "^0.7.2",
24
- "openai": "6.10.0",
25
- "@locallm/types": "^0.6.4",
23
+ "@locallm/api": "^0.7.3",
24
+ "openai": "6.15.0",
25
+ "@locallm/types": "^0.6.5",
26
26
  "@rollup/plugin-node-resolve": "^16.0.3",
27
27
  "@rollup/plugin-terser": "^0.4.4",
28
28
  "@rollup/plugin-typescript": "^12.3.0",
29
- "@types/node": "^25.0.1",
29
+ "@types/node": "^25.0.3",
30
30
  "markdown-it-replace-link": "^1.2.2",
31
31
  "restmix": "^0.6.1",
32
- "rollup": "^4.53.3",
32
+ "rollup": "^4.54.0",
33
33
  "tslib": "^2.8.1",
34
34
  "typedoc": "^0.28.15",
35
35
  "typedoc-plugin-markdown": "^4.9.0",