@agent-smith/cli 0.0.23 → 0.0.25
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.d.ts +1 -1
- package/dist/agent.js +1 -1
- package/dist/cmd/lib/execute_job.js +8 -6
- package/dist/cmd/lib/execute_task.js +35 -7
- package/dist/cmd/lib/utils.d.ts +1 -1
- package/dist/cmd/lib/utils.js +6 -5
- package/package.json +1 -1
package/dist/agent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LmTaskBuilder } from "
|
|
1
|
+
import { LmTaskBuilder } from "../../lmtask/dist/task.js";
|
|
2
2
|
import { marked } from 'marked';
|
|
3
3
|
import { FeatureType } from "./interfaces.js";
|
|
4
4
|
declare let brain: import("@agent-smith/brain").AgentBrain<Record<string, any>>;
|
package/dist/agent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAgentBrain } from "@agent-smith/brain";
|
|
2
|
-
import { LmTaskBuilder } from "
|
|
2
|
+
import { LmTaskBuilder } from "../../lmtask/dist/task.js";
|
|
3
3
|
import { marked } from 'marked';
|
|
4
4
|
import { markedTerminal } from "marked-terminal";
|
|
5
5
|
marked.use(markedTerminal());
|
|
@@ -18,11 +18,6 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
18
18
|
let i = 0;
|
|
19
19
|
for (const [name, task] of Object.entries(job.tasks)) {
|
|
20
20
|
if (task.type == "task") {
|
|
21
|
-
let conf = {};
|
|
22
|
-
let vars = {};
|
|
23
|
-
const tv = initTaskVars(args);
|
|
24
|
-
conf = tv.conf;
|
|
25
|
-
vars = i == 0 ? tv.vars : params;
|
|
26
21
|
const { found, path } = getFeatureSpec(name, "task");
|
|
27
22
|
if (!found) {
|
|
28
23
|
return { ok: false, data: {}, error: `Task ${name} not found` };
|
|
@@ -33,7 +28,14 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
33
28
|
}
|
|
34
29
|
const taskSpec = taskBuilder.readFromYaml(tres.ymlTask);
|
|
35
30
|
let m = taskSpec.model.name;
|
|
36
|
-
let t = taskSpec.template
|
|
31
|
+
let t = taskSpec.model.template;
|
|
32
|
+
let conf = {};
|
|
33
|
+
let vars = {};
|
|
34
|
+
const tv = initTaskVars(args, taskSpec?.inferParams ? taskSpec.inferParams : {});
|
|
35
|
+
console.log("TIP", taskSpec.inferParams);
|
|
36
|
+
console.log("IP", tv.conf.inferParams);
|
|
37
|
+
conf = tv.conf;
|
|
38
|
+
vars = i == 0 ? tv.vars : params;
|
|
37
39
|
if (conf?.model) {
|
|
38
40
|
m = conf.model;
|
|
39
41
|
}
|
|
@@ -2,6 +2,8 @@ import { brain, initAgent, taskBuilder } from "../../agent.js";
|
|
|
2
2
|
import { getFeatureSpec } from "../../state/features.js";
|
|
3
3
|
import { isChatMode, isDebug } from "../../state/state.js";
|
|
4
4
|
import { initTaskVars, parseInputOptions, readTask } from "./utils.js";
|
|
5
|
+
import { useTemplateForModel } from "@agent-smith/tfm";
|
|
6
|
+
const tfm = useTemplateForModel();
|
|
5
7
|
async function executeTaskCmd(args = [], options = {}) {
|
|
6
8
|
await initAgent();
|
|
7
9
|
if (isDebug.value) {
|
|
@@ -30,18 +32,47 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
30
32
|
}
|
|
31
33
|
const taskSpec = taskBuilder.readFromYaml(res.ymlTask);
|
|
32
34
|
const task = taskBuilder.fromYaml(res.ymlTask);
|
|
33
|
-
const { conf, vars } = initTaskVars(args);
|
|
35
|
+
const { conf, vars } = initTaskVars(args, taskSpec?.inferParams ? taskSpec.inferParams : {});
|
|
34
36
|
if (isDebug.value) {
|
|
35
37
|
console.log("Task conf:", conf);
|
|
36
38
|
console.log("Task vars:", vars);
|
|
37
39
|
}
|
|
38
40
|
let m = taskSpec.model.name;
|
|
39
|
-
let t = taskSpec.template
|
|
41
|
+
let t = taskSpec.model.template;
|
|
42
|
+
let c = taskSpec.model.ctx;
|
|
40
43
|
if (conf?.model) {
|
|
41
44
|
m = conf.model;
|
|
45
|
+
if (conf?.template) {
|
|
46
|
+
t = conf.template;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const gt = tfm.guess(m);
|
|
50
|
+
if (gt == "none") {
|
|
51
|
+
throw new Error(`Unable to guess the template for ${conf.model}: please provide a template name"`);
|
|
52
|
+
}
|
|
53
|
+
t = gt;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
if (conf?.size) {
|
|
58
|
+
if (!taskSpec?.models) {
|
|
59
|
+
throw new Error(`Model ${conf.size} not found in task`);
|
|
60
|
+
}
|
|
61
|
+
if (!Object.keys(taskSpec.models).includes(conf.size)) {
|
|
62
|
+
throw new Error(`Model ${conf.size} not found in task`);
|
|
63
|
+
}
|
|
64
|
+
m = taskSpec.models[conf.size].name;
|
|
65
|
+
t = taskSpec.models[conf.size].template;
|
|
66
|
+
c = taskSpec.models[conf.size].ctx;
|
|
67
|
+
}
|
|
42
68
|
}
|
|
43
|
-
|
|
44
|
-
|
|
69
|
+
conf.model = {
|
|
70
|
+
name: m,
|
|
71
|
+
template: t,
|
|
72
|
+
ctx: c,
|
|
73
|
+
};
|
|
74
|
+
if (isDebug.value) {
|
|
75
|
+
console.log("Model:", conf.model);
|
|
45
76
|
}
|
|
46
77
|
const ex = brain.getOrCreateExpertForModel(m, t);
|
|
47
78
|
if (!ex) {
|
|
@@ -62,9 +93,6 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
62
93
|
if (isDebug.value) {
|
|
63
94
|
conf.debug = true;
|
|
64
95
|
}
|
|
65
|
-
if (isDebug.value) {
|
|
66
|
-
console.log("Vars", vars);
|
|
67
|
-
}
|
|
68
96
|
const data = await task.run({ prompt: pr, ...vars }, conf);
|
|
69
97
|
if (data?.error) {
|
|
70
98
|
return { ok: false, data: "", conf: conf, error: `Error executing task: ${data.error}` };
|
package/dist/cmd/lib/utils.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare function readTask(taskpath: string): {
|
|
|
6
6
|
ymlTask: string;
|
|
7
7
|
};
|
|
8
8
|
declare function readTasksDir(dir: string): Array<string>;
|
|
9
|
-
declare function initTaskVars(args: Array<any>): {
|
|
9
|
+
declare function initTaskVars(args: Array<any>, inferParams: Record<string, any>): {
|
|
10
10
|
conf: Record<string, any>;
|
|
11
11
|
vars: Record<string, any>;
|
|
12
12
|
};
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -73,8 +73,8 @@ function readTasksDir(dir) {
|
|
|
73
73
|
});
|
|
74
74
|
return tasks;
|
|
75
75
|
}
|
|
76
|
-
function initTaskVars(args) {
|
|
77
|
-
const conf = {};
|
|
76
|
+
function initTaskVars(args, inferParams) {
|
|
77
|
+
const conf = { inferParams: inferParams };
|
|
78
78
|
const vars = {};
|
|
79
79
|
args.forEach((a) => {
|
|
80
80
|
if (a.includes("=")) {
|
|
@@ -92,12 +92,13 @@ function initTaskVars(args) {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
else if (k == "ip") {
|
|
95
|
-
const ip = {};
|
|
96
95
|
v.split(",").forEach((p) => {
|
|
97
96
|
const s = p.split(":");
|
|
98
|
-
|
|
97
|
+
conf["inferParams"][s[0]] = parseFloat(s[1]);
|
|
99
98
|
});
|
|
100
|
-
|
|
99
|
+
}
|
|
100
|
+
else if (k == "s") {
|
|
101
|
+
conf.size = v;
|
|
101
102
|
}
|
|
102
103
|
else {
|
|
103
104
|
vars[k] = v;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@agent-smith/cli",
|
|
3
3
|
"description": "Agent Smith: terminal client for language model agents",
|
|
4
4
|
"repository": "https://github.com/synw/agent-smith",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.25",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|