@agent-smith/agent 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/agent.js +20 -15
- package/package.json +7 -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
|
});
|
|
@@ -162,23 +168,22 @@ class Agent {
|
|
|
162
168
|
final = finalAnswer;
|
|
163
169
|
}
|
|
164
170
|
if (it == 1) {
|
|
171
|
+
const turn = {};
|
|
165
172
|
if (thinking.length > 0) {
|
|
166
|
-
|
|
173
|
+
turn.think = thinking;
|
|
167
174
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
175
|
+
turn.user = prompt.replace("{prompt}", prompt);
|
|
176
|
+
turn.assistant = final;
|
|
177
|
+
this.history.push(turn);
|
|
172
178
|
}
|
|
173
179
|
else {
|
|
180
|
+
const turn = {};
|
|
174
181
|
if (thinking.length > 0) {
|
|
175
|
-
|
|
182
|
+
turn.think = thinking;
|
|
176
183
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
184
|
+
turn.assistant = final;
|
|
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,22 +5,23 @@
|
|
|
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.
|
|
15
|
-
"modprompt": "^0.12.
|
|
14
|
+
"@locallm/api": "^0.7.3",
|
|
15
|
+
"modprompt": "^0.12.6",
|
|
16
16
|
"restmix": "^0.6.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@locallm/types": "^0.6.
|
|
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": "^
|
|
23
|
-
"
|
|
22
|
+
"@types/node": "^25.0.3",
|
|
23
|
+
"openai": "^6.15.0",
|
|
24
|
+
"rollup": "^4.54.0",
|
|
24
25
|
"ts-node": "^10.9.2",
|
|
25
26
|
"tslib": "2.8.1",
|
|
26
27
|
"typescript": "^5.9.3"
|