tune-sdk 0.2.23 → 0.2.24
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/tune.js +13 -12
- package/package.json +1 -1
package/dist/tune.js
CHANGED
|
@@ -2282,7 +2282,7 @@ function text2run(text, ctx, opts) {
|
|
|
2282
2282
|
}
|
|
2283
2283
|
text2run;
|
|
2284
2284
|
async function file2run(args, params, ctx) {
|
|
2285
|
-
var lctx, text, stop, errors, turnsSaved, longFormatRegex, isLong, initialText,
|
|
2285
|
+
var lctx, text, stop, errors, turnsSaved, node, longFormatRegex, isLong, initialText, response, res, r, chunk, itergMKZ8fG, _ref;
|
|
2286
2286
|
var lctx;
|
|
2287
2287
|
lctx = ctx.clone();
|
|
2288
2288
|
if (params) lctx.ms.unshift(envmd(params));
|
|
@@ -2290,10 +2290,12 @@ async function file2run(args, params, ctx) {
|
|
|
2290
2290
|
var stop;
|
|
2291
2291
|
var errors;
|
|
2292
2292
|
var turnsSaved;
|
|
2293
|
+
var node;
|
|
2293
2294
|
text = args.text;
|
|
2294
2295
|
stop = (((typeof args !== "undefined") && (args !== null) && !Number.isNaN(args) && (typeof args.stop !== "undefined") && (args.stop !== null) && !Number.isNaN(args.stop)) ? args.stop : (((typeof "assistant" !== "undefined") && ("assistant" !== null) && !Number.isNaN("assistant")) ? "assistant" : undefined));
|
|
2295
2296
|
errors = (((typeof args !== "undefined") && (args !== null) && !Number.isNaN(args) && (typeof args.errors !== "undefined") && (args.errors !== null) && !Number.isNaN(args.errors)) ? args.errors : (((typeof "throw" !== "undefined") && ("throw" !== null) && !Number.isNaN("throw")) ? "throw" : undefined));
|
|
2296
2297
|
turnsSaved = 0;
|
|
2298
|
+
node = null;
|
|
2297
2299
|
var longFormatRegex;
|
|
2298
2300
|
var isLong;
|
|
2299
2301
|
longFormatRegex = /^(system|user|tool_call|tool_result|assistant|error):/;
|
|
@@ -2314,22 +2316,21 @@ async function file2run(args, params, ctx) {
|
|
|
2314
2316
|
initialText = (args.system ? tpl("system:\n{system}", args) : "");
|
|
2315
2317
|
if (args.filename) {
|
|
2316
2318
|
node = await ctx.resolve(args.filename);
|
|
2317
|
-
if (node) lctx.stack.push(node);
|
|
2318
2319
|
if ((node && !text)) text = await node.read();
|
|
2319
2320
|
}
|
|
2320
2321
|
if ((!text && args.system)) text = initialText;
|
|
2321
2322
|
text = text || "";
|
|
2323
|
+
if (args.user) text += ((text ? "\n" : "") + tpl("user:\n{user}", args));
|
|
2322
2324
|
node = node || {
|
|
2323
|
-
type: "text"
|
|
2324
|
-
read: (async function() {
|
|
2325
|
-
return text;
|
|
2326
|
-
})
|
|
2325
|
+
type: "text"
|
|
2327
2326
|
}
|
|
2328
2327
|
node.name = args.filename;
|
|
2329
2328
|
node.fullname = args.filename;
|
|
2330
2329
|
node.mimetype = "text/chat";
|
|
2330
|
+
node.read = (async function() {
|
|
2331
|
+
return text;
|
|
2332
|
+
});
|
|
2331
2333
|
lctx.stack.push(node);
|
|
2332
|
-
if (args.user) text += ((text ? "\n" : "") + tpl("user:\n{user}", args));
|
|
2333
2334
|
if (!text) throw new TuneError("ether 'text' or 'system' or 'user' should be specified or 'filename' should exist ");
|
|
2334
2335
|
isLong = longFormatRegex.test(text);
|
|
2335
2336
|
var response;
|
|
@@ -2373,7 +2374,7 @@ async function file2run(args, params, ctx) {
|
|
|
2373
2374
|
hookTurnEnd: save
|
|
2374
2375
|
});
|
|
2375
2376
|
chunk = {};
|
|
2376
|
-
|
|
2377
|
+
itergMKZ8fG = new AsyncIter();
|
|
2377
2378
|
(async function($lastRes) {
|
|
2378
2379
|
var _ref;
|
|
2379
2380
|
try {
|
|
@@ -2381,20 +2382,20 @@ async function file2run(args, params, ctx) {
|
|
|
2381
2382
|
chunk = await r.next();
|
|
2382
2383
|
res = (chunk.value || "");
|
|
2383
2384
|
$lastRes = transformOutput(res) || $lastRes;
|
|
2384
|
-
|
|
2385
|
+
itergMKZ8fG.result = {
|
|
2385
2386
|
value: $lastRes
|
|
2386
2387
|
}
|
|
2387
2388
|
}
|
|
2388
|
-
_ref =
|
|
2389
|
+
_ref = itergMKZ8fG.result = {
|
|
2389
2390
|
value: $lastRes,
|
|
2390
2391
|
done: true
|
|
2391
2392
|
}
|
|
2392
2393
|
} catch (e) {
|
|
2393
|
-
_ref = (
|
|
2394
|
+
_ref = (itergMKZ8fG.err = e);
|
|
2394
2395
|
}
|
|
2395
2396
|
return _ref;
|
|
2396
2397
|
})();
|
|
2397
|
-
_ref =
|
|
2398
|
+
_ref = itergMKZ8fG;
|
|
2398
2399
|
}
|
|
2399
2400
|
return _ref;
|
|
2400
2401
|
}
|