@agent-smith/cli 0.0.95 → 0.0.97

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.
@@ -9,17 +9,12 @@ import { pythonAction, systemAction } from '../actions/cmd.js';
9
9
  import { createJsAction } from '../actions/read.js';
10
10
  import { pathToFileURL } from 'url';
11
11
  async function _createWorkflowFromSpec(spec) {
12
- const steps = {};
12
+ const steps = [];
13
+ let i = 1;
13
14
  for (const step of spec.steps) {
14
15
  const type = Object.keys(step)[0];
15
16
  const sval = step[type];
16
- let name;
17
- if (typeof sval == "string") {
18
- name = sval;
19
- }
20
- else {
21
- name = step[type].name;
22
- }
17
+ const name = sval;
23
18
  if (type == "action") {
24
19
  const { found, path, ext } = getFeatureSpec(name, "action");
25
20
  if (!found) {
@@ -31,36 +26,40 @@ async function _createWorkflowFromSpec(spec) {
31
26
  const { action } = await import(url);
32
27
  const at = action;
33
28
  const wf = {
29
+ name: name,
34
30
  type: "action",
35
31
  run: at,
36
32
  };
37
- steps[name] = wf;
33
+ steps.push(wf);
38
34
  break;
39
35
  case "mjs":
40
36
  const url2 = pathToFileURL(path).href;
41
37
  const mjsa = await import(url2);
42
38
  const act = createJsAction(mjsa.action);
43
39
  const wf2 = {
40
+ name: name,
44
41
  type: "action",
45
42
  run: act,
46
43
  };
47
- steps[name] = wf2;
44
+ steps.push(wf2);
48
45
  break;
49
46
  case "yml":
50
47
  const _t1 = systemAction(path);
51
48
  const wf3 = {
49
+ name: name,
52
50
  type: "action",
53
51
  run: _t1,
54
52
  };
55
- steps[name] = wf3;
53
+ steps.push(wf3);
56
54
  break;
57
55
  case "py":
58
56
  const _t = pythonAction(path);
59
57
  const wf4 = {
58
+ name: name,
60
59
  type: "action",
61
60
  run: _t,
62
61
  };
63
- steps[name] = wf4;
62
+ steps.push(wf4);
64
63
  break;
65
64
  default:
66
65
  throw new Error(`Unknown feature extension ${ext}`);
@@ -75,10 +74,11 @@ async function _createWorkflowFromSpec(spec) {
75
74
  const jsa = await import(url);
76
75
  const act = createJsAction(jsa.action);
77
76
  const wf = {
77
+ name: name,
78
78
  type: "adaptater",
79
79
  run: act,
80
80
  };
81
- steps[name] = wf;
81
+ steps.push(wf);
82
82
  }
83
83
  else {
84
84
  const { found, path } = getFeatureSpec(name, "task");
@@ -92,11 +92,13 @@ async function _createWorkflowFromSpec(spec) {
92
92
  const agent = new Agent(backend.value);
93
93
  const tsk = Task.fromYaml(agent, res.ymlTask);
94
94
  const wf = {
95
+ name: name,
95
96
  type: "task",
96
97
  run: tsk.run,
97
98
  };
98
- steps[name] = wf;
99
+ steps.push(wf);
99
100
  }
101
+ ++i;
100
102
  }
101
103
  return steps;
102
104
  }
@@ -116,16 +118,16 @@ async function _readWorkflowFromDisk(name) {
116
118
  async function readWorkflow(name) {
117
119
  const { found, ext } = getFeatureSpec(name, "workflow");
118
120
  if (!found) {
119
- return { found: false, workflow: {} };
121
+ return { found: false, workflow: [] };
120
122
  }
121
- let wf = {};
123
+ let wf = new Array();
122
124
  switch (ext) {
123
125
  case "yml":
124
126
  const { data } = await _readWorkflowFromDisk(name);
125
127
  try {
126
128
  const workflow = await _createWorkflowFromSpec(data);
127
129
  if (!found) {
128
- return { found: false, workflow: {} };
130
+ return { found: false, workflow: [] };
129
131
  }
130
132
  wf = workflow;
131
133
  }
@@ -22,7 +22,6 @@ function readFeaturesDir(dir) {
22
22
  cmd: [],
23
23
  workflow: [],
24
24
  adaptater: [],
25
- modelfile: []
26
25
  };
27
26
  let dirpath = path.join(dir, "tasks");
28
27
  if (fs.existsSync(dirpath)) {
@@ -94,20 +93,6 @@ function readFeaturesDir(dir) {
94
93
  });
95
94
  });
96
95
  }
97
- dirpath = path.join(dir, "models");
98
- if (fs.existsSync(dirpath)) {
99
- const data = _readDir(dirpath, [".yml"]);
100
- data.forEach((filename) => {
101
- const parts = filename.split(".");
102
- const ext = parts.pop();
103
- const name = parts.join("");
104
- feats.modelfile.push({
105
- name: name,
106
- path: path.join(dirpath),
107
- ext: ext,
108
- });
109
- });
110
- }
111
96
  return feats;
112
97
  }
113
98
  export { readFeaturesDir };
package/dist/conf.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { readConf } from "./cmd/sys/read_conf.js";
2
- import { upsertBackends, insertFeaturesPathIfNotExists, insertPluginIfNotExists } from "./db/write.js";
2
+ import { upsertBackends, insertFeaturesPathIfNotExists, insertPluginIfNotExists, upsertTaskSettings, deleteTaskSettings } from "./db/write.js";
3
3
  import { buildPluginsPaths } from "./state/plugins.js";
4
4
  import { runtimeError } from "./cmd/lib/user_msgs.js";
5
5
  import { localBackends } from "./const.js";
6
6
  import { homedir } from 'os';
7
7
  import { join } from 'path';
8
8
  import { createDirectoryIfNotExists } from "./cmd/sys/dirs.js";
9
+ import { initTaskSettings, tasksSettings } from "./state/tasks.js";
9
10
  function getConfigPath(appName, filename) {
10
11
  let confDir;
11
12
  let dbPath;
@@ -93,6 +94,16 @@ async function processConfPath(confPath) {
93
94
  insertPluginIfNotExists(_pl.name, _pl.path);
94
95
  });
95
96
  }
97
+ if (data?.tasks) {
98
+ initTaskSettings();
99
+ const okTasks = new Array();
100
+ for (const [name, settings] of Object.entries(data.tasks)) {
101
+ upsertTaskSettings(name, settings);
102
+ okTasks.push(name);
103
+ }
104
+ const toDel = Object.keys(tasksSettings).filter(t => !okTasks.includes(t));
105
+ deleteTaskSettings(toDel);
106
+ }
96
107
  let pf = "";
97
108
  if (data?.promptfile) {
98
109
  pf = data.promptfile;
package/dist/db/read.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ToolSpec } from "@locallm/types";
2
- import { AliasType, FeatureSpec, FeatureType, DbModelDef, ToolType, InferenceBackend } from "../interfaces.js";
2
+ import { AliasType, FeatureSpec, FeatureType, ToolType, InferenceBackend } from "../interfaces.js";
3
3
  declare function readFeaturePaths(): Array<string>;
4
4
  declare function readBackends(): Record<string, InferenceBackend>;
5
5
  declare function readPlugins(): Array<Record<string, string>>;
@@ -26,10 +26,9 @@ declare function readFilePath(name: string): {
26
26
  found: boolean;
27
27
  path: string;
28
28
  };
29
- declare function readModelfiles(): Array<Record<string, string>>;
30
- declare function readModels(): Array<DbModelDef>;
31
- declare function readModel(shortname: string): {
29
+ declare function readTaskSettings(): Array<Record<string, any>>;
30
+ declare function readTaskSetting(name: string): {
32
31
  found: boolean;
33
- modelData: Record<string, any>;
32
+ settings: Record<string, string>;
34
33
  };
35
- export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePath, readFilePaths, readTool, readModels, readModelfiles, readModel, readFeaturesType, readBackends, };
34
+ export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePath, readFilePaths, readTool, readFeaturesType, readBackends, readTaskSettings, readTaskSetting, };
package/dist/db/read.js CHANGED
@@ -43,14 +43,13 @@ function readFeaturesType(type) {
43
43
  }
44
44
  function readFeatures() {
45
45
  const feats = {
46
- task: {}, action: {}, cmd: {}, workflow: {}, adaptater: {}, modelfile: {}
46
+ task: {}, action: {}, cmd: {}, workflow: {}, adaptater: {}
47
47
  };
48
48
  feats.task = readFeaturesType("task");
49
49
  feats.action = readFeaturesType("action");
50
50
  feats.cmd = readFeaturesType("cmd");
51
51
  feats.workflow = readFeaturesType("workflow");
52
52
  feats.adaptater = readFeaturesType("adaptater");
53
- feats.modelfile = readFeaturesType("modelfile");
54
53
  return feats;
55
54
  }
56
55
  function readAliases() {
@@ -110,38 +109,18 @@ function readFilePath(name) {
110
109
  }
111
110
  return { found: false, path: "" };
112
111
  }
113
- function readModelfiles() {
114
- const stmt = db.prepare("SELECT name, path, ext FROM modelfile");
115
- const data = stmt.all();
116
- let f = new Array();
117
- data.forEach((row) => {
118
- f.push(row);
119
- });
120
- return f;
121
- }
122
- function readModels() {
123
- const stmt = db.prepare("SELECT name, shortname, data FROM model");
124
- const data = stmt.all();
125
- let f = new Array();
126
- data.forEach((row) => {
127
- const ips = JSON.parse(row.data);
128
- const mod = {
129
- name: row.name,
130
- shortname: row.shortname,
131
- data: ips,
132
- };
133
- f.push(mod);
134
- });
135
- return f;
112
+ function readTaskSettings() {
113
+ const stmt1 = db.prepare("SELECT * FROM tasksettings ORDER BY name");
114
+ const data = stmt1.all();
115
+ return data;
136
116
  }
137
- function readModel(shortname) {
138
- const q = `SELECT id, data FROM model WHERE shortname='${shortname}'`;
117
+ function readTaskSetting(name) {
118
+ const q = "SELECT * FROM tasksettings WHERE name= ?";
139
119
  const stmt = db.prepare(q);
140
- const result = stmt.get();
120
+ const result = stmt.get(name);
141
121
  if (result?.id) {
142
- const data = JSON.parse(result.data);
143
- return { found: true, modelData: data };
122
+ return { found: true, settings: result };
144
123
  }
145
- return { found: false, modelData: {} };
124
+ return { found: false, settings: {} };
146
125
  }
147
- export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePath, readFilePaths, readTool, readModels, readModelfiles, readModel, readFeaturesType, readBackends, };
126
+ export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePath, readFilePaths, readTool, readFeaturesType, readBackends, readTaskSettings, readTaskSetting, };
@@ -58,19 +58,6 @@ const alias = `CREATE TABLE IF NOT EXISTS aliases (
58
58
  name TEXT UNIQUE NOT NULL,
59
59
  type TEXT NOT NULL CHECK ( type IN ('task', 'action', 'workflow') )
60
60
  );`;
61
- const modelfile = `CREATE TABLE IF NOT EXISTS modelfile (
62
- id INTEGER PRIMARY KEY AUTOINCREMENT,
63
- name TEXT UNIQUE NOT NULL,
64
- path TEXT NOT NULL,
65
- variables TEXT,
66
- ext TEXT NOT NULL CHECK ( ext IN ('yml') )
67
- );`;
68
- const model = `CREATE TABLE IF NOT EXISTS model (
69
- id INTEGER PRIMARY KEY AUTOINCREMENT,
70
- name TEXT NOT NULL,
71
- shortname TEXT UNIQUE NOT NULL,
72
- data TEXT NOT NULL
73
- );`;
74
61
  const backend = `CREATE TABLE IF NOT EXISTS backend (
75
62
  id INTEGER PRIMARY KEY AUTOINCREMENT,
76
63
  name TEXT UNIQUE NOT NULL,
@@ -79,6 +66,20 @@ const backend = `CREATE TABLE IF NOT EXISTS backend (
79
66
  isdefault INTEGER NOT NULL,
80
67
  apiKey TEXT
81
68
  );`;
69
+ const tasksSettings = `CREATE TABLE IF NOT EXISTS tasksettings (
70
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
71
+ name TEXT UNIQUE NOT NULL,
72
+ model TEXT,
73
+ template TEXT,
74
+ ctx INTEGER,
75
+ maxtokens INTEGER
76
+ topk INTEGER,
77
+ topp REAL,
78
+ minp REAL,
79
+ temperature REAL,
80
+ repeat REAL,
81
+ backend TEXT
82
+ );`;
82
83
  const schemas = [
83
84
  filepath,
84
85
  featurespath,
@@ -89,9 +90,8 @@ const schemas = [
89
90
  cmd,
90
91
  plugin,
91
92
  alias,
92
- model,
93
- modelfile,
94
93
  adaptater,
95
94
  backend,
95
+ tasksSettings,
96
96
  ];
97
97
  export { schemas };
@@ -1,4 +1,4 @@
1
- import { Features, DbModelDef, InferenceBackend } from "../interfaces.js";
1
+ import { Features, InferenceBackend, TaskSettings } from "../interfaces.js";
2
2
  declare function updatePromptfilePath(pf: string): void;
3
3
  declare function updateDataDirPath(dd: string): void;
4
4
  declare function setDefaultBackend(name: string): void;
@@ -7,7 +7,9 @@ declare function insertFeaturesPathIfNotExists(path: string): boolean;
7
7
  declare function insertPluginIfNotExists(n: string, p: string): boolean;
8
8
  declare function cleanupFeaturePaths(paths: Array<string>): Array<string>;
9
9
  declare function updateAliases(feats: Features): void;
10
- declare function updateModels(models: Array<DbModelDef>): void;
11
10
  declare function updateFeatures(feats: Features): void;
12
11
  declare function upsertFilePath(name: string, newPath: string): boolean;
13
- export { updatePromptfilePath, updateDataDirPath, upsertBackends, setDefaultBackend, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, updateModels, upsertFilePath, };
12
+ declare function upsertTaskSettings(taskName: string, settings: TaskSettings): boolean;
13
+ declare function deleteTaskSettings(settings: Array<string>): void;
14
+ declare function deleteTaskSetting(name: string): void;
15
+ export { updatePromptfilePath, updateDataDirPath, upsertBackends, setDefaultBackend, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, upsertFilePath, upsertTaskSettings, deleteTaskSettings, deleteTaskSetting, };
package/dist/db/write.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { extractTaskToolDocAndVariables, extractToolDoc } from "../cmd/lib/tools.js";
2
2
  import { db } from "./db.js";
3
- import { readModels } from "./read.js";
4
3
  function updatePromptfilePath(pf) {
5
4
  const deleteStmt = db.prepare("DELETE FROM filepath WHERE name = ?");
6
5
  deleteStmt.run("promptfile");
@@ -145,7 +144,6 @@ function updateVariables(name, variableDoc) {
145
144
  }
146
145
  const updateStmt = db.prepare("UPDATE task SET variables = ? WHERE id = ?");
147
146
  updateStmt.run(variableDoc, result.id);
148
- console.log("~", "[task variables] updated for", name);
149
147
  }
150
148
  function upsertTool(name, type, toolDoc) {
151
149
  const stmt1 = db.prepare("SELECT * FROM tool WHERE name = ?");
@@ -153,39 +151,12 @@ function upsertTool(name, type, toolDoc) {
153
151
  if (result?.id) {
154
152
  const updateStmt = db.prepare("UPDATE tool SET spec = ?, type = ? WHERE id = ?");
155
153
  updateStmt.run(toolDoc, type, result.id);
156
- console.log("~", "[tool] updated from", type, ":", name);
157
154
  }
158
155
  else {
159
156
  const stmt = db.prepare("INSERT INTO tool (name, spec, type) VALUES (?,?,?)");
160
157
  stmt.run(name, toolDoc, type);
161
- console.log("+", "[tool] added from", type, ":", name);
162
158
  }
163
159
  }
164
- function updateModels(models) {
165
- const allDbModels = readModels();
166
- const existingModelShortNames = allDbModels.map(row => row.shortname);
167
- const newModelShortNames = models.filter(m => !existingModelShortNames.includes(m.shortname)).map(m => m.shortname);
168
- const mm = models.map(m => m.shortname);
169
- const modelsToDelete = existingModelShortNames.filter(name => !mm.includes(name));
170
- db.transaction(() => {
171
- for (const model of models) {
172
- if (!existingModelShortNames.includes(model.shortname)) {
173
- const insertStmt = db.prepare("INSERT INTO model (name, shortname, data) VALUES (?, ?, ?)");
174
- insertStmt.run(model.name, model.shortname, JSON.stringify(model.data));
175
- console.log("+", "[model]", model.name);
176
- }
177
- else {
178
- const updateStmt = db.prepare("UPDATE model SET name = ?, data = ? WHERE shortname = ?");
179
- updateStmt.run(model.name, JSON.stringify(model.data), model.shortname);
180
- }
181
- }
182
- for (const name of modelsToDelete) {
183
- const deleteStmt = db.prepare("DELETE FROM model WHERE shortname = ?");
184
- deleteStmt.run(name);
185
- console.log("-", "[model]", name);
186
- }
187
- })();
188
- }
189
160
  function updateFeatures(feats) {
190
161
  upsertAndCleanFeatures(feats.task, "task");
191
162
  feats.task.forEach((feat) => {
@@ -213,7 +184,6 @@ function updateFeatures(feats) {
213
184
  });
214
185
  upsertAndCleanFeatures(feats.adaptater, "adaptater");
215
186
  upsertAndCleanFeatures(feats.cmd, "cmd");
216
- upsertAndCleanFeatures(feats.modelfile, "modelfile");
217
187
  }
218
188
  function upsertFilePath(name, newPath) {
219
189
  const selectStmt = db.prepare("SELECT * FROM filepath WHERE name = ?");
@@ -230,4 +200,116 @@ function upsertFilePath(name, newPath) {
230
200
  return true;
231
201
  }
232
202
  }
233
- export { updatePromptfilePath, updateDataDirPath, upsertBackends, setDefaultBackend, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, updateModels, upsertFilePath, };
203
+ function upsertTaskSettings(taskName, settings) {
204
+ const selectStmt = db.prepare("SELECT * FROM tasksettings WHERE name = ?");
205
+ const result = selectStmt.get(taskName);
206
+ if (result?.id) {
207
+ const qparams = new Array();
208
+ const qvalues = new Array();
209
+ if (settings?.model) {
210
+ qparams.push("model = ?");
211
+ qvalues.push(settings.model);
212
+ }
213
+ if (settings?.template) {
214
+ qparams.push("template = ?");
215
+ qvalues.push(settings.template);
216
+ }
217
+ if (settings?.ctx) {
218
+ qparams.push("ctx = ?");
219
+ qvalues.push(settings.ctx);
220
+ }
221
+ if (settings?.max_tokens) {
222
+ qparams.push("maxtokens = ?");
223
+ qvalues.push(settings.max_tokens);
224
+ }
225
+ if (settings?.top_k) {
226
+ qparams.push("topk = ?");
227
+ qvalues.push(settings.top_k);
228
+ }
229
+ if (settings?.top_p) {
230
+ qparams.push("topp = ?");
231
+ qvalues.push(settings.top_p);
232
+ }
233
+ if (settings?.min_p) {
234
+ qparams.push("minp = ?");
235
+ qvalues.push(settings.min_p);
236
+ }
237
+ if (settings?.temperature) {
238
+ qparams.push("temperature = ?");
239
+ qvalues.push(settings.temperature);
240
+ }
241
+ if (settings?.repeat_penalty) {
242
+ qparams.push("repeat = ?");
243
+ qvalues.push(settings.repeat_penalty);
244
+ }
245
+ if (settings?.backend) {
246
+ qparams.push("backend = ?");
247
+ qvalues.push(settings.backend);
248
+ }
249
+ const q = `UPDATE tasksettings SET ${qparams.join(", ")} WHERE name = ?`;
250
+ const stmt = db.prepare(q);
251
+ const updateResult = stmt.run(...qvalues, taskName);
252
+ return updateResult.changes > 0;
253
+ }
254
+ else {
255
+ const qnames = new Array();
256
+ const qvalues = new Array();
257
+ if (settings?.model) {
258
+ qnames.push("model");
259
+ qvalues.push(settings.model);
260
+ }
261
+ if (settings?.template) {
262
+ qnames.push("template");
263
+ qvalues.push(settings.template);
264
+ }
265
+ if (settings?.ctx) {
266
+ qnames.push("ctx");
267
+ qvalues.push(settings.ctx);
268
+ }
269
+ if (settings?.max_tokens) {
270
+ qnames.push("maxtokens");
271
+ qvalues.push(settings.max_tokens);
272
+ }
273
+ if (settings?.top_k) {
274
+ qnames.push("topk");
275
+ qvalues.push(settings.top_k);
276
+ }
277
+ if (settings?.top_p) {
278
+ qnames.push("topp");
279
+ qvalues.push(settings.top_p);
280
+ }
281
+ if (settings?.min_p) {
282
+ qnames.push("minp");
283
+ qvalues.push(settings.min_p);
284
+ }
285
+ if (settings?.temperature) {
286
+ qnames.push("temperature");
287
+ qvalues.push(settings.temperature);
288
+ }
289
+ if (settings?.repeat_penalty) {
290
+ qnames.push("repeat");
291
+ qvalues.push(settings.repeat_penalty);
292
+ }
293
+ if (settings?.backend) {
294
+ qnames.push("backend");
295
+ qvalues.push(settings.backend);
296
+ }
297
+ const nq = new Array("?");
298
+ qnames.forEach(n => nq.push("?"));
299
+ const q = `INSERT INTO tasksettings (name, ${qnames.join(", ")}) VALUES (${nq.join(", ")})`;
300
+ const insertStmt = db.prepare(q);
301
+ insertStmt.run(taskName, ...qvalues);
302
+ return true;
303
+ }
304
+ }
305
+ function deleteTaskSettings(settings) {
306
+ settings.forEach(s => {
307
+ const deleteStmt = db.prepare("DELETE FROM tasksettings WHERE name = ?");
308
+ deleteStmt.run(s);
309
+ });
310
+ }
311
+ function deleteTaskSetting(name) {
312
+ const deleteStmt = db.prepare("DELETE FROM tasksettings WHERE name = ?");
313
+ deleteStmt.run(name);
314
+ }
315
+ export { updatePromptfilePath, updateDataDirPath, upsertBackends, setDefaultBackend, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, upsertFilePath, upsertTaskSettings, deleteTaskSettings, deleteTaskSetting, };
@@ -33,11 +33,6 @@ interface Features {
33
33
  path: string;
34
34
  ext: AdaptaterExtension;
35
35
  }>;
36
- modelfile: Array<{
37
- name: string;
38
- path: string;
39
- ext: ModelFileExtension;
40
- }>;
41
36
  }
42
37
  interface ConfInferenceBackend {
43
38
  type: LmProviderType;
@@ -57,6 +52,7 @@ interface ConfigFile {
57
52
  features?: Array<string>;
58
53
  plugins?: Array<string>;
59
54
  backends?: BackendEntries;
55
+ tasks?: Record<string, TaskSettings>;
60
56
  }
61
57
  interface Settings {
62
58
  name: string;
@@ -102,6 +98,7 @@ interface FinalLmTaskConfig {
102
98
  modelname?: string;
103
99
  }
104
100
  interface WorkflowStep {
101
+ name: string;
105
102
  type: string;
106
103
  run: FeatureExecutor;
107
104
  }
@@ -122,20 +119,31 @@ interface McpServerTool {
122
119
  required: string[];
123
120
  };
124
121
  }
122
+ interface TaskSettings {
123
+ model?: string;
124
+ template?: string;
125
+ ctx?: number;
126
+ max_tokens?: number;
127
+ top_k?: number;
128
+ top_p?: number;
129
+ min_p?: number;
130
+ temperature?: number;
131
+ repeat_penalty?: number;
132
+ backend?: string;
133
+ }
125
134
  type InputMode = "manual" | "promptfile" | "clipboard";
126
135
  type OutputMode = "txt" | "clipboard";
127
136
  type RunMode = "cli" | "cmd";
128
137
  type FormatMode = "text" | "markdown";
129
138
  type VerbosityMode = "quiet" | "verbose" | "debug";
130
- type FeatureType = "task" | "action" | "cmd" | "workflow" | "adaptater" | "modelfile";
139
+ type FeatureType = "task" | "action" | "cmd" | "workflow" | "adaptater";
131
140
  type ToolType = "task" | "action" | "cmd" | "workflow";
132
141
  type ActionExtension = "js" | "mjs" | "py" | "yml";
133
142
  type TaskExtension = "yml";
134
143
  type AdaptaterExtension = "js";
135
144
  type WorkflowExtension = "yml";
136
145
  type CmdExtension = "js";
137
- type ModelFileExtension = "yml";
138
- type FeatureExtension = TaskExtension | CmdExtension | ActionExtension | WorkflowExtension | ModelFileExtension;
146
+ type FeatureExtension = TaskExtension | CmdExtension | ActionExtension | WorkflowExtension;
139
147
  type AliasType = "task" | "action" | "workflow";
140
148
  type FeatureExecutor<I = any, O = any> = (params: I, options: Record<string, any>) => Promise<O>;
141
- export { InputMode, VerbosityMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, ModelFileExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, McpServerSpec, McpServerTool, InferenceBackend, ConfInferenceBackend, FeatureExecutor, WorkflowStep, };
149
+ export { InputMode, VerbosityMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, McpServerSpec, McpServerTool, InferenceBackend, ConfInferenceBackend, FeatureExecutor, WorkflowStep, TaskSettings, };
@@ -1,27 +1,7 @@
1
- declare const chatInferenceParams: {
2
- stream?: boolean | undefined;
3
- model?: {
4
- name: string;
5
- ctx?: number | undefined;
6
- info?: {
7
- size: string;
8
- quant: string;
9
- } | undefined;
10
- extra?: Record<string, any> | undefined;
11
- } | undefined;
12
- template?: string | undefined;
13
- max_tokens?: number | undefined;
14
- top_k?: number | undefined;
15
- top_p?: number | undefined;
16
- min_p?: number | undefined;
17
- temperature?: number | undefined;
18
- repeat_penalty?: number | undefined;
19
- tfs?: number | undefined;
20
- stop?: Array<string> | undefined;
21
- grammar?: string | undefined;
22
- tsGrammar?: string | undefined;
23
- schema?: Record<string, any> | undefined;
24
- images?: Array<string> | undefined;
25
- extra?: Record<string, any> | undefined;
26
- };
27
- export { chatInferenceParams, };
1
+ import { InferenceParams } from "@locallm/types";
2
+ import { PromptTemplate } from "modprompt";
3
+ declare let chatInferenceParams: InferenceParams;
4
+ declare let chatTemplate: PromptTemplate;
5
+ declare function setChatTemplate(tpl: PromptTemplate): void;
6
+ declare function setChatInferenceParams(ip: InferenceParams): void;
7
+ export { chatInferenceParams, chatTemplate, setChatInferenceParams, setChatTemplate, };
@@ -1,3 +1,10 @@
1
- import { reactive } from "@vue/reactivity";
2
- const chatInferenceParams = reactive({ temperature: 0.2, min_p: 0.05, max_tokens: 2048 });
3
- export { chatInferenceParams, };
1
+ import { PromptTemplate } from "modprompt";
2
+ let chatInferenceParams = { temperature: 0.2, min_p: 0.05, max_tokens: 2048 };
3
+ let chatTemplate = new PromptTemplate("none");
4
+ function setChatTemplate(tpl) {
5
+ chatTemplate = tpl;
6
+ }
7
+ function setChatInferenceParams(ip) {
8
+ chatInferenceParams = ip;
9
+ }
10
+ export { chatInferenceParams, chatTemplate, setChatInferenceParams, setChatTemplate, };
@@ -8,7 +8,6 @@ function readFeaturesDirs(featuresPaths) {
8
8
  cmd: [],
9
9
  workflow: [],
10
10
  adaptater: [],
11
- modelfile: [],
12
11
  };
13
12
  featuresPaths.forEach((dir) => {
14
13
  const _f = readFeaturesDir(dir);
@@ -17,7 +16,6 @@ function readFeaturesDirs(featuresPaths) {
17
16
  _f.cmd.forEach((item) => feats.cmd.push(item));
18
17
  _f.workflow.forEach((item) => feats.workflow.push(item));
19
18
  _f.adaptater.forEach((item) => feats.adaptater.push(item));
20
- _f.modelfile.forEach((item) => feats.modelfile.push(item));
21
19
  });
22
20
  return feats;
23
21
  }
@@ -0,0 +1,5 @@
1
+ import { TaskSettings } from "../interfaces.js";
2
+ declare const tasksSettings: Record<string, TaskSettings>;
3
+ declare const isTaskSettingsInitialized: import("@vue/reactivity").Ref<boolean, boolean>;
4
+ declare function initTaskSettings(): void;
5
+ export { tasksSettings, initTaskSettings, isTaskSettingsInitialized, };
@@ -0,0 +1,21 @@
1
+ import { ref } from "@vue/reactivity";
2
+ import { readTaskSettings } from "../db/read.js";
3
+ const tasksSettings = {};
4
+ const isTaskSettingsInitialized = ref(false);
5
+ function initTaskSettings() {
6
+ const data = readTaskSettings();
7
+ data.forEach(row => {
8
+ const name = row.name;
9
+ delete row.name;
10
+ delete row.id;
11
+ const vals = {};
12
+ for (const [k, v] of Object.entries(row)) {
13
+ if (v !== null) {
14
+ vals[k] = v;
15
+ }
16
+ }
17
+ tasksSettings[name] = vals;
18
+ });
19
+ isTaskSettingsInitialized.value = true;
20
+ }
21
+ export { tasksSettings, initTaskSettings, isTaskSettingsInitialized, };