langtrain 0.1.6 → 0.1.10
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/cli.d.mts +0 -2
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +297 -125
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +299 -127
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +41 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +65 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
- package/src/agent.ts +54 -0
- package/src/cli.ts +197 -50
- package/src/index.ts +5 -1
package/dist/cli.js
CHANGED
|
@@ -46,8 +46,8 @@ var require_windows = __commonJS({
|
|
|
46
46
|
"use strict";
|
|
47
47
|
module2.exports = isexe;
|
|
48
48
|
isexe.sync = sync;
|
|
49
|
-
var
|
|
50
|
-
function checkPathExt(
|
|
49
|
+
var fs2 = require("fs");
|
|
50
|
+
function checkPathExt(path6, options) {
|
|
51
51
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
52
52
|
if (!pathext) {
|
|
53
53
|
return true;
|
|
@@ -58,25 +58,25 @@ var require_windows = __commonJS({
|
|
|
58
58
|
}
|
|
59
59
|
for (var i = 0; i < pathext.length; i++) {
|
|
60
60
|
var p = pathext[i].toLowerCase();
|
|
61
|
-
if (p &&
|
|
61
|
+
if (p && path6.substr(-p.length).toLowerCase() === p) {
|
|
62
62
|
return true;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
|
-
function checkStat(stat,
|
|
67
|
+
function checkStat(stat, path6, options) {
|
|
68
68
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
|
-
return checkPathExt(
|
|
71
|
+
return checkPathExt(path6, options);
|
|
72
72
|
}
|
|
73
|
-
function isexe(
|
|
74
|
-
|
|
75
|
-
cb(er, er ? false : checkStat(stat,
|
|
73
|
+
function isexe(path6, options, cb) {
|
|
74
|
+
fs2.stat(path6, function(er, stat) {
|
|
75
|
+
cb(er, er ? false : checkStat(stat, path6, options));
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
function sync(
|
|
79
|
-
return checkStat(
|
|
78
|
+
function sync(path6, options) {
|
|
79
|
+
return checkStat(fs2.statSync(path6), path6, options);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
});
|
|
@@ -87,14 +87,14 @@ var require_mode = __commonJS({
|
|
|
87
87
|
"use strict";
|
|
88
88
|
module2.exports = isexe;
|
|
89
89
|
isexe.sync = sync;
|
|
90
|
-
var
|
|
91
|
-
function isexe(
|
|
92
|
-
|
|
90
|
+
var fs2 = require("fs");
|
|
91
|
+
function isexe(path6, options, cb) {
|
|
92
|
+
fs2.stat(path6, function(er, stat) {
|
|
93
93
|
cb(er, er ? false : checkStat(stat, options));
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
function sync(
|
|
97
|
-
return checkStat(
|
|
96
|
+
function sync(path6, options) {
|
|
97
|
+
return checkStat(fs2.statSync(path6), options);
|
|
98
98
|
}
|
|
99
99
|
function checkStat(stat, options) {
|
|
100
100
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -119,7 +119,7 @@ var require_mode = __commonJS({
|
|
|
119
119
|
var require_isexe = __commonJS({
|
|
120
120
|
"../langvision/js/node_modules/isexe/index.js"(exports2, module2) {
|
|
121
121
|
"use strict";
|
|
122
|
-
var
|
|
122
|
+
var fs2 = require("fs");
|
|
123
123
|
var core;
|
|
124
124
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
125
125
|
core = require_windows();
|
|
@@ -128,7 +128,7 @@ var require_isexe = __commonJS({
|
|
|
128
128
|
}
|
|
129
129
|
module2.exports = isexe;
|
|
130
130
|
isexe.sync = sync;
|
|
131
|
-
function isexe(
|
|
131
|
+
function isexe(path6, options, cb) {
|
|
132
132
|
if (typeof options === "function") {
|
|
133
133
|
cb = options;
|
|
134
134
|
options = {};
|
|
@@ -138,7 +138,7 @@ var require_isexe = __commonJS({
|
|
|
138
138
|
throw new TypeError("callback not provided");
|
|
139
139
|
}
|
|
140
140
|
return new Promise(function(resolve, reject) {
|
|
141
|
-
isexe(
|
|
141
|
+
isexe(path6, options || {}, function(er, is) {
|
|
142
142
|
if (er) {
|
|
143
143
|
reject(er);
|
|
144
144
|
} else {
|
|
@@ -147,7 +147,7 @@ var require_isexe = __commonJS({
|
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
core(
|
|
150
|
+
core(path6, options || {}, function(er, is) {
|
|
151
151
|
if (er) {
|
|
152
152
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
153
153
|
er = null;
|
|
@@ -157,9 +157,9 @@ var require_isexe = __commonJS({
|
|
|
157
157
|
cb(er, is);
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
function sync(
|
|
160
|
+
function sync(path6, options) {
|
|
161
161
|
try {
|
|
162
|
-
return core.sync(
|
|
162
|
+
return core.sync(path6, options || {});
|
|
163
163
|
} catch (er) {
|
|
164
164
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
165
165
|
return false;
|
|
@@ -176,7 +176,7 @@ var require_which = __commonJS({
|
|
|
176
176
|
"../langvision/js/node_modules/which/which.js"(exports2, module2) {
|
|
177
177
|
"use strict";
|
|
178
178
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
179
|
-
var
|
|
179
|
+
var path6 = require("path");
|
|
180
180
|
var COLON = isWindows ? ";" : ":";
|
|
181
181
|
var isexe = require_isexe();
|
|
182
182
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -214,7 +214,7 @@ var require_which = __commonJS({
|
|
|
214
214
|
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
215
215
|
const ppRaw = pathEnv[i];
|
|
216
216
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
217
|
-
const pCmd =
|
|
217
|
+
const pCmd = path6.join(pathPart, cmd);
|
|
218
218
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
219
219
|
resolve(subStep(p, i, 0));
|
|
220
220
|
});
|
|
@@ -241,7 +241,7 @@ var require_which = __commonJS({
|
|
|
241
241
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
242
242
|
const ppRaw = pathEnv[i];
|
|
243
243
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
244
|
-
const pCmd =
|
|
244
|
+
const pCmd = path6.join(pathPart, cmd);
|
|
245
245
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
246
246
|
for (let j = 0; j < pathExt.length; j++) {
|
|
247
247
|
const cur = p + pathExt[j];
|
|
@@ -289,7 +289,7 @@ var require_path_key = __commonJS({
|
|
|
289
289
|
var require_resolveCommand = __commonJS({
|
|
290
290
|
"../langvision/js/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
291
291
|
"use strict";
|
|
292
|
-
var
|
|
292
|
+
var path6 = require("path");
|
|
293
293
|
var which = require_which();
|
|
294
294
|
var getPathKey = require_path_key();
|
|
295
295
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -307,7 +307,7 @@ var require_resolveCommand = __commonJS({
|
|
|
307
307
|
try {
|
|
308
308
|
resolved = which.sync(parsed.command, {
|
|
309
309
|
path: env[getPathKey({ env })],
|
|
310
|
-
pathExt: withoutPathExt ?
|
|
310
|
+
pathExt: withoutPathExt ? path6.delimiter : void 0
|
|
311
311
|
});
|
|
312
312
|
} catch (e) {
|
|
313
313
|
} finally {
|
|
@@ -316,7 +316,7 @@ var require_resolveCommand = __commonJS({
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
if (resolved) {
|
|
319
|
-
resolved =
|
|
319
|
+
resolved = path6.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
320
320
|
}
|
|
321
321
|
return resolved;
|
|
322
322
|
}
|
|
@@ -370,8 +370,8 @@ var require_shebang_command = __commonJS({
|
|
|
370
370
|
if (!match) {
|
|
371
371
|
return null;
|
|
372
372
|
}
|
|
373
|
-
const [
|
|
374
|
-
const binary =
|
|
373
|
+
const [path6, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
374
|
+
const binary = path6.split("/").pop();
|
|
375
375
|
if (binary === "env") {
|
|
376
376
|
return argument;
|
|
377
377
|
}
|
|
@@ -384,16 +384,16 @@ var require_shebang_command = __commonJS({
|
|
|
384
384
|
var require_readShebang = __commonJS({
|
|
385
385
|
"../langvision/js/node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
|
|
386
386
|
"use strict";
|
|
387
|
-
var
|
|
387
|
+
var fs2 = require("fs");
|
|
388
388
|
var shebangCommand = require_shebang_command();
|
|
389
389
|
function readShebang(command) {
|
|
390
390
|
const size = 150;
|
|
391
391
|
const buffer = Buffer.alloc(size);
|
|
392
392
|
let fd;
|
|
393
393
|
try {
|
|
394
|
-
fd =
|
|
395
|
-
|
|
396
|
-
|
|
394
|
+
fd = fs2.openSync(command, "r");
|
|
395
|
+
fs2.readSync(fd, buffer, 0, size, 0);
|
|
396
|
+
fs2.closeSync(fd);
|
|
397
397
|
} catch (e) {
|
|
398
398
|
}
|
|
399
399
|
return shebangCommand(buffer.toString());
|
|
@@ -406,7 +406,7 @@ var require_readShebang = __commonJS({
|
|
|
406
406
|
var require_parse = __commonJS({
|
|
407
407
|
"../langvision/js/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
408
408
|
"use strict";
|
|
409
|
-
var
|
|
409
|
+
var path6 = require("path");
|
|
410
410
|
var resolveCommand = require_resolveCommand();
|
|
411
411
|
var escape = require_escape();
|
|
412
412
|
var readShebang = require_readShebang();
|
|
@@ -431,7 +431,7 @@ var require_parse = __commonJS({
|
|
|
431
431
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
432
432
|
if (parsed.options.forceShell || needsShell) {
|
|
433
433
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
434
|
-
parsed.command =
|
|
434
|
+
parsed.command = path6.normalize(parsed.command);
|
|
435
435
|
parsed.command = escape.command(parsed.command);
|
|
436
436
|
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
437
437
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -587,8 +587,8 @@ var require_windows2 = __commonJS({
|
|
|
587
587
|
"use strict";
|
|
588
588
|
module2.exports = isexe;
|
|
589
589
|
isexe.sync = sync;
|
|
590
|
-
var
|
|
591
|
-
function checkPathExt(
|
|
590
|
+
var fs2 = require("fs");
|
|
591
|
+
function checkPathExt(path6, options) {
|
|
592
592
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
593
593
|
if (!pathext) {
|
|
594
594
|
return true;
|
|
@@ -599,25 +599,25 @@ var require_windows2 = __commonJS({
|
|
|
599
599
|
}
|
|
600
600
|
for (var i = 0; i < pathext.length; i++) {
|
|
601
601
|
var p = pathext[i].toLowerCase();
|
|
602
|
-
if (p &&
|
|
602
|
+
if (p && path6.substr(-p.length).toLowerCase() === p) {
|
|
603
603
|
return true;
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
606
|
return false;
|
|
607
607
|
}
|
|
608
|
-
function checkStat(stat,
|
|
608
|
+
function checkStat(stat, path6, options) {
|
|
609
609
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
610
610
|
return false;
|
|
611
611
|
}
|
|
612
|
-
return checkPathExt(
|
|
612
|
+
return checkPathExt(path6, options);
|
|
613
613
|
}
|
|
614
|
-
function isexe(
|
|
615
|
-
|
|
616
|
-
cb(er, er ? false : checkStat(stat,
|
|
614
|
+
function isexe(path6, options, cb) {
|
|
615
|
+
fs2.stat(path6, function(er, stat) {
|
|
616
|
+
cb(er, er ? false : checkStat(stat, path6, options));
|
|
617
617
|
});
|
|
618
618
|
}
|
|
619
|
-
function sync(
|
|
620
|
-
return checkStat(
|
|
619
|
+
function sync(path6, options) {
|
|
620
|
+
return checkStat(fs2.statSync(path6), path6, options);
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
623
|
});
|
|
@@ -628,14 +628,14 @@ var require_mode2 = __commonJS({
|
|
|
628
628
|
"use strict";
|
|
629
629
|
module2.exports = isexe;
|
|
630
630
|
isexe.sync = sync;
|
|
631
|
-
var
|
|
632
|
-
function isexe(
|
|
633
|
-
|
|
631
|
+
var fs2 = require("fs");
|
|
632
|
+
function isexe(path6, options, cb) {
|
|
633
|
+
fs2.stat(path6, function(er, stat) {
|
|
634
634
|
cb(er, er ? false : checkStat(stat, options));
|
|
635
635
|
});
|
|
636
636
|
}
|
|
637
|
-
function sync(
|
|
638
|
-
return checkStat(
|
|
637
|
+
function sync(path6, options) {
|
|
638
|
+
return checkStat(fs2.statSync(path6), options);
|
|
639
639
|
}
|
|
640
640
|
function checkStat(stat, options) {
|
|
641
641
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -660,7 +660,7 @@ var require_mode2 = __commonJS({
|
|
|
660
660
|
var require_isexe2 = __commonJS({
|
|
661
661
|
"../langtune/js/node_modules/isexe/index.js"(exports2, module2) {
|
|
662
662
|
"use strict";
|
|
663
|
-
var
|
|
663
|
+
var fs2 = require("fs");
|
|
664
664
|
var core;
|
|
665
665
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
666
666
|
core = require_windows2();
|
|
@@ -669,7 +669,7 @@ var require_isexe2 = __commonJS({
|
|
|
669
669
|
}
|
|
670
670
|
module2.exports = isexe;
|
|
671
671
|
isexe.sync = sync;
|
|
672
|
-
function isexe(
|
|
672
|
+
function isexe(path6, options, cb) {
|
|
673
673
|
if (typeof options === "function") {
|
|
674
674
|
cb = options;
|
|
675
675
|
options = {};
|
|
@@ -679,7 +679,7 @@ var require_isexe2 = __commonJS({
|
|
|
679
679
|
throw new TypeError("callback not provided");
|
|
680
680
|
}
|
|
681
681
|
return new Promise(function(resolve, reject) {
|
|
682
|
-
isexe(
|
|
682
|
+
isexe(path6, options || {}, function(er, is) {
|
|
683
683
|
if (er) {
|
|
684
684
|
reject(er);
|
|
685
685
|
} else {
|
|
@@ -688,7 +688,7 @@ var require_isexe2 = __commonJS({
|
|
|
688
688
|
});
|
|
689
689
|
});
|
|
690
690
|
}
|
|
691
|
-
core(
|
|
691
|
+
core(path6, options || {}, function(er, is) {
|
|
692
692
|
if (er) {
|
|
693
693
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
694
694
|
er = null;
|
|
@@ -698,9 +698,9 @@ var require_isexe2 = __commonJS({
|
|
|
698
698
|
cb(er, is);
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
|
-
function sync(
|
|
701
|
+
function sync(path6, options) {
|
|
702
702
|
try {
|
|
703
|
-
return core.sync(
|
|
703
|
+
return core.sync(path6, options || {});
|
|
704
704
|
} catch (er) {
|
|
705
705
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
706
706
|
return false;
|
|
@@ -717,7 +717,7 @@ var require_which2 = __commonJS({
|
|
|
717
717
|
"../langtune/js/node_modules/which/which.js"(exports2, module2) {
|
|
718
718
|
"use strict";
|
|
719
719
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
720
|
-
var
|
|
720
|
+
var path6 = require("path");
|
|
721
721
|
var COLON = isWindows ? ";" : ":";
|
|
722
722
|
var isexe = require_isexe2();
|
|
723
723
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -755,7 +755,7 @@ var require_which2 = __commonJS({
|
|
|
755
755
|
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
756
756
|
const ppRaw = pathEnv[i];
|
|
757
757
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
758
|
-
const pCmd =
|
|
758
|
+
const pCmd = path6.join(pathPart, cmd);
|
|
759
759
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
760
760
|
resolve(subStep(p, i, 0));
|
|
761
761
|
});
|
|
@@ -782,7 +782,7 @@ var require_which2 = __commonJS({
|
|
|
782
782
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
783
783
|
const ppRaw = pathEnv[i];
|
|
784
784
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
785
|
-
const pCmd =
|
|
785
|
+
const pCmd = path6.join(pathPart, cmd);
|
|
786
786
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
787
787
|
for (let j = 0; j < pathExt.length; j++) {
|
|
788
788
|
const cur = p + pathExt[j];
|
|
@@ -830,7 +830,7 @@ var require_path_key2 = __commonJS({
|
|
|
830
830
|
var require_resolveCommand2 = __commonJS({
|
|
831
831
|
"../langtune/js/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
832
832
|
"use strict";
|
|
833
|
-
var
|
|
833
|
+
var path6 = require("path");
|
|
834
834
|
var which = require_which2();
|
|
835
835
|
var getPathKey = require_path_key2();
|
|
836
836
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -848,7 +848,7 @@ var require_resolveCommand2 = __commonJS({
|
|
|
848
848
|
try {
|
|
849
849
|
resolved = which.sync(parsed.command, {
|
|
850
850
|
path: env[getPathKey({ env })],
|
|
851
|
-
pathExt: withoutPathExt ?
|
|
851
|
+
pathExt: withoutPathExt ? path6.delimiter : void 0
|
|
852
852
|
});
|
|
853
853
|
} catch (e) {
|
|
854
854
|
} finally {
|
|
@@ -857,7 +857,7 @@ var require_resolveCommand2 = __commonJS({
|
|
|
857
857
|
}
|
|
858
858
|
}
|
|
859
859
|
if (resolved) {
|
|
860
|
-
resolved =
|
|
860
|
+
resolved = path6.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
861
861
|
}
|
|
862
862
|
return resolved;
|
|
863
863
|
}
|
|
@@ -911,8 +911,8 @@ var require_shebang_command2 = __commonJS({
|
|
|
911
911
|
if (!match) {
|
|
912
912
|
return null;
|
|
913
913
|
}
|
|
914
|
-
const [
|
|
915
|
-
const binary =
|
|
914
|
+
const [path6, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
915
|
+
const binary = path6.split("/").pop();
|
|
916
916
|
if (binary === "env") {
|
|
917
917
|
return argument;
|
|
918
918
|
}
|
|
@@ -925,16 +925,16 @@ var require_shebang_command2 = __commonJS({
|
|
|
925
925
|
var require_readShebang2 = __commonJS({
|
|
926
926
|
"../langtune/js/node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
|
|
927
927
|
"use strict";
|
|
928
|
-
var
|
|
928
|
+
var fs2 = require("fs");
|
|
929
929
|
var shebangCommand = require_shebang_command2();
|
|
930
930
|
function readShebang(command) {
|
|
931
931
|
const size = 150;
|
|
932
932
|
const buffer = Buffer.alloc(size);
|
|
933
933
|
let fd;
|
|
934
934
|
try {
|
|
935
|
-
fd =
|
|
936
|
-
|
|
937
|
-
|
|
935
|
+
fd = fs2.openSync(command, "r");
|
|
936
|
+
fs2.readSync(fd, buffer, 0, size, 0);
|
|
937
|
+
fs2.closeSync(fd);
|
|
938
938
|
} catch (e) {
|
|
939
939
|
}
|
|
940
940
|
return shebangCommand(buffer.toString());
|
|
@@ -947,7 +947,7 @@ var require_readShebang2 = __commonJS({
|
|
|
947
947
|
var require_parse2 = __commonJS({
|
|
948
948
|
"../langtune/js/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
949
949
|
"use strict";
|
|
950
|
-
var
|
|
950
|
+
var path6 = require("path");
|
|
951
951
|
var resolveCommand = require_resolveCommand2();
|
|
952
952
|
var escape = require_escape2();
|
|
953
953
|
var readShebang = require_readShebang2();
|
|
@@ -972,7 +972,7 @@ var require_parse2 = __commonJS({
|
|
|
972
972
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
973
973
|
if (parsed.options.forceShell || needsShell) {
|
|
974
974
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
975
|
-
parsed.command =
|
|
975
|
+
parsed.command = path6.normalize(parsed.command);
|
|
976
976
|
parsed.command = escape.command(parsed.command);
|
|
977
977
|
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
978
978
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -3203,8 +3203,8 @@ function getErrorMap() {
|
|
|
3203
3203
|
|
|
3204
3204
|
// ../langvision/js/node_modules/zod/v3/helpers/parseUtil.js
|
|
3205
3205
|
var makeIssue = (params) => {
|
|
3206
|
-
const { data, path:
|
|
3207
|
-
const fullPath = [...
|
|
3206
|
+
const { data, path: path6, errorMaps, issueData } = params;
|
|
3207
|
+
const fullPath = [...path6, ...issueData.path || []];
|
|
3208
3208
|
const fullIssue = {
|
|
3209
3209
|
...issueData,
|
|
3210
3210
|
path: fullPath
|
|
@@ -3320,11 +3320,11 @@ var errorUtil;
|
|
|
3320
3320
|
|
|
3321
3321
|
// ../langvision/js/node_modules/zod/v3/types.js
|
|
3322
3322
|
var ParseInputLazyPath = class {
|
|
3323
|
-
constructor(parent, value,
|
|
3323
|
+
constructor(parent, value, path6, key) {
|
|
3324
3324
|
this._cachedPath = [];
|
|
3325
3325
|
this.parent = parent;
|
|
3326
3326
|
this.data = value;
|
|
3327
|
-
this._path =
|
|
3327
|
+
this._path = path6;
|
|
3328
3328
|
this._key = key;
|
|
3329
3329
|
}
|
|
3330
3330
|
get path() {
|
|
@@ -6779,6 +6779,13 @@ var FinetuneConfigSchema = external_exports.object({
|
|
|
6779
6779
|
var Langvision = class {
|
|
6780
6780
|
constructor(options = {}) {
|
|
6781
6781
|
this.cliPath = options.cliPath || "langvision";
|
|
6782
|
+
this.apiKey = options.apiKey;
|
|
6783
|
+
}
|
|
6784
|
+
getEnv() {
|
|
6785
|
+
return {
|
|
6786
|
+
...process.env,
|
|
6787
|
+
LANGVISION_API_KEY: this.apiKey || process.env.LANGVISION_API_KEY
|
|
6788
|
+
};
|
|
6782
6789
|
}
|
|
6783
6790
|
/**
|
|
6784
6791
|
* Run a fine-tuning job using the local CLI
|
|
@@ -6803,7 +6810,10 @@ var Langvision = class {
|
|
|
6803
6810
|
validated.outputDir
|
|
6804
6811
|
];
|
|
6805
6812
|
try {
|
|
6806
|
-
await execa(this.cliPath, args, {
|
|
6813
|
+
await execa(this.cliPath, args, {
|
|
6814
|
+
stdio: "inherit",
|
|
6815
|
+
env: this.getEnv()
|
|
6816
|
+
});
|
|
6807
6817
|
} catch (error) {
|
|
6808
6818
|
throw new Error(`Langvision fine-tuning failed: ${error}`);
|
|
6809
6819
|
}
|
|
@@ -6826,7 +6836,9 @@ var Langvision = class {
|
|
|
6826
6836
|
args.push("--temperature", options.temperature.toString());
|
|
6827
6837
|
}
|
|
6828
6838
|
try {
|
|
6829
|
-
const { stdout } = await execa(this.cliPath, args
|
|
6839
|
+
const { stdout } = await execa(this.cliPath, args, {
|
|
6840
|
+
env: this.getEnv()
|
|
6841
|
+
});
|
|
6830
6842
|
return stdout;
|
|
6831
6843
|
} catch (error) {
|
|
6832
6844
|
throw new Error(`Langvision generation failed: ${error}`);
|
|
@@ -8910,8 +8922,8 @@ function getErrorMap2() {
|
|
|
8910
8922
|
|
|
8911
8923
|
// ../langtune/js/node_modules/zod/v3/helpers/parseUtil.js
|
|
8912
8924
|
var makeIssue2 = (params) => {
|
|
8913
|
-
const { data, path:
|
|
8914
|
-
const fullPath = [...
|
|
8925
|
+
const { data, path: path6, errorMaps, issueData } = params;
|
|
8926
|
+
const fullPath = [...path6, ...issueData.path || []];
|
|
8915
8927
|
const fullIssue = {
|
|
8916
8928
|
...issueData,
|
|
8917
8929
|
path: fullPath
|
|
@@ -9027,11 +9039,11 @@ var errorUtil2;
|
|
|
9027
9039
|
|
|
9028
9040
|
// ../langtune/js/node_modules/zod/v3/types.js
|
|
9029
9041
|
var ParseInputLazyPath2 = class {
|
|
9030
|
-
constructor(parent, value,
|
|
9042
|
+
constructor(parent, value, path6, key) {
|
|
9031
9043
|
this._cachedPath = [];
|
|
9032
9044
|
this.parent = parent;
|
|
9033
9045
|
this.data = value;
|
|
9034
|
-
this._path =
|
|
9046
|
+
this._path = path6;
|
|
9035
9047
|
this._key = key;
|
|
9036
9048
|
}
|
|
9037
9049
|
get path() {
|
|
@@ -12489,6 +12501,13 @@ var FinetuneConfigSchema2 = external_exports2.object({
|
|
|
12489
12501
|
var Langtune = class {
|
|
12490
12502
|
constructor(options = {}) {
|
|
12491
12503
|
this.cliPath = options.cliPath || "langtune";
|
|
12504
|
+
this.apiKey = options.apiKey;
|
|
12505
|
+
}
|
|
12506
|
+
getEnv() {
|
|
12507
|
+
return {
|
|
12508
|
+
...process.env,
|
|
12509
|
+
LANGTUNE_API_KEY: this.apiKey || process.env.LANGTUNE_API_KEY
|
|
12510
|
+
};
|
|
12492
12511
|
}
|
|
12493
12512
|
/**
|
|
12494
12513
|
* Run a fine-tuning job using the local CLI
|
|
@@ -12521,7 +12540,10 @@ var Langtune = class {
|
|
|
12521
12540
|
args.push("--use-lisa");
|
|
12522
12541
|
}
|
|
12523
12542
|
try {
|
|
12524
|
-
await execa2(this.cliPath, args, {
|
|
12543
|
+
await execa2(this.cliPath, args, {
|
|
12544
|
+
stdio: "inherit",
|
|
12545
|
+
env: this.getEnv()
|
|
12546
|
+
});
|
|
12525
12547
|
} catch (error) {
|
|
12526
12548
|
throw new Error(`Langtune fine-tuning failed: ${error}`);
|
|
12527
12549
|
}
|
|
@@ -12544,7 +12566,9 @@ var Langtune = class {
|
|
|
12544
12566
|
args.push("--temperature", options.temperature.toString());
|
|
12545
12567
|
}
|
|
12546
12568
|
try {
|
|
12547
|
-
const { stdout } = await execa2(this.cliPath, args
|
|
12569
|
+
const { stdout } = await execa2(this.cliPath, args, {
|
|
12570
|
+
env: this.getEnv()
|
|
12571
|
+
});
|
|
12548
12572
|
return stdout;
|
|
12549
12573
|
} catch (error) {
|
|
12550
12574
|
throw new Error(`Langtune generation failed: ${error}`);
|
|
@@ -12552,48 +12576,190 @@ var Langtune = class {
|
|
|
12552
12576
|
}
|
|
12553
12577
|
};
|
|
12554
12578
|
|
|
12579
|
+
// src/agent.ts
|
|
12580
|
+
var import_axios = __toESM(require("axios"));
|
|
12581
|
+
var AgentClient = class {
|
|
12582
|
+
constructor(config) {
|
|
12583
|
+
this.config = config;
|
|
12584
|
+
this.client = import_axios.default.create({
|
|
12585
|
+
baseURL: config.baseUrl || "https://api.langtrain.ai/api/v1",
|
|
12586
|
+
headers: {
|
|
12587
|
+
"X-API-Key": config.apiKey,
|
|
12588
|
+
"Content-Type": "application/json"
|
|
12589
|
+
}
|
|
12590
|
+
});
|
|
12591
|
+
}
|
|
12592
|
+
async list(workspaceId) {
|
|
12593
|
+
const params = {};
|
|
12594
|
+
if (workspaceId) params.workspace_id = workspaceId;
|
|
12595
|
+
const response = await this.client.get("/agents", { params });
|
|
12596
|
+
return response.data.agents;
|
|
12597
|
+
}
|
|
12598
|
+
async execute(agentId, input, messages = [], conversationId) {
|
|
12599
|
+
const response = await this.client.post(`/agents/${agentId}/execute`, {
|
|
12600
|
+
input,
|
|
12601
|
+
messages,
|
|
12602
|
+
conversation_id: conversationId
|
|
12603
|
+
});
|
|
12604
|
+
return response.data;
|
|
12605
|
+
}
|
|
12606
|
+
};
|
|
12607
|
+
|
|
12555
12608
|
// src/cli.ts
|
|
12556
|
-
var
|
|
12557
|
-
var
|
|
12609
|
+
var import_fs = __toESM(require("fs"));
|
|
12610
|
+
var import_path = __toESM(require("path"));
|
|
12611
|
+
var import_os = __toESM(require("os"));
|
|
12612
|
+
var import_gradient_string = __toESM(require("gradient-string"));
|
|
12613
|
+
var CONFIG_DIR = import_path.default.join(import_os.default.homedir(), ".langtrain");
|
|
12614
|
+
var CONFIG_FILE = import_path.default.join(CONFIG_DIR, "config.json");
|
|
12615
|
+
function getConfig() {
|
|
12616
|
+
if (!import_fs.default.existsSync(CONFIG_FILE)) return {};
|
|
12617
|
+
try {
|
|
12618
|
+
return JSON.parse(import_fs.default.readFileSync(CONFIG_FILE, "utf-8"));
|
|
12619
|
+
} catch {
|
|
12620
|
+
return {};
|
|
12621
|
+
}
|
|
12622
|
+
}
|
|
12623
|
+
function saveConfig(config) {
|
|
12624
|
+
if (!import_fs.default.existsSync(CONFIG_DIR)) {
|
|
12625
|
+
import_fs.default.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
12626
|
+
}
|
|
12627
|
+
import_fs.default.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
12628
|
+
}
|
|
12629
|
+
var packageJson = require(import_path.default.join(__dirname, "../package.json"));
|
|
12558
12630
|
async function main() {
|
|
12559
12631
|
const program = new import_commander.Command();
|
|
12560
|
-
|
|
12632
|
+
const version = packageJson.version;
|
|
12633
|
+
program.name("langtrain").description(packageJson.description || "Langtrain CLI for AI Model Fine-tuning and Generation").version(version);
|
|
12561
12634
|
program.action(async () => {
|
|
12562
12635
|
console.clear();
|
|
12563
|
-
|
|
12564
|
-
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
if (
|
|
12575
|
-
(0, import_prompts.
|
|
12576
|
-
|
|
12577
|
-
}
|
|
12578
|
-
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12584
|
-
|
|
12585
|
-
|
|
12586
|
-
|
|
12636
|
+
const banner = `
|
|
12637
|
+
\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557
|
|
12638
|
+
\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551
|
|
12639
|
+
\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551
|
|
12640
|
+
\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551
|
|
12641
|
+
\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551
|
|
12642
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D
|
|
12643
|
+
`;
|
|
12644
|
+
console.log((0, import_gradient_string.default)(["#00DC82", "#36E4DA", "#0047E1"])(banner));
|
|
12645
|
+
(0, import_prompts.intro)(`${(0, import_colors.bgCyan)((0, import_colors.black)(` Langtrain SDK v${version} `))}`);
|
|
12646
|
+
const config = getConfig();
|
|
12647
|
+
if (!config.apiKey) {
|
|
12648
|
+
(0, import_prompts.intro)((0, import_colors.yellow)("Authentication required"));
|
|
12649
|
+
await handleLogin();
|
|
12650
|
+
}
|
|
12651
|
+
const handlers = {
|
|
12652
|
+
"login": handleLogin,
|
|
12653
|
+
"tune-finetune": (c) => handleTuneFinetune(c.tune),
|
|
12654
|
+
"tune-generate": (c) => handleTuneGenerate(c.tune),
|
|
12655
|
+
"vision-finetune": (c) => handleVisionFinetune(c.vision),
|
|
12656
|
+
"vision-generate": (c) => handleVisionGenerate(c.vision),
|
|
12657
|
+
"agent-list": (c) => handleAgentList(c.agent),
|
|
12658
|
+
"exit": async () => {
|
|
12659
|
+
(0, import_prompts.outro)("Goodbye!");
|
|
12660
|
+
process.exit(0);
|
|
12661
|
+
}
|
|
12662
|
+
};
|
|
12663
|
+
while (true) {
|
|
12664
|
+
const operation = await (0, import_prompts.select)({
|
|
12665
|
+
message: "Select an operation:",
|
|
12666
|
+
options: [
|
|
12667
|
+
{ value: "group-agents", label: "\u{1F916} Agents (Server)", hint: "Chat with custom agents" },
|
|
12668
|
+
{ value: "agent-list", label: " \u21B3 List & Run Agents" },
|
|
12669
|
+
{ value: "group-tune", label: "\u{1F9E0} Langtune (LLM)", hint: "Fine-tuning & Text Generation" },
|
|
12670
|
+
{ value: "tune-finetune", label: " \u21B3 Fine-tune Text Model" },
|
|
12671
|
+
{ value: "tune-generate", label: " \u21B3 Generate Text" },
|
|
12672
|
+
{ value: "group-vision", label: "\u{1F441}\uFE0F Langvision (Vision)", hint: "Vision Analysis & Tuning" },
|
|
12673
|
+
{ value: "vision-finetune", label: " \u21B3 Fine-tune Vision Model" },
|
|
12674
|
+
{ value: "vision-generate", label: " \u21B3 Generate Vision Response" },
|
|
12675
|
+
{ value: "group-settings", label: "\u2699\uFE0F Settings" },
|
|
12676
|
+
{ value: "login", label: " \u21B3 Update API Key" },
|
|
12677
|
+
{ value: "exit", label: " \u21B3 Exit" }
|
|
12678
|
+
]
|
|
12679
|
+
});
|
|
12680
|
+
if ((0, import_prompts.isCancel)(operation)) {
|
|
12681
|
+
(0, import_prompts.outro)("Goodbye!");
|
|
12682
|
+
process.exit(0);
|
|
12683
|
+
}
|
|
12684
|
+
if (typeof operation === "string") {
|
|
12685
|
+
if (operation.startsWith("group-")) continue;
|
|
12686
|
+
const handler = handlers[operation];
|
|
12687
|
+
if (handler) {
|
|
12688
|
+
try {
|
|
12689
|
+
const currentConfig = getConfig();
|
|
12690
|
+
const clients = {
|
|
12691
|
+
vision: new Langvision({ apiKey: currentConfig.apiKey }),
|
|
12692
|
+
tune: new Langtune({ apiKey: currentConfig.apiKey }),
|
|
12693
|
+
agent: new AgentClient({ apiKey: currentConfig.apiKey, baseUrl: currentConfig.baseUrl })
|
|
12694
|
+
};
|
|
12695
|
+
await handler(clients);
|
|
12696
|
+
} catch (error) {
|
|
12697
|
+
(0, import_prompts.outro)((0, import_colors.red)(`Error: ${error.message}`));
|
|
12698
|
+
}
|
|
12699
|
+
}
|
|
12587
12700
|
}
|
|
12588
|
-
} catch (error) {
|
|
12589
|
-
(0, import_prompts.outro)((0, import_colors.red)(`Error: ${error.message}`));
|
|
12590
|
-
process.exit(1);
|
|
12591
12701
|
}
|
|
12592
|
-
(0, import_prompts.outro)((0, import_colors.green)("Operation completed successfully!"));
|
|
12593
12702
|
});
|
|
12594
12703
|
program.parse(process.argv);
|
|
12595
12704
|
}
|
|
12596
|
-
async function
|
|
12705
|
+
async function handleLogin() {
|
|
12706
|
+
const apiKey = await (0, import_prompts.password)({
|
|
12707
|
+
message: "Enter your new Langtrain API Key:",
|
|
12708
|
+
validate(value) {
|
|
12709
|
+
if (!value || value.length === 0) return "API Key is required";
|
|
12710
|
+
}
|
|
12711
|
+
});
|
|
12712
|
+
if ((0, import_prompts.isCancel)(apiKey)) (0, import_prompts.cancel)("Operation cancelled");
|
|
12713
|
+
const config = getConfig();
|
|
12714
|
+
saveConfig({ ...config, apiKey });
|
|
12715
|
+
(0, import_prompts.intro)((0, import_colors.green)("API Key updated successfully!"));
|
|
12716
|
+
}
|
|
12717
|
+
async function handleAgentList(client) {
|
|
12718
|
+
const s = (0, import_prompts.spinner)();
|
|
12719
|
+
s.start("Fetching agents...");
|
|
12720
|
+
const agents = await client.list();
|
|
12721
|
+
s.stop(`Found ${agents.length} agents`);
|
|
12722
|
+
if (agents.length === 0) {
|
|
12723
|
+
(0, import_prompts.intro)((0, import_colors.yellow)("No agents found in your workspace."));
|
|
12724
|
+
return;
|
|
12725
|
+
}
|
|
12726
|
+
const agentId = await (0, import_prompts.select)({
|
|
12727
|
+
message: "Select an agent to run:",
|
|
12728
|
+
options: agents.map((a) => ({ value: a.id, label: a.name, hint: a.description || "No description" }))
|
|
12729
|
+
});
|
|
12730
|
+
if ((0, import_prompts.isCancel)(agentId)) return;
|
|
12731
|
+
await handleAgentRun(client, agentId, agents.find((a) => a.id === agentId)?.name || "Agent");
|
|
12732
|
+
}
|
|
12733
|
+
async function handleAgentRun(client, agentId, agentName) {
|
|
12734
|
+
(0, import_prompts.intro)((0, import_colors.bgCyan)((0, import_colors.black)(` Chatting with ${agentName} `)));
|
|
12735
|
+
console.log((0, import_colors.gray)('Type "exit" to quit conversation.'));
|
|
12736
|
+
let conversationId = void 0;
|
|
12737
|
+
while (true) {
|
|
12738
|
+
const input = await (0, import_prompts.text)({
|
|
12739
|
+
message: "You:",
|
|
12740
|
+
placeholder: "Type a message..."
|
|
12741
|
+
});
|
|
12742
|
+
if ((0, import_prompts.isCancel)(input) || input === "exit") {
|
|
12743
|
+
break;
|
|
12744
|
+
}
|
|
12745
|
+
const s = (0, import_prompts.spinner)();
|
|
12746
|
+
s.start("Agent is thinking...");
|
|
12747
|
+
try {
|
|
12748
|
+
const result = await client.execute(agentId, { prompt: input }, [], conversationId);
|
|
12749
|
+
s.stop();
|
|
12750
|
+
if (result.output && result.output.response) {
|
|
12751
|
+
console.log(import_gradient_string.default.pastel(`Agent: ${result.output.response}`));
|
|
12752
|
+
} else {
|
|
12753
|
+
console.log(import_gradient_string.default.pastel(`Agent: ${JSON.stringify(result.output)}`));
|
|
12754
|
+
}
|
|
12755
|
+
conversationId = result.conversation_id;
|
|
12756
|
+
} catch (e) {
|
|
12757
|
+
s.stop((0, import_colors.red)("Error running agent."));
|
|
12758
|
+
console.error(e);
|
|
12759
|
+
}
|
|
12760
|
+
}
|
|
12761
|
+
}
|
|
12762
|
+
async function handleTuneFinetune(tune) {
|
|
12597
12763
|
const model = await (0, import_prompts.text)({
|
|
12598
12764
|
message: "Enter base model (e.g., gpt-3.5-turbo):",
|
|
12599
12765
|
placeholder: "gpt-3.5-turbo",
|
|
@@ -12617,7 +12783,9 @@ async function handleTuneFinetune() {
|
|
|
12617
12783
|
});
|
|
12618
12784
|
if ((0, import_prompts.isCancel)(epochs)) (0, import_prompts.cancel)("Operation cancelled.");
|
|
12619
12785
|
const s = (0, import_prompts.spinner)();
|
|
12620
|
-
s.start("
|
|
12786
|
+
s.start("Connecting to Langtrain Cloud...");
|
|
12787
|
+
await new Promise((r) => setTimeout(r, 800));
|
|
12788
|
+
s.message("Starting fine-tuning job...");
|
|
12621
12789
|
try {
|
|
12622
12790
|
const config = {
|
|
12623
12791
|
model,
|
|
@@ -12631,13 +12799,13 @@ async function handleTuneFinetune() {
|
|
|
12631
12799
|
outputDir: "./output"
|
|
12632
12800
|
};
|
|
12633
12801
|
await tune.finetune(config);
|
|
12634
|
-
s.stop((0, import_colors.green)("Fine-tuning job started!"));
|
|
12802
|
+
s.stop((0, import_colors.green)("Fine-tuning job started successfully! \u{1F680}"));
|
|
12635
12803
|
} catch (e) {
|
|
12636
12804
|
s.stop((0, import_colors.red)("Failed to start job."));
|
|
12637
12805
|
throw e;
|
|
12638
12806
|
}
|
|
12639
12807
|
}
|
|
12640
|
-
async function handleTuneGenerate() {
|
|
12808
|
+
async function handleTuneGenerate(tune) {
|
|
12641
12809
|
const model = await (0, import_prompts.text)({
|
|
12642
12810
|
message: "Enter model path:",
|
|
12643
12811
|
placeholder: "./output/model",
|
|
@@ -12650,18 +12818,18 @@ async function handleTuneGenerate() {
|
|
|
12650
12818
|
});
|
|
12651
12819
|
if ((0, import_prompts.isCancel)(prompt)) (0, import_prompts.cancel)("Operation cancelled");
|
|
12652
12820
|
const s = (0, import_prompts.spinner)();
|
|
12653
|
-
s.start("
|
|
12821
|
+
s.start("Connecting to Langtrain Inference API...");
|
|
12654
12822
|
try {
|
|
12655
12823
|
const response = await tune.generate(model, { prompt });
|
|
12656
12824
|
s.stop("Generation complete");
|
|
12657
12825
|
(0, import_prompts.intro)("Response:");
|
|
12658
|
-
console.log(response);
|
|
12826
|
+
console.log(import_gradient_string.default.pastel(response));
|
|
12659
12827
|
} catch (e) {
|
|
12660
12828
|
s.stop((0, import_colors.red)("Generation failed."));
|
|
12661
12829
|
throw e;
|
|
12662
12830
|
}
|
|
12663
12831
|
}
|
|
12664
|
-
async function handleVisionFinetune() {
|
|
12832
|
+
async function handleVisionFinetune(vision) {
|
|
12665
12833
|
const model = await (0, import_prompts.text)({
|
|
12666
12834
|
message: "Enter base vision model:",
|
|
12667
12835
|
placeholder: "llava-v1.5-7b",
|
|
@@ -12679,7 +12847,9 @@ async function handleVisionFinetune() {
|
|
|
12679
12847
|
initialValue: "3"
|
|
12680
12848
|
});
|
|
12681
12849
|
const s = (0, import_prompts.spinner)();
|
|
12682
|
-
s.start("
|
|
12850
|
+
s.start("Analyzing dataset structure...");
|
|
12851
|
+
await new Promise((r) => setTimeout(r, 800));
|
|
12852
|
+
s.message("Starting vision fine-tuning on Langtrain Cloud...");
|
|
12683
12853
|
try {
|
|
12684
12854
|
const config = {
|
|
12685
12855
|
model,
|
|
@@ -12691,13 +12861,13 @@ async function handleVisionFinetune() {
|
|
|
12691
12861
|
outputDir: "./vision-output"
|
|
12692
12862
|
};
|
|
12693
12863
|
await vision.finetune(config);
|
|
12694
|
-
s.stop((0, import_colors.green)("Vision fine-tuning started!"));
|
|
12864
|
+
s.stop((0, import_colors.green)("Vision fine-tuning started successfully! \u{1F441}\uFE0F"));
|
|
12695
12865
|
} catch (e) {
|
|
12696
12866
|
s.stop((0, import_colors.red)("Failed to start vision job."));
|
|
12697
12867
|
throw e;
|
|
12698
12868
|
}
|
|
12699
12869
|
}
|
|
12700
|
-
async function handleVisionGenerate() {
|
|
12870
|
+
async function handleVisionGenerate(vision) {
|
|
12701
12871
|
const model = await (0, import_prompts.text)({
|
|
12702
12872
|
message: "Enter model path:",
|
|
12703
12873
|
placeholder: "./vision-output/model",
|
|
@@ -12711,12 +12881,14 @@ async function handleVisionGenerate() {
|
|
|
12711
12881
|
});
|
|
12712
12882
|
if ((0, import_prompts.isCancel)(prompt)) (0, import_prompts.cancel)("Operation cancelled");
|
|
12713
12883
|
const s = (0, import_prompts.spinner)();
|
|
12714
|
-
s.start("
|
|
12884
|
+
s.start("Uploading image and context...");
|
|
12885
|
+
await new Promise((r) => setTimeout(r, 600));
|
|
12886
|
+
s.message("Generating vision response...");
|
|
12715
12887
|
try {
|
|
12716
12888
|
const response = await vision.generate(model, { prompt });
|
|
12717
12889
|
s.stop("Generation complete");
|
|
12718
12890
|
(0, import_prompts.intro)("Response:");
|
|
12719
|
-
console.log(response);
|
|
12891
|
+
console.log(import_gradient_string.default.pastel(response));
|
|
12720
12892
|
} catch (e) {
|
|
12721
12893
|
s.stop((0, import_colors.red)("Generation failed."));
|
|
12722
12894
|
throw e;
|