@agent-smith/agent 0.1.5 → 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/agent.js +13 -8
- package/package.json +6 -6
package/dist/agent.js
CHANGED
|
@@ -13,6 +13,10 @@ class Agent {
|
|
|
13
13
|
console.log("Agent inference params:", params);
|
|
14
14
|
console.log("Agent options:", options);
|
|
15
15
|
}
|
|
16
|
+
if (options?.history) {
|
|
17
|
+
this.history = options.history;
|
|
18
|
+
options.history = undefined;
|
|
19
|
+
}
|
|
16
20
|
if (this.lm.providerType == "openai") {
|
|
17
21
|
this.tools = {};
|
|
18
22
|
if (options?.tools) {
|
|
@@ -52,6 +56,7 @@ class Agent {
|
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
async runAgentNoTemplate(it, prompt, params, options = {}) {
|
|
59
|
+
options.history = this.history;
|
|
55
60
|
const res = await this.lm.infer(prompt, params, options);
|
|
56
61
|
this.history.push({ user: prompt });
|
|
57
62
|
let _res = res;
|
|
@@ -89,7 +94,6 @@ class Agent {
|
|
|
89
94
|
options.debug = false;
|
|
90
95
|
options.verbose = true;
|
|
91
96
|
}
|
|
92
|
-
options.history = this.history;
|
|
93
97
|
_res = await this.runAgentNoTemplate(nit, " ", params, options);
|
|
94
98
|
}
|
|
95
99
|
else {
|
|
@@ -104,7 +108,9 @@ class Agent {
|
|
|
104
108
|
}
|
|
105
109
|
await this.lm.loadModel(params.model.name, params.model.ctx);
|
|
106
110
|
}
|
|
107
|
-
|
|
111
|
+
tpl.history = this.history;
|
|
112
|
+
const pr = tpl.prompt(prompt);
|
|
113
|
+
let res = await this.lm.infer(pr, params, options);
|
|
108
114
|
if (typeof params?.model == "string") {
|
|
109
115
|
params.model = { name: params.model };
|
|
110
116
|
}
|
|
@@ -139,14 +145,14 @@ class Agent {
|
|
|
139
145
|
});
|
|
140
146
|
}
|
|
141
147
|
if (it == 1) {
|
|
142
|
-
|
|
143
|
-
user: prompt
|
|
148
|
+
this.history.push({
|
|
149
|
+
user: prompt,
|
|
144
150
|
assistant: res.text,
|
|
145
151
|
tools: toolResults,
|
|
146
152
|
});
|
|
147
153
|
}
|
|
148
154
|
else {
|
|
149
|
-
|
|
155
|
+
this.history.push({
|
|
150
156
|
assistant: res.text,
|
|
151
157
|
tools: toolResults,
|
|
152
158
|
});
|
|
@@ -168,7 +174,7 @@ class Agent {
|
|
|
168
174
|
}
|
|
169
175
|
turn.user = prompt.replace("{prompt}", prompt);
|
|
170
176
|
turn.assistant = final;
|
|
171
|
-
|
|
177
|
+
this.history.push(turn);
|
|
172
178
|
}
|
|
173
179
|
else {
|
|
174
180
|
const turn = {};
|
|
@@ -176,9 +182,8 @@ class Agent {
|
|
|
176
182
|
turn.think = thinking;
|
|
177
183
|
}
|
|
178
184
|
turn.assistant = final;
|
|
179
|
-
|
|
185
|
+
this.history.push(turn);
|
|
180
186
|
}
|
|
181
|
-
this.history = tpl.history;
|
|
182
187
|
return res;
|
|
183
188
|
}
|
|
184
189
|
}
|
package/package.json
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/synw/agent-smith.git"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.6",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
11
11
|
"build": "rm -rf dist/* && tsc"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@locallm/api": "^0.7.
|
|
14
|
+
"@locallm/api": "^0.7.3",
|
|
15
15
|
"modprompt": "^0.12.6",
|
|
16
16
|
"restmix": "^0.6.1"
|
|
17
17
|
},
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"@locallm/types": "^0.6.4",
|
|
20
20
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
21
21
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
22
|
-
"@types/node": "^25.0.
|
|
23
|
-
"openai": "^6.
|
|
24
|
-
"rollup": "^4.
|
|
22
|
+
"@types/node": "^25.0.3",
|
|
23
|
+
"openai": "^6.15.0",
|
|
24
|
+
"rollup": "^4.54.0",
|
|
25
25
|
"ts-node": "^10.9.2",
|
|
26
26
|
"tslib": "2.8.1",
|
|
27
27
|
"typescript": "^5.9.3"
|
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
"registry": "https://registry.npmjs.org/"
|
|
42
42
|
},
|
|
43
43
|
"license": "MIT"
|
|
44
|
-
}
|
|
44
|
+
}
|