tune-sdk 0.2.18 → 0.2.20
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/bin/cli.js +1 -1
- package/dist/tune.js +22 -13
- package/package.json +1 -1
- package/src/cli.js +3 -0
package/bin/cli.js
CHANGED
package/dist/tune.js
CHANGED
|
@@ -1159,9 +1159,8 @@ async function resolve(ctx, name, args, middlewares) {
|
|
|
1159
1159
|
}));
|
|
1160
1160
|
if (!item.type) {
|
|
1161
1161
|
_ref = undefined;
|
|
1162
|
-
throw Error(tpl("resolved '@{name}' node must have a 'type' property
|
|
1163
|
-
name: name
|
|
1164
|
-
item: JSON.stringify(item)
|
|
1162
|
+
throw Error(tpl("resolved '@{name}' node must have a 'type' property", {
|
|
1163
|
+
name: name
|
|
1165
1164
|
}));
|
|
1166
1165
|
} else {
|
|
1167
1166
|
_ref = undefined;
|
|
@@ -2182,7 +2181,7 @@ function text2run(text, ctx, opts) {
|
|
|
2182
2181
|
return JSON.parse(item);
|
|
2183
2182
|
}));
|
|
2184
2183
|
it = it.reduce((function(msg, chunk) {
|
|
2185
|
-
var delta, tc, tcIdx;
|
|
2184
|
+
var delta, tc, tcIdx, func;
|
|
2186
2185
|
if (chunk.usage) usage = chunk.usage;
|
|
2187
2186
|
var delta;
|
|
2188
2187
|
delta = (((typeof chunk !== "undefined") && (chunk !== null) && !Number.isNaN(chunk) && (typeof chunk.choices !== "undefined") && (chunk.choices !== null) && !Number.isNaN(chunk.choices) && (typeof chunk.choices[0] !== "undefined") && (chunk.choices[0] !== null) && !Number.isNaN(chunk.choices[0]) && (typeof chunk.choices[0].delta !== "undefined") && (chunk.choices[0].delta !== null) && !Number.isNaN(chunk.choices[0].delta)) ? chunk.choices[0].delta : (((typeof {} !== "undefined") && ({} !== null) && !Number.isNaN({})) ? {} : undefined));
|
|
@@ -2195,11 +2194,21 @@ function text2run(text, ctx, opts) {
|
|
|
2195
2194
|
if (delta.content) {
|
|
2196
2195
|
msg.content = msg.content || "";
|
|
2197
2196
|
msg.content += delta.content;
|
|
2198
|
-
}
|
|
2197
|
+
}
|
|
2198
|
+
if (delta.reasoning) {
|
|
2199
|
+
msg.reasoning = msg.reasoning || "";
|
|
2200
|
+
msg.reasoning += delta.reasoning;
|
|
2201
|
+
}
|
|
2202
|
+
if (delta.tool_calls) {
|
|
2199
2203
|
msg.tool_calls = msg.tool_calls || [];
|
|
2200
2204
|
tc = delta.tool_calls[0];
|
|
2201
2205
|
tcIdx = tc.index || 0;
|
|
2202
|
-
!msg.tool_calls[tcIdx]
|
|
2206
|
+
if (!msg.tool_calls[tcIdx]) {
|
|
2207
|
+
msg.tool_calls[tcIdx] = tc;
|
|
2208
|
+
} else {
|
|
2209
|
+
func = msg.tool_calls[tcIdx].function;
|
|
2210
|
+
func.arguments = (func.arguments || "") + (tc.function.arguments || "");
|
|
2211
|
+
}
|
|
2203
2212
|
}
|
|
2204
2213
|
return msg;
|
|
2205
2214
|
}), {
|
|
@@ -2240,7 +2249,7 @@ function text2run(text, ctx, opts) {
|
|
|
2240
2249
|
}
|
|
2241
2250
|
text2run;
|
|
2242
2251
|
async function file2run(args, params, ctx) {
|
|
2243
|
-
var lctx, text, stop, node, response, res, r, chunk,
|
|
2252
|
+
var lctx, text, stop, node, response, res, r, chunk, itergH2RRGq, _ref;
|
|
2244
2253
|
var lctx;
|
|
2245
2254
|
lctx = ctx.clone();
|
|
2246
2255
|
if (params) lctx.ms.unshift(envmd(params));
|
|
@@ -2307,7 +2316,7 @@ async function file2run(args, params, ctx) {
|
|
|
2307
2316
|
stream: true
|
|
2308
2317
|
});
|
|
2309
2318
|
chunk = {};
|
|
2310
|
-
|
|
2319
|
+
itergH2RRGq = new AsyncIter();
|
|
2311
2320
|
(async function($lastRes) {
|
|
2312
2321
|
var _ref;
|
|
2313
2322
|
try {
|
|
@@ -2316,20 +2325,20 @@ async function file2run(args, params, ctx) {
|
|
|
2316
2325
|
res = (chunk.value || "");
|
|
2317
2326
|
if (chunk.done) await save();
|
|
2318
2327
|
$lastRes = transformOutput(res) || $lastRes;
|
|
2319
|
-
|
|
2328
|
+
itergH2RRGq.result = {
|
|
2320
2329
|
value: $lastRes
|
|
2321
2330
|
}
|
|
2322
2331
|
}
|
|
2323
|
-
_ref =
|
|
2332
|
+
_ref = itergH2RRGq.result = {
|
|
2324
2333
|
value: $lastRes,
|
|
2325
2334
|
done: true
|
|
2326
2335
|
}
|
|
2327
2336
|
} catch (e) {
|
|
2328
|
-
_ref = (
|
|
2337
|
+
_ref = (itergH2RRGq.err = e);
|
|
2329
2338
|
}
|
|
2330
2339
|
return _ref;
|
|
2331
2340
|
})();
|
|
2332
|
-
_ref =
|
|
2341
|
+
_ref = itergH2RRGq;
|
|
2333
2342
|
}
|
|
2334
2343
|
return _ref;
|
|
2335
2344
|
}
|
|
@@ -2604,4 +2613,4 @@ exports.payload2http = payload2http;
|
|
|
2604
2613
|
exports.envmd = envmd;
|
|
2605
2614
|
exports.unescape = unescape;
|
|
2606
2615
|
exports.escape = escape;
|
|
2607
|
-
exports.resolve = resolve;
|
|
2616
|
+
exports.resolve = resolve;
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -346,6 +346,9 @@ async function initContext(args) {
|
|
|
346
346
|
}));
|
|
347
347
|
dirs.push(getHomedir(args));
|
|
348
348
|
dirs.unshift(pwd);
|
|
349
|
+
if (process.env.TUNE_PATH) {
|
|
350
|
+
dirs = dirs.concat(process.env.TUNE_PATH.split(path.delimiter))
|
|
351
|
+
}
|
|
349
352
|
process.env.TUNE_PATH = dirs.join(path.delimiter);
|
|
350
353
|
ctx = tune.makeContext({
|
|
351
354
|
TUNE_PATH: process.env.TUNE_PATH,
|