@absolutejs/absolute 0.19.0-beta.623 → 0.19.0-beta.625
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/ai/client/index.js +8751 -6935
- package/dist/ai/client/index.js.map +5 -5
- package/dist/ai/client/ui.js +6402 -42
- package/dist/ai/client/ui.js.map +7 -4
- package/dist/ai/index.js +12994 -8132
- package/dist/ai/index.js.map +15 -13
- package/dist/ai/rag/quality.js +4194 -37
- package/dist/ai/rag/quality.js.map +6 -5
- package/dist/ai/rag/ui.js +6407 -42
- package/dist/ai/rag/ui.js.map +7 -4
- package/dist/ai-client/angular/ai/index.js +401 -4
- package/dist/ai-client/react/ai/index.js +537 -511
- package/dist/ai-client/vue/ai/index.js +743 -720
- package/dist/angular/ai/index.js +9400 -3140
- package/dist/angular/ai/index.js.map +7 -6
- package/dist/react/ai/index.js +8187 -6372
- package/dist/react/ai/index.js.map +5 -5
- package/dist/src/ai/index.d.ts +2 -2
- package/dist/src/ai/rag/adapters/filtering.d.ts +2 -0
- package/dist/src/ai/rag/adapters/queryPlanning.d.ts +11 -0
- package/dist/src/ai/rag/index.d.ts +4 -4
- package/dist/src/ai/rag/ingestion.d.ts +3 -0
- package/dist/src/ai/rag/presentation.d.ts +6 -1
- package/dist/src/ai/rag/quality.d.ts +95 -2
- package/dist/src/ai/rag/sync.d.ts +20 -1
- package/dist/src/ai/rag/types.d.ts +1 -1
- package/dist/src/ai/rag/ui.d.ts +1 -1
- package/dist/src/react/ai/useRAG.d.ts +1 -1
- package/dist/src/react/ai/useRAGIndexAdmin.d.ts +2 -2
- package/dist/src/vue/ai/useRAG.d.ts +408 -0
- package/dist/src/vue/ai/useRAGEvaluate.d.ts +84 -0
- package/dist/src/vue/ai/useRAGIndexAdmin.d.ts +222 -0
- package/dist/src/vue/ai/useRAGOps.d.ts +102 -0
- package/dist/src/vue/components/Image.d.ts +74 -0
- package/dist/src/vue/components/index.d.ts +1 -1
- package/dist/src/vue/index.d.ts +1 -1
- package/dist/svelte/ai/index.js +8186 -6371
- package/dist/svelte/ai/index.js.map +4 -4
- package/dist/types/ai.d.ts +389 -1
- package/dist/vue/ai/index.js +8186 -6371
- package/dist/vue/ai/index.js.map +4 -4
- package/dist/vue/components/Image.js +253 -0
- package/dist/vue/components/Image.js.map +11 -0
- package/dist/vue/components/index.js +181 -16
- package/dist/vue/components/index.js.map +5 -3
- package/dist/vue/index.js +195 -30
- package/dist/vue/index.js.map +6 -4
- package/package.json +11 -11
- package/dist/Image-0pe96k20.vue +0 -186
- package/dist/vue/components/Image.vue +0 -186
- package/dist/vue/components/Image.vue.d.ts +0 -4
|
@@ -1183,6 +1183,378 @@ var buildRAGGroundingReferences = (sources) => {
|
|
|
1183
1183
|
});
|
|
1184
1184
|
};
|
|
1185
1185
|
|
|
1186
|
+
// src/ai/rag/quality.ts
|
|
1187
|
+
var {mkdir, readFile, writeFile} = (() => ({}));
|
|
1188
|
+
|
|
1189
|
+
// node:path
|
|
1190
|
+
function assertPath(path) {
|
|
1191
|
+
if (typeof path !== "string")
|
|
1192
|
+
throw TypeError("Path must be a string. Received " + JSON.stringify(path));
|
|
1193
|
+
}
|
|
1194
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
1195
|
+
var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
|
|
1196
|
+
for (var i = 0;i <= path.length; ++i) {
|
|
1197
|
+
if (i < path.length)
|
|
1198
|
+
code = path.charCodeAt(i);
|
|
1199
|
+
else if (code === 47)
|
|
1200
|
+
break;
|
|
1201
|
+
else
|
|
1202
|
+
code = 47;
|
|
1203
|
+
if (code === 47) {
|
|
1204
|
+
if (lastSlash === i - 1 || dots === 1)
|
|
1205
|
+
;
|
|
1206
|
+
else if (lastSlash !== i - 1 && dots === 2) {
|
|
1207
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
|
1208
|
+
if (res.length > 2) {
|
|
1209
|
+
var lastSlashIndex = res.lastIndexOf("/");
|
|
1210
|
+
if (lastSlashIndex !== res.length - 1) {
|
|
1211
|
+
if (lastSlashIndex === -1)
|
|
1212
|
+
res = "", lastSegmentLength = 0;
|
|
1213
|
+
else
|
|
1214
|
+
res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
1215
|
+
lastSlash = i, dots = 0;
|
|
1216
|
+
continue;
|
|
1217
|
+
}
|
|
1218
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
1219
|
+
res = "", lastSegmentLength = 0, lastSlash = i, dots = 0;
|
|
1220
|
+
continue;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
if (allowAboveRoot) {
|
|
1224
|
+
if (res.length > 0)
|
|
1225
|
+
res += "/..";
|
|
1226
|
+
else
|
|
1227
|
+
res = "..";
|
|
1228
|
+
lastSegmentLength = 2;
|
|
1229
|
+
}
|
|
1230
|
+
} else {
|
|
1231
|
+
if (res.length > 0)
|
|
1232
|
+
res += "/" + path.slice(lastSlash + 1, i);
|
|
1233
|
+
else
|
|
1234
|
+
res = path.slice(lastSlash + 1, i);
|
|
1235
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
1236
|
+
}
|
|
1237
|
+
lastSlash = i, dots = 0;
|
|
1238
|
+
} else if (code === 46 && dots !== -1)
|
|
1239
|
+
++dots;
|
|
1240
|
+
else
|
|
1241
|
+
dots = -1;
|
|
1242
|
+
}
|
|
1243
|
+
return res;
|
|
1244
|
+
}
|
|
1245
|
+
function _format(sep, pathObject) {
|
|
1246
|
+
var dir = pathObject.dir || pathObject.root, base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
1247
|
+
if (!dir)
|
|
1248
|
+
return base;
|
|
1249
|
+
if (dir === pathObject.root)
|
|
1250
|
+
return dir + base;
|
|
1251
|
+
return dir + sep + base;
|
|
1252
|
+
}
|
|
1253
|
+
function resolve() {
|
|
1254
|
+
var resolvedPath = "", resolvedAbsolute = false, cwd;
|
|
1255
|
+
for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
|
|
1256
|
+
var path;
|
|
1257
|
+
if (i >= 0)
|
|
1258
|
+
path = arguments[i];
|
|
1259
|
+
else {
|
|
1260
|
+
if (cwd === undefined)
|
|
1261
|
+
cwd = process.cwd();
|
|
1262
|
+
path = cwd;
|
|
1263
|
+
}
|
|
1264
|
+
if (assertPath(path), path.length === 0)
|
|
1265
|
+
continue;
|
|
1266
|
+
resolvedPath = path + "/" + resolvedPath, resolvedAbsolute = path.charCodeAt(0) === 47;
|
|
1267
|
+
}
|
|
1268
|
+
if (resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute)
|
|
1269
|
+
if (resolvedPath.length > 0)
|
|
1270
|
+
return "/" + resolvedPath;
|
|
1271
|
+
else
|
|
1272
|
+
return "/";
|
|
1273
|
+
else if (resolvedPath.length > 0)
|
|
1274
|
+
return resolvedPath;
|
|
1275
|
+
else
|
|
1276
|
+
return ".";
|
|
1277
|
+
}
|
|
1278
|
+
function normalize(path) {
|
|
1279
|
+
if (assertPath(path), path.length === 0)
|
|
1280
|
+
return ".";
|
|
1281
|
+
var isAbsolute = path.charCodeAt(0) === 47, trailingSeparator = path.charCodeAt(path.length - 1) === 47;
|
|
1282
|
+
if (path = normalizeStringPosix(path, !isAbsolute), path.length === 0 && !isAbsolute)
|
|
1283
|
+
path = ".";
|
|
1284
|
+
if (path.length > 0 && trailingSeparator)
|
|
1285
|
+
path += "/";
|
|
1286
|
+
if (isAbsolute)
|
|
1287
|
+
return "/" + path;
|
|
1288
|
+
return path;
|
|
1289
|
+
}
|
|
1290
|
+
function isAbsolute(path) {
|
|
1291
|
+
return assertPath(path), path.length > 0 && path.charCodeAt(0) === 47;
|
|
1292
|
+
}
|
|
1293
|
+
function join() {
|
|
1294
|
+
if (arguments.length === 0)
|
|
1295
|
+
return ".";
|
|
1296
|
+
var joined;
|
|
1297
|
+
for (var i = 0;i < arguments.length; ++i) {
|
|
1298
|
+
var arg = arguments[i];
|
|
1299
|
+
if (assertPath(arg), arg.length > 0)
|
|
1300
|
+
if (joined === undefined)
|
|
1301
|
+
joined = arg;
|
|
1302
|
+
else
|
|
1303
|
+
joined += "/" + arg;
|
|
1304
|
+
}
|
|
1305
|
+
if (joined === undefined)
|
|
1306
|
+
return ".";
|
|
1307
|
+
return normalize(joined);
|
|
1308
|
+
}
|
|
1309
|
+
function relative(from, to) {
|
|
1310
|
+
if (assertPath(from), assertPath(to), from === to)
|
|
1311
|
+
return "";
|
|
1312
|
+
if (from = resolve(from), to = resolve(to), from === to)
|
|
1313
|
+
return "";
|
|
1314
|
+
var fromStart = 1;
|
|
1315
|
+
for (;fromStart < from.length; ++fromStart)
|
|
1316
|
+
if (from.charCodeAt(fromStart) !== 47)
|
|
1317
|
+
break;
|
|
1318
|
+
var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1;
|
|
1319
|
+
for (;toStart < to.length; ++toStart)
|
|
1320
|
+
if (to.charCodeAt(toStart) !== 47)
|
|
1321
|
+
break;
|
|
1322
|
+
var toEnd = to.length, toLen = toEnd - toStart, length = fromLen < toLen ? fromLen : toLen, lastCommonSep = -1, i = 0;
|
|
1323
|
+
for (;i <= length; ++i) {
|
|
1324
|
+
if (i === length) {
|
|
1325
|
+
if (toLen > length) {
|
|
1326
|
+
if (to.charCodeAt(toStart + i) === 47)
|
|
1327
|
+
return to.slice(toStart + i + 1);
|
|
1328
|
+
else if (i === 0)
|
|
1329
|
+
return to.slice(toStart + i);
|
|
1330
|
+
} else if (fromLen > length) {
|
|
1331
|
+
if (from.charCodeAt(fromStart + i) === 47)
|
|
1332
|
+
lastCommonSep = i;
|
|
1333
|
+
else if (i === 0)
|
|
1334
|
+
lastCommonSep = 0;
|
|
1335
|
+
}
|
|
1336
|
+
break;
|
|
1337
|
+
}
|
|
1338
|
+
var fromCode = from.charCodeAt(fromStart + i), toCode = to.charCodeAt(toStart + i);
|
|
1339
|
+
if (fromCode !== toCode)
|
|
1340
|
+
break;
|
|
1341
|
+
else if (fromCode === 47)
|
|
1342
|
+
lastCommonSep = i;
|
|
1343
|
+
}
|
|
1344
|
+
var out = "";
|
|
1345
|
+
for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i)
|
|
1346
|
+
if (i === fromEnd || from.charCodeAt(i) === 47)
|
|
1347
|
+
if (out.length === 0)
|
|
1348
|
+
out += "..";
|
|
1349
|
+
else
|
|
1350
|
+
out += "/..";
|
|
1351
|
+
if (out.length > 0)
|
|
1352
|
+
return out + to.slice(toStart + lastCommonSep);
|
|
1353
|
+
else {
|
|
1354
|
+
if (toStart += lastCommonSep, to.charCodeAt(toStart) === 47)
|
|
1355
|
+
++toStart;
|
|
1356
|
+
return to.slice(toStart);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
function _makeLong(path) {
|
|
1360
|
+
return path;
|
|
1361
|
+
}
|
|
1362
|
+
function dirname(path) {
|
|
1363
|
+
if (assertPath(path), path.length === 0)
|
|
1364
|
+
return ".";
|
|
1365
|
+
var code = path.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = true;
|
|
1366
|
+
for (var i = path.length - 1;i >= 1; --i)
|
|
1367
|
+
if (code = path.charCodeAt(i), code === 47) {
|
|
1368
|
+
if (!matchedSlash) {
|
|
1369
|
+
end = i;
|
|
1370
|
+
break;
|
|
1371
|
+
}
|
|
1372
|
+
} else
|
|
1373
|
+
matchedSlash = false;
|
|
1374
|
+
if (end === -1)
|
|
1375
|
+
return hasRoot ? "/" : ".";
|
|
1376
|
+
if (hasRoot && end === 1)
|
|
1377
|
+
return "//";
|
|
1378
|
+
return path.slice(0, end);
|
|
1379
|
+
}
|
|
1380
|
+
function basename(path, ext) {
|
|
1381
|
+
if (ext !== undefined && typeof ext !== "string")
|
|
1382
|
+
throw TypeError('"ext" argument must be a string');
|
|
1383
|
+
assertPath(path);
|
|
1384
|
+
var start = 0, end = -1, matchedSlash = true, i;
|
|
1385
|
+
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
1386
|
+
if (ext.length === path.length && ext === path)
|
|
1387
|
+
return "";
|
|
1388
|
+
var extIdx = ext.length - 1, firstNonSlashEnd = -1;
|
|
1389
|
+
for (i = path.length - 1;i >= 0; --i) {
|
|
1390
|
+
var code = path.charCodeAt(i);
|
|
1391
|
+
if (code === 47) {
|
|
1392
|
+
if (!matchedSlash) {
|
|
1393
|
+
start = i + 1;
|
|
1394
|
+
break;
|
|
1395
|
+
}
|
|
1396
|
+
} else {
|
|
1397
|
+
if (firstNonSlashEnd === -1)
|
|
1398
|
+
matchedSlash = false, firstNonSlashEnd = i + 1;
|
|
1399
|
+
if (extIdx >= 0)
|
|
1400
|
+
if (code === ext.charCodeAt(extIdx)) {
|
|
1401
|
+
if (--extIdx === -1)
|
|
1402
|
+
end = i;
|
|
1403
|
+
} else
|
|
1404
|
+
extIdx = -1, end = firstNonSlashEnd;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
if (start === end)
|
|
1408
|
+
end = firstNonSlashEnd;
|
|
1409
|
+
else if (end === -1)
|
|
1410
|
+
end = path.length;
|
|
1411
|
+
return path.slice(start, end);
|
|
1412
|
+
} else {
|
|
1413
|
+
for (i = path.length - 1;i >= 0; --i)
|
|
1414
|
+
if (path.charCodeAt(i) === 47) {
|
|
1415
|
+
if (!matchedSlash) {
|
|
1416
|
+
start = i + 1;
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
} else if (end === -1)
|
|
1420
|
+
matchedSlash = false, end = i + 1;
|
|
1421
|
+
if (end === -1)
|
|
1422
|
+
return "";
|
|
1423
|
+
return path.slice(start, end);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
function extname(path) {
|
|
1427
|
+
assertPath(path);
|
|
1428
|
+
var startDot = -1, startPart = 0, end = -1, matchedSlash = true, preDotState = 0;
|
|
1429
|
+
for (var i = path.length - 1;i >= 0; --i) {
|
|
1430
|
+
var code = path.charCodeAt(i);
|
|
1431
|
+
if (code === 47) {
|
|
1432
|
+
if (!matchedSlash) {
|
|
1433
|
+
startPart = i + 1;
|
|
1434
|
+
break;
|
|
1435
|
+
}
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
if (end === -1)
|
|
1439
|
+
matchedSlash = false, end = i + 1;
|
|
1440
|
+
if (code === 46) {
|
|
1441
|
+
if (startDot === -1)
|
|
1442
|
+
startDot = i;
|
|
1443
|
+
else if (preDotState !== 1)
|
|
1444
|
+
preDotState = 1;
|
|
1445
|
+
} else if (startDot !== -1)
|
|
1446
|
+
preDotState = -1;
|
|
1447
|
+
}
|
|
1448
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
|
|
1449
|
+
return "";
|
|
1450
|
+
return path.slice(startDot, end);
|
|
1451
|
+
}
|
|
1452
|
+
function format(pathObject) {
|
|
1453
|
+
if (pathObject === null || typeof pathObject !== "object")
|
|
1454
|
+
throw TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
1455
|
+
return _format("/", pathObject);
|
|
1456
|
+
}
|
|
1457
|
+
function parse(path) {
|
|
1458
|
+
assertPath(path);
|
|
1459
|
+
var ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
1460
|
+
if (path.length === 0)
|
|
1461
|
+
return ret;
|
|
1462
|
+
var code = path.charCodeAt(0), isAbsolute2 = code === 47, start;
|
|
1463
|
+
if (isAbsolute2)
|
|
1464
|
+
ret.root = "/", start = 1;
|
|
1465
|
+
else
|
|
1466
|
+
start = 0;
|
|
1467
|
+
var startDot = -1, startPart = 0, end = -1, matchedSlash = true, i = path.length - 1, preDotState = 0;
|
|
1468
|
+
for (;i >= start; --i) {
|
|
1469
|
+
if (code = path.charCodeAt(i), code === 47) {
|
|
1470
|
+
if (!matchedSlash) {
|
|
1471
|
+
startPart = i + 1;
|
|
1472
|
+
break;
|
|
1473
|
+
}
|
|
1474
|
+
continue;
|
|
1475
|
+
}
|
|
1476
|
+
if (end === -1)
|
|
1477
|
+
matchedSlash = false, end = i + 1;
|
|
1478
|
+
if (code === 46) {
|
|
1479
|
+
if (startDot === -1)
|
|
1480
|
+
startDot = i;
|
|
1481
|
+
else if (preDotState !== 1)
|
|
1482
|
+
preDotState = 1;
|
|
1483
|
+
} else if (startDot !== -1)
|
|
1484
|
+
preDotState = -1;
|
|
1485
|
+
}
|
|
1486
|
+
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
1487
|
+
if (end !== -1)
|
|
1488
|
+
if (startPart === 0 && isAbsolute2)
|
|
1489
|
+
ret.base = ret.name = path.slice(1, end);
|
|
1490
|
+
else
|
|
1491
|
+
ret.base = ret.name = path.slice(startPart, end);
|
|
1492
|
+
} else {
|
|
1493
|
+
if (startPart === 0 && isAbsolute2)
|
|
1494
|
+
ret.name = path.slice(1, startDot), ret.base = path.slice(1, end);
|
|
1495
|
+
else
|
|
1496
|
+
ret.name = path.slice(startPart, startDot), ret.base = path.slice(startPart, end);
|
|
1497
|
+
ret.ext = path.slice(startDot, end);
|
|
1498
|
+
}
|
|
1499
|
+
if (startPart > 0)
|
|
1500
|
+
ret.dir = path.slice(0, startPart - 1);
|
|
1501
|
+
else if (isAbsolute2)
|
|
1502
|
+
ret.dir = "/";
|
|
1503
|
+
return ret;
|
|
1504
|
+
}
|
|
1505
|
+
var sep = "/";
|
|
1506
|
+
var delimiter = ":";
|
|
1507
|
+
var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
|
|
1508
|
+
|
|
1509
|
+
// src/ai/rag/quality.ts
|
|
1510
|
+
var buildRAGEvaluationLeaderboard = (runs) => {
|
|
1511
|
+
const sorted = [...runs].sort((left, right) => {
|
|
1512
|
+
if (right.response.passingRate !== left.response.passingRate) {
|
|
1513
|
+
return right.response.passingRate - left.response.passingRate;
|
|
1514
|
+
}
|
|
1515
|
+
if (right.response.summary.averageF1 !== left.response.summary.averageF1) {
|
|
1516
|
+
return right.response.summary.averageF1 - left.response.summary.averageF1;
|
|
1517
|
+
}
|
|
1518
|
+
return left.response.summary.averageLatencyMs - right.response.summary.averageLatencyMs;
|
|
1519
|
+
});
|
|
1520
|
+
return sorted.map((run, index) => ({
|
|
1521
|
+
averageF1: run.response.summary.averageF1,
|
|
1522
|
+
averageLatencyMs: run.response.summary.averageLatencyMs,
|
|
1523
|
+
label: run.label,
|
|
1524
|
+
passingRate: run.response.passingRate,
|
|
1525
|
+
rank: index + 1,
|
|
1526
|
+
runId: run.id,
|
|
1527
|
+
suiteId: run.suiteId,
|
|
1528
|
+
totalCases: run.response.totalCases
|
|
1529
|
+
}));
|
|
1530
|
+
};
|
|
1531
|
+
var runRAGEvaluationSuite = async ({
|
|
1532
|
+
suite,
|
|
1533
|
+
evaluate,
|
|
1534
|
+
overrides,
|
|
1535
|
+
artifacts
|
|
1536
|
+
}) => {
|
|
1537
|
+
const startedAt = Date.now();
|
|
1538
|
+
const response = await evaluate({
|
|
1539
|
+
...suite.input,
|
|
1540
|
+
...overrides,
|
|
1541
|
+
cases: overrides?.cases ?? suite.input.cases
|
|
1542
|
+
});
|
|
1543
|
+
const finishedAt = Date.now();
|
|
1544
|
+
return {
|
|
1545
|
+
caseTraceSnapshots: artifacts?.caseTraceSnapshots,
|
|
1546
|
+
elapsedMs: finishedAt - startedAt,
|
|
1547
|
+
finishedAt,
|
|
1548
|
+
id: generateId(),
|
|
1549
|
+
label: suite.label ?? suite.id,
|
|
1550
|
+
metadata: suite.metadata,
|
|
1551
|
+
response,
|
|
1552
|
+
startedAt,
|
|
1553
|
+
suiteId: suite.id,
|
|
1554
|
+
traceSummary: artifacts?.traceSummary
|
|
1555
|
+
};
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1186
1558
|
// src/ai/rag/presentation.ts
|
|
1187
1559
|
var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.chunkId;
|
|
1188
1560
|
var buildSourceLabel2 = (source) => source.source ?? source.title ?? source.chunkId;
|
|
@@ -1376,6 +1748,8 @@ var buildContextLabel2 = (metadata) => {
|
|
|
1376
1748
|
const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
1377
1749
|
const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
1378
1750
|
const hasOCRTrace = typeof metadata.ocrRegionConfidence === "number" || typeof metadata.ocrConfidence === "number" || getContextString2(metadata.pdfTextMode) === "ocr" || typeof metadata.ocrRegionCount === "number";
|
|
1751
|
+
const ocrPageStart = getContextNumber2(metadata.ocrPageStart);
|
|
1752
|
+
const ocrPageEnd = getContextNumber2(metadata.ocrPageEnd);
|
|
1379
1753
|
if (page && region) {
|
|
1380
1754
|
if (hasOCRTrace) {
|
|
1381
1755
|
return `OCR page ${page} region ${region}`;
|
|
@@ -1388,6 +1762,9 @@ var buildContextLabel2 = (metadata) => {
|
|
|
1388
1762
|
}
|
|
1389
1763
|
return `Page ${page}`;
|
|
1390
1764
|
}
|
|
1765
|
+
if (hasOCRTrace && typeof ocrPageStart === "number" && typeof ocrPageEnd === "number") {
|
|
1766
|
+
return ocrPageStart === ocrPageEnd ? `OCR page ${ocrPageStart}` : `OCR pages ${ocrPageStart}-${ocrPageEnd}`;
|
|
1767
|
+
}
|
|
1391
1768
|
const sheet = getContextString2(metadata.sheetName) ?? (Array.isArray(metadata.sheetNames) ? getContextString2(metadata.sheetNames[0]) : undefined);
|
|
1392
1769
|
if (sheet) {
|
|
1393
1770
|
const tableLabel = formatSpreadsheetTableLabel(getContextNumber2(metadata.spreadsheetTableIndex), getContextNumber2(metadata.spreadsheetTableCount));
|
|
@@ -1458,6 +1835,8 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
1458
1835
|
const slideTitle = getContextString2(metadata.slideTitle);
|
|
1459
1836
|
const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
|
|
1460
1837
|
const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
|
|
1838
|
+
const ocrPageStart = getContextNumber2(metadata.ocrPageStart);
|
|
1839
|
+
const ocrPageEnd = getContextNumber2(metadata.ocrPageEnd);
|
|
1461
1840
|
if (page && region) {
|
|
1462
1841
|
return `Page ${page} · Region ${region}`;
|
|
1463
1842
|
}
|
|
@@ -1470,6 +1849,9 @@ var buildLocatorLabel2 = (metadata, source, title) => {
|
|
|
1470
1849
|
if (page) {
|
|
1471
1850
|
return `Page ${page}`;
|
|
1472
1851
|
}
|
|
1852
|
+
if (typeof ocrPageStart === "number" && typeof ocrPageEnd === "number") {
|
|
1853
|
+
return ocrPageStart === ocrPageEnd ? `Page ${ocrPageStart}` : `Pages ${ocrPageStart}-${ocrPageEnd}`;
|
|
1854
|
+
}
|
|
1473
1855
|
const sheet = getContextString2(metadata.sheetName) ?? (Array.isArray(metadata.sheetNames) ? getContextString2(metadata.sheetNames[0]) : undefined);
|
|
1474
1856
|
if (sheet) {
|
|
1475
1857
|
const tableLabel = formatSpreadsheetTableLabel(getContextNumber2(metadata.spreadsheetTableIndex), getContextNumber2(metadata.spreadsheetTableCount));
|
|
@@ -1574,6 +1956,8 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
1574
1956
|
const spreadsheetTableLabel = formatSpreadsheetTableLabel(getContextNumber2(metadata.spreadsheetTableIndex), getContextNumber2(metadata.spreadsheetTableCount));
|
|
1575
1957
|
const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
|
|
1576
1958
|
const ocrAverageConfidence = getContextNumber2(metadata.ocrPageAverageConfidence) ?? getContextNumber2(metadata.ocrAverageConfidence);
|
|
1959
|
+
const ocrMinConfidence = getContextNumber2(metadata.ocrPageMinConfidence) ?? getContextNumber2(metadata.ocrMinConfidence);
|
|
1960
|
+
const ocrMaxConfidence = getContextNumber2(metadata.ocrPageMaxConfidence) ?? getContextNumber2(metadata.ocrMaxConfidence);
|
|
1577
1961
|
const ocrRegionCount = getContextNumber2(metadata.ocrRegionCount);
|
|
1578
1962
|
const labels = [
|
|
1579
1963
|
pdfTextMode ? `PDF ${pdfTextMode}` : "",
|
|
@@ -1586,6 +1970,7 @@ var buildProvenanceLabel2 = (metadata) => {
|
|
|
1586
1970
|
sourceAwareUnitScope ?? "",
|
|
1587
1971
|
typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
|
|
1588
1972
|
typeof ocrAverageConfidence === "number" && ocrAverageConfidence !== ocrConfidence ? `Average ${ocrAverageConfidence.toFixed(2)}` : "",
|
|
1973
|
+
typeof ocrMinConfidence === "number" && typeof ocrMaxConfidence === "number" && ocrMinConfidence !== ocrMaxConfidence ? `Range ${ocrMinConfidence.toFixed(2)}-${ocrMaxConfidence.toFixed(2)}` : "",
|
|
1589
1974
|
typeof ocrRegionCount === "number" ? `${ocrRegionCount} regions` : "",
|
|
1590
1975
|
spreadsheetHeaders.length > 0 ? `Spreadsheet ${spreadsheetHeaders.join(", ")}` : "",
|
|
1591
1976
|
spreadsheetColumnRange ? `Spreadsheet ${spreadsheetColumnRange}` : "",
|
|
@@ -1681,12 +2066,17 @@ var buildRAGChunkExcerpts = (chunks, activeChunkId) => {
|
|
|
1681
2066
|
return;
|
|
1682
2067
|
}
|
|
1683
2068
|
const chunkMap = new Map(chunks.map((chunk) => [chunk.chunkId, chunk]));
|
|
1684
|
-
const
|
|
2069
|
+
const orderedSectionIds = navigation.sectionNodes.length > 0 ? navigation.sectionNodes.map((node) => node.chunkId) : [activeChunk.chunkId];
|
|
2070
|
+
const orderedWindowIds = navigation.sectionNodes.length > 0 ? (() => {
|
|
2071
|
+
const activeIndex = navigation.sectionNodes.findIndex((node) => node.chunkId === activeChunk.chunkId);
|
|
2072
|
+
const startIndex = Math.max(0, activeIndex - 2);
|
|
2073
|
+
const endIndex = Math.min(navigation.sectionNodes.length, activeIndex + 3);
|
|
2074
|
+
return navigation.sectionNodes.slice(startIndex, endIndex).map((node) => node.chunkId);
|
|
2075
|
+
})() : [
|
|
1685
2076
|
navigation.previousNode?.chunkId,
|
|
1686
2077
|
activeChunk.chunkId,
|
|
1687
2078
|
navigation.nextNode?.chunkId
|
|
1688
2079
|
].filter((chunkId, index, ids) => Boolean(chunkId) && ids.indexOf(chunkId) === index);
|
|
1689
|
-
const orderedSectionIds = navigation.sectionNodes.length > 0 ? navigation.sectionNodes.map((node) => node.chunkId) : [activeChunk.chunkId];
|
|
1690
2080
|
const collectText = (chunkIds) => chunkIds.map((chunkId) => chunkMap.get(chunkId)?.text).filter((text) => typeof text === "string").join(`
|
|
1691
2081
|
|
|
1692
2082
|
`);
|
|
@@ -2101,6 +2491,9 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
2101
2491
|
const parentShare = parentTotal > 0 ? section.totalScore / parentTotal : undefined;
|
|
2102
2492
|
const topChunk = sources.find((source) => source.chunkId === section.topChunkId);
|
|
2103
2493
|
const topContextLabel = topChunk?.labels?.contextLabel ?? buildContextLabel2(topChunk?.metadata);
|
|
2494
|
+
const topLocatorLabel = topChunk?.labels?.locatorLabel ?? buildLocatorLabel2(topChunk?.metadata, topChunk?.source, topChunk?.title);
|
|
2495
|
+
const sourceAwareChunkReason = formatSourceAwareChunkReason(topChunk?.metadata?.sourceAwareChunkReason);
|
|
2496
|
+
const sourceAwareUnitScopeLabel = buildSourceAwareUnitScopeLabel(topChunk?.metadata);
|
|
2104
2497
|
const parentDistribution = parentTotal > 0 ? siblingPool.map((entry) => ({
|
|
2105
2498
|
count: entry.count,
|
|
2106
2499
|
isActive: entry.key === section.key,
|
|
@@ -2231,8 +2624,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
2231
2624
|
`${(scoreShare * 100).toFixed(0)}% score share`,
|
|
2232
2625
|
`vector ${section.vectorHits} · lexical ${section.lexicalHits} · hybrid ${section.hybridHits}`,
|
|
2233
2626
|
typeof parentShare === "number" ? `${(parentShare * 100).toFixed(0)}% of parent section set` : "",
|
|
2234
|
-
|
|
2235
|
-
|
|
2627
|
+
sourceAwareChunkReason ? `boundary ${sourceAwareChunkReason}` : "",
|
|
2628
|
+
sourceAwareUnitScopeLabel ? `scope ${sourceAwareUnitScopeLabel}` : "",
|
|
2236
2629
|
strongestSibling ? `ahead of ${strongestSibling.label} by ${(section.totalScore - strongestSibling.totalScore).toFixed(2)}` : "no sibling competition"
|
|
2237
2630
|
].filter(Boolean);
|
|
2238
2631
|
return {
|
|
@@ -2277,6 +2670,10 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
|
|
|
2277
2670
|
siblingCount: siblings.length,
|
|
2278
2671
|
siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
|
|
2279
2672
|
sourceCount: section.sourceSet.size,
|
|
2673
|
+
sourceAwareChunkReasonLabel: sourceAwareChunkReason,
|
|
2674
|
+
sourceAwareUnitScopeLabel,
|
|
2675
|
+
topContextLabel,
|
|
2676
|
+
topLocatorLabel,
|
|
2280
2677
|
sourceBalanceApplied: trace?.steps.some((step) => step.stage === "source_balance"),
|
|
2281
2678
|
strongestSiblingLabel: strongestSibling?.label,
|
|
2282
2679
|
strongestSiblingScore: strongestSibling?.totalScore,
|