@agent-smith/cli 0.0.45 → 0.0.46
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/cmd/lib/tasks/cmd.js +15 -11
- package/dist/cmd/lib/tasks/conf.d.ts +3 -3
- package/dist/cmd/lib/tasks/conf.js +21 -15
- package/package.json +2 -1
|
@@ -8,7 +8,7 @@ import { readTask } from "../../sys/read_task.js";
|
|
|
8
8
|
import { readTool } from "../../../db/read.js";
|
|
9
9
|
import { executeActionCmd, } from "../actions/cmd.js";
|
|
10
10
|
import { executeWorkflowCmd } from "../workflows/cmd.js";
|
|
11
|
-
import {
|
|
11
|
+
import { configureTaskModel, parseTaskVars } from "./conf.js";
|
|
12
12
|
async function executeTaskCmd(args = [], options = {}) {
|
|
13
13
|
await initAgent();
|
|
14
14
|
if (isDebug.value) {
|
|
@@ -55,17 +55,17 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
55
55
|
throw new Error(`Task ${name}, ${path} not found`);
|
|
56
56
|
}
|
|
57
57
|
const taskFileSpec = YAML.parse(res.ymlTask);
|
|
58
|
-
let
|
|
58
|
+
let model;
|
|
59
59
|
let vars = {};
|
|
60
60
|
if (!isWorkflow) {
|
|
61
61
|
const tv = parseTaskVars(args, taskFileSpec?.inferParams ? taskFileSpec.inferParams : {});
|
|
62
62
|
vars = tv.vars;
|
|
63
|
-
|
|
63
|
+
model = configureTaskModel(tv.conf, taskFileSpec);
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
const tv = parseTaskVars({ name: name, prompt: pr, ...args }, taskFileSpec?.inferParams ? taskFileSpec.inferParams : {});
|
|
67
67
|
vars = tv.vars;
|
|
68
|
-
|
|
68
|
+
model = configureTaskModel(tv.conf, taskFileSpec);
|
|
69
69
|
}
|
|
70
70
|
const taskSpec = taskFileSpec;
|
|
71
71
|
if (taskSpec.toolsList) {
|
|
@@ -100,17 +100,17 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
100
100
|
}
|
|
101
101
|
;
|
|
102
102
|
const task = taskBuilder.init(taskSpec);
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
delete
|
|
103
|
+
if (model?.inferParams?.tsGrammar) {
|
|
104
|
+
model.inferParams.grammar = serializeGrammar(await compile(model.inferParams.tsGrammar, "Grammar"));
|
|
105
|
+
delete model.inferParams.tsGrammar;
|
|
106
106
|
}
|
|
107
107
|
if (isDebug.value) {
|
|
108
|
-
console.log("Task
|
|
108
|
+
console.log("Task model:", model);
|
|
109
109
|
console.log("Task vars:", vars);
|
|
110
110
|
}
|
|
111
|
-
const ex = brain.getOrCreateExpertForModel(
|
|
111
|
+
const ex = brain.getOrCreateExpertForModel(model.name, model.template);
|
|
112
112
|
if (!ex) {
|
|
113
|
-
throw new Error("No expert found for model " +
|
|
113
|
+
throw new Error("No expert found for model " + model.name);
|
|
114
114
|
}
|
|
115
115
|
ex.checkStatus();
|
|
116
116
|
let i = 0;
|
|
@@ -129,6 +129,11 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
129
129
|
c = !c;
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
+
const conf = {
|
|
133
|
+
expert: ex,
|
|
134
|
+
model: model,
|
|
135
|
+
debug: isDebug.value,
|
|
136
|
+
};
|
|
132
137
|
conf.expert = ex;
|
|
133
138
|
if (isDebug.value || isVerbose.value) {
|
|
134
139
|
conf.debug = true;
|
|
@@ -141,7 +146,6 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
141
146
|
catch (err) {
|
|
142
147
|
throw new Error(`Error executing task: ${name} ${err}`);
|
|
143
148
|
}
|
|
144
|
-
conf.prompt = pr;
|
|
145
149
|
if (isChatMode.value) {
|
|
146
150
|
if (brain.ex.name != ex.name) {
|
|
147
151
|
brain.setDefaultExpert(ex);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LmTaskConfig,
|
|
2
|
-
declare function
|
|
1
|
+
import { LmTaskConfig, LmTaskFileSpec, ModelSpec } from "../../../interfaces.js";
|
|
2
|
+
declare function configureTaskModel(itConf: LmTaskConfig, taskSpec: LmTaskFileSpec): ModelSpec;
|
|
3
3
|
declare function parseTaskVars(params: Array<any> | Record<string, any>, inferParams: Record<string, any>): {
|
|
4
4
|
conf: LmTaskConfig;
|
|
5
5
|
vars: Record<string, any>;
|
|
6
6
|
};
|
|
7
|
-
export { parseTaskVars,
|
|
7
|
+
export { parseTaskVars, configureTaskModel, };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { useTemplateForModel } from "@agent-smith/tfm";
|
|
1
2
|
import { readModel } from "../../../db/read.js";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
const tfm = useTemplateForModel();
|
|
4
|
+
function configureTaskModel(itConf, taskSpec) {
|
|
4
5
|
let modelName = "";
|
|
5
6
|
let templateName = "";
|
|
6
7
|
let ip = itConf.inferParams;
|
|
@@ -60,21 +61,26 @@ function configureTask(itConf, taskSpec) {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
if (found) {
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
_conf.model = model;
|
|
69
|
-
_conf.model.inferParams = ip;
|
|
70
|
-
if (templateName.length > 0) {
|
|
71
|
-
_conf.model.template = templateName;
|
|
64
|
+
if (!found) {
|
|
65
|
+
const gt = tfm.guess(modelName);
|
|
66
|
+
if (gt == "none") {
|
|
67
|
+
throw new Error(`Unable to guess the template for ${modelName}: please provide a template name: m="modelname/templatename"`);
|
|
72
68
|
}
|
|
69
|
+
const m = {
|
|
70
|
+
name: modelName,
|
|
71
|
+
template: gt
|
|
72
|
+
};
|
|
73
|
+
model = m;
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
model.inferParams = ip;
|
|
76
|
+
if (!model?.ctx || !isModelFromTaskFile) {
|
|
77
|
+
model.ctx = taskSpec.ctx;
|
|
78
|
+
}
|
|
79
|
+
model.inferParams = ip;
|
|
80
|
+
if (templateName.length > 0) {
|
|
81
|
+
model.template = templateName;
|
|
76
82
|
}
|
|
77
|
-
return
|
|
83
|
+
return model;
|
|
78
84
|
}
|
|
79
85
|
function parseTaskVars(params, inferParams) {
|
|
80
86
|
switch (Array.isArray(params)) {
|
|
@@ -141,4 +147,4 @@ function _initTaskVars(args, inferParams) {
|
|
|
141
147
|
});
|
|
142
148
|
return { conf, vars };
|
|
143
149
|
}
|
|
144
|
-
export { parseTaskVars,
|
|
150
|
+
export { parseTaskVars, configureTaskModel, };
|
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.46",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@agent-smith/brain": "^0.0.42",
|
|
14
14
|
"@agent-smith/jobs": "^0.0.14",
|
|
15
15
|
"@agent-smith/lmtask": "^0.0.37",
|
|
16
|
+
"@agent-smith/tfm": "^0.1.2",
|
|
16
17
|
"@inquirer/prompts": "^7.4.1",
|
|
17
18
|
"@inquirer/select": "^4.1.1",
|
|
18
19
|
"@vue/reactivity": "^3.5.13",
|