@agent-smith/task 0.2.4 → 0.3.0
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/interfaces.d.ts +6 -1
- package/dist/task.js +21 -2
- package/package.json +9 -9
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InferenceParams, InferenceResult, InferenceOptions, ToolSpec, HistoryTurn, ToolCallSpec } from "@locallm/types";
|
|
1
|
+
import type { InferenceParams, InferenceResult, InferenceOptions, ToolSpec, HistoryTurn, ToolCallSpec, ToolTurn } from "@locallm/types";
|
|
2
2
|
import type { PromptTemplate } from "modprompt";
|
|
3
3
|
interface ModelSpec {
|
|
4
4
|
name: string;
|
|
@@ -35,8 +35,13 @@ interface TaskConf {
|
|
|
35
35
|
debug?: boolean;
|
|
36
36
|
verbose?: boolean;
|
|
37
37
|
baseDir?: string;
|
|
38
|
+
history?: Array<HistoryTurn>;
|
|
38
39
|
onToolCall?: (tc: ToolCallSpec) => void;
|
|
39
40
|
onToolCallEnd?: (tr: any) => void;
|
|
41
|
+
onToolsTurnStart?: (tc: Array<ToolCallSpec>) => void;
|
|
42
|
+
onToolsTurnEnd?: (tr: Array<ToolTurn>) => void;
|
|
43
|
+
onTurnEnd?: (ht: HistoryTurn) => void;
|
|
44
|
+
onAssistant?: (txt: string) => void;
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
47
|
* Represents a template specification for a language model task.
|
package/dist/task.js
CHANGED
|
@@ -48,6 +48,18 @@ class Task {
|
|
|
48
48
|
if (conf?.onToolCallEnd) {
|
|
49
49
|
options.onToolCallEnd = conf.onToolCallEnd;
|
|
50
50
|
}
|
|
51
|
+
if (conf?.onToolsTurnStart) {
|
|
52
|
+
options.onToolsTurnStart = conf.onToolsTurnStart;
|
|
53
|
+
}
|
|
54
|
+
if (conf?.onToolsTurnEnd) {
|
|
55
|
+
options.onToolsTurnEnd = conf.onToolsTurnEnd;
|
|
56
|
+
}
|
|
57
|
+
if (conf?.onTurnEnd) {
|
|
58
|
+
options.onTurnEnd = conf.onTurnEnd;
|
|
59
|
+
}
|
|
60
|
+
if (conf?.onAssistant) {
|
|
61
|
+
options.onAssistant = conf.onAssistant;
|
|
62
|
+
}
|
|
51
63
|
let hasTools = false;
|
|
52
64
|
// add task tools to the agent
|
|
53
65
|
if (this.def?.tools) {
|
|
@@ -87,6 +99,13 @@ class Task {
|
|
|
87
99
|
options.tools = this.def.tools;
|
|
88
100
|
}
|
|
89
101
|
if (conf?.debug) {
|
|
102
|
+
if (this.agent?.history) {
|
|
103
|
+
this.agent.history.forEach(t => {
|
|
104
|
+
if (t?.assistant || t?.tools) {
|
|
105
|
+
tpl.pushToHistory(t);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
90
109
|
console.log("-----------", model.name, "- Template:", tpl.name, "- Ctx:", ctx, "-----------");
|
|
91
110
|
console.log(useTemplates ? tpl.prompt(finalPrompt) : finalPrompt);
|
|
92
111
|
console.log("----------------------------------------------");
|
|
@@ -106,7 +125,7 @@ class Task {
|
|
|
106
125
|
// cut debug here. TODO: debug log levels
|
|
107
126
|
options.debug = false;
|
|
108
127
|
}
|
|
109
|
-
const isRoutingAgent = this.def
|
|
128
|
+
const isRoutingAgent = this.def?.description?.includes("routing agent") ?? false;
|
|
110
129
|
if (isRoutingAgent) {
|
|
111
130
|
options.isToolsRouter = true;
|
|
112
131
|
}
|
|
@@ -115,7 +134,7 @@ class Task {
|
|
|
115
134
|
options.system = this.def.template.system;
|
|
116
135
|
}
|
|
117
136
|
if (this.def?.shots) {
|
|
118
|
-
options.history = this.def.shots;
|
|
137
|
+
options.history = options?.history ? [...options.history, ...this.def.shots] : this.def.shots;
|
|
119
138
|
}
|
|
120
139
|
//console.log("RUN AGENT (TASK) params:", this.def.inferParams);
|
|
121
140
|
//console.log("RUN AGENT (TASK) options:", options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-smith/task",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A toolkit to create human friendly agents: the language model tasks module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,25 +14,25 @@
|
|
|
14
14
|
"docs": "typedoc --entryPointStrategy expand"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@agent-smith/agent": "^0.
|
|
17
|
+
"@agent-smith/agent": "^0.3.0",
|
|
18
18
|
"@agent-smith/tfm": "^0.2.0",
|
|
19
|
-
"modprompt": "0.
|
|
19
|
+
"modprompt": "^0.14.0",
|
|
20
20
|
"yaml": "^2.8.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@locallm/api": "^0.7.3",
|
|
24
|
-
"openai": "6.
|
|
25
|
-
"@locallm/types": "^0.
|
|
24
|
+
"openai": "6.22.0",
|
|
25
|
+
"@locallm/types": "^0.7.0",
|
|
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
|
|
29
|
+
"@types/node": "^25.3.0",
|
|
30
30
|
"markdown-it-replace-link": "^1.2.2",
|
|
31
31
|
"restmix": "^0.6.1",
|
|
32
|
-
"rollup": "^4.
|
|
32
|
+
"rollup": "^4.59.0",
|
|
33
33
|
"tslib": "^2.8.1",
|
|
34
|
-
"typedoc": "^0.28.
|
|
35
|
-
"typedoc-plugin-markdown": "^4.
|
|
34
|
+
"typedoc": "^0.28.17",
|
|
35
|
+
"typedoc-plugin-markdown": "^4.10.0",
|
|
36
36
|
"typedoc-plugin-rename-defaults": "^0.7.3",
|
|
37
37
|
"typescript": "^5.9.3"
|
|
38
38
|
},
|