@absolutejs/absolute 0.19.0-beta.605 → 0.19.0-beta.606
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 +53 -1
- package/dist/ai/client/index.js.map +4 -4
- package/dist/ai/client/ui.js +53 -1
- package/dist/ai/client/ui.js.map +4 -4
- package/dist/ai/index.js +94 -4
- package/dist/ai/index.js.map +6 -6
- package/dist/ai/rag/quality.js.map +2 -2
- package/dist/ai/rag/ui.js +53 -1
- package/dist/ai/rag/ui.js.map +4 -4
- package/dist/ai-client/angular/ai/index.js +52 -0
- package/dist/ai-client/react/ai/index.js +82 -7
- package/dist/ai-client/vue/ai/index.js +76 -1
- package/dist/angular/ai/index.js +53 -1
- package/dist/angular/ai/index.js.map +4 -4
- package/dist/react/ai/index.js +83 -8
- package/dist/react/ai/index.js.map +6 -6
- package/dist/src/react/ai/useRAG.d.ts +4 -0
- package/dist/src/react/ai/useRAGChunkPreview.d.ts +3 -0
- package/dist/src/react/ai/useRAGSources.d.ts +1 -0
- package/dist/src/svelte/ai/createRAG.d.ts +4 -0
- package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +3 -0
- package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
- package/dist/src/vue/ai/useRAG.d.ts +4 -0
- package/dist/src/vue/ai/useRAGChunkPreview.d.ts +3 -0
- package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
- package/dist/svelte/ai/index.js +90 -3
- package/dist/svelte/ai/index.js.map +6 -6
- package/dist/types/ai.d.ts +7 -1
- package/dist/vue/ai/index.js +77 -2
- package/dist/vue/ai/index.js.map +6 -6
- package/package.json +1 -1
|
@@ -1250,11 +1250,13 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1250
1250
|
const existing = sections.get(sectionId);
|
|
1251
1251
|
if (!existing) {
|
|
1252
1252
|
sections.set(sectionId, {
|
|
1253
|
+
childSectionIds: [],
|
|
1253
1254
|
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
1254
1255
|
chunkIds: [chunk.chunkId],
|
|
1255
1256
|
depth: structure.section?.depth,
|
|
1256
1257
|
id: sectionId,
|
|
1257
1258
|
kind: structure.section?.kind,
|
|
1259
|
+
leadChunkId: chunk.chunkId,
|
|
1258
1260
|
path: structure.section?.path,
|
|
1259
1261
|
title: structure.section?.title
|
|
1260
1262
|
});
|
|
@@ -1277,6 +1279,48 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1277
1279
|
}
|
|
1278
1280
|
return left.localeCompare(right);
|
|
1279
1281
|
});
|
|
1282
|
+
section.leadChunkId = section.chunkIds[0];
|
|
1283
|
+
}
|
|
1284
|
+
const sectionPathIndex = new Map;
|
|
1285
|
+
for (const section of sections.values()) {
|
|
1286
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1287
|
+
if (path && path.length > 0) {
|
|
1288
|
+
sectionPathIndex.set(path.join("\x00"), section);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
for (const section of sections.values()) {
|
|
1292
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1293
|
+
if (!path || path.length < 2) {
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
|
|
1297
|
+
if (!parent || parent.id === section.id) {
|
|
1298
|
+
continue;
|
|
1299
|
+
}
|
|
1300
|
+
section.parentSectionId = parent.id;
|
|
1301
|
+
if (!parent.childSectionIds.includes(section.id)) {
|
|
1302
|
+
parent.childSectionIds.push(section.id);
|
|
1303
|
+
}
|
|
1304
|
+
if (parent.leadChunkId && section.leadChunkId) {
|
|
1305
|
+
const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
|
|
1306
|
+
if (!edgeKeys.has(parentKey)) {
|
|
1307
|
+
edgeKeys.add(parentKey);
|
|
1308
|
+
edges.push({
|
|
1309
|
+
fromChunkId: section.leadChunkId,
|
|
1310
|
+
relation: "section_parent",
|
|
1311
|
+
toChunkId: parent.leadChunkId
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
|
|
1315
|
+
if (!edgeKeys.has(childKey)) {
|
|
1316
|
+
edgeKeys.add(childKey);
|
|
1317
|
+
edges.push({
|
|
1318
|
+
fromChunkId: parent.leadChunkId,
|
|
1319
|
+
relation: "section_child",
|
|
1320
|
+
toChunkId: section.leadChunkId
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1280
1324
|
}
|
|
1281
1325
|
nodes.sort((left, right) => {
|
|
1282
1326
|
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -1310,6 +1354,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1310
1354
|
if (graph.nodes.length === 0) {
|
|
1311
1355
|
return {
|
|
1312
1356
|
activeChunkId,
|
|
1357
|
+
childSections: [],
|
|
1358
|
+
siblingSections: [],
|
|
1313
1359
|
sectionNodes: []
|
|
1314
1360
|
};
|
|
1315
1361
|
}
|
|
@@ -1318,13 +1364,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1318
1364
|
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
1319
1365
|
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
1320
1366
|
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
1367
|
+
const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
|
|
1368
|
+
const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
|
|
1369
|
+
const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
|
|
1321
1370
|
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
1322
1371
|
return {
|
|
1323
1372
|
activeChunkId: resolvedActiveChunkId,
|
|
1324
1373
|
activeNode,
|
|
1374
|
+
childSections,
|
|
1325
1375
|
nextNode,
|
|
1376
|
+
parentSection,
|
|
1326
1377
|
previousNode,
|
|
1327
1378
|
section,
|
|
1379
|
+
siblingSections,
|
|
1328
1380
|
sectionNodes
|
|
1329
1381
|
};
|
|
1330
1382
|
};
|
|
@@ -1210,11 +1210,13 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1210
1210
|
const existing = sections.get(sectionId);
|
|
1211
1211
|
if (!existing) {
|
|
1212
1212
|
sections.set(sectionId, {
|
|
1213
|
+
childSectionIds: [],
|
|
1213
1214
|
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
1214
1215
|
chunkIds: [chunk.chunkId],
|
|
1215
1216
|
depth: structure.section?.depth,
|
|
1216
1217
|
id: sectionId,
|
|
1217
1218
|
kind: structure.section?.kind,
|
|
1219
|
+
leadChunkId: chunk.chunkId,
|
|
1218
1220
|
path: structure.section?.path,
|
|
1219
1221
|
title: structure.section?.title
|
|
1220
1222
|
});
|
|
@@ -1237,6 +1239,48 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1237
1239
|
}
|
|
1238
1240
|
return left.localeCompare(right);
|
|
1239
1241
|
});
|
|
1242
|
+
section.leadChunkId = section.chunkIds[0];
|
|
1243
|
+
}
|
|
1244
|
+
const sectionPathIndex = new Map;
|
|
1245
|
+
for (const section of sections.values()) {
|
|
1246
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1247
|
+
if (path && path.length > 0) {
|
|
1248
|
+
sectionPathIndex.set(path.join("\x00"), section);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
for (const section of sections.values()) {
|
|
1252
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1253
|
+
if (!path || path.length < 2) {
|
|
1254
|
+
continue;
|
|
1255
|
+
}
|
|
1256
|
+
const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
|
|
1257
|
+
if (!parent || parent.id === section.id) {
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
section.parentSectionId = parent.id;
|
|
1261
|
+
if (!parent.childSectionIds.includes(section.id)) {
|
|
1262
|
+
parent.childSectionIds.push(section.id);
|
|
1263
|
+
}
|
|
1264
|
+
if (parent.leadChunkId && section.leadChunkId) {
|
|
1265
|
+
const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
|
|
1266
|
+
if (!edgeKeys.has(parentKey)) {
|
|
1267
|
+
edgeKeys.add(parentKey);
|
|
1268
|
+
edges.push({
|
|
1269
|
+
fromChunkId: section.leadChunkId,
|
|
1270
|
+
relation: "section_parent",
|
|
1271
|
+
toChunkId: parent.leadChunkId
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
|
|
1275
|
+
if (!edgeKeys.has(childKey)) {
|
|
1276
|
+
edgeKeys.add(childKey);
|
|
1277
|
+
edges.push({
|
|
1278
|
+
fromChunkId: parent.leadChunkId,
|
|
1279
|
+
relation: "section_child",
|
|
1280
|
+
toChunkId: section.leadChunkId
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1240
1284
|
}
|
|
1241
1285
|
nodes.sort((left, right) => {
|
|
1242
1286
|
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -1270,6 +1314,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1270
1314
|
if (graph.nodes.length === 0) {
|
|
1271
1315
|
return {
|
|
1272
1316
|
activeChunkId,
|
|
1317
|
+
childSections: [],
|
|
1318
|
+
siblingSections: [],
|
|
1273
1319
|
sectionNodes: []
|
|
1274
1320
|
};
|
|
1275
1321
|
}
|
|
@@ -1278,13 +1324,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1278
1324
|
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
1279
1325
|
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
1280
1326
|
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
1327
|
+
const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
|
|
1328
|
+
const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
|
|
1329
|
+
const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
|
|
1281
1330
|
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
1282
1331
|
return {
|
|
1283
1332
|
activeChunkId: resolvedActiveChunkId,
|
|
1284
1333
|
activeNode,
|
|
1334
|
+
childSections,
|
|
1285
1335
|
nextNode,
|
|
1336
|
+
parentSection,
|
|
1286
1337
|
previousNode,
|
|
1287
1338
|
section,
|
|
1339
|
+
siblingSections,
|
|
1288
1340
|
sectionNodes
|
|
1289
1341
|
};
|
|
1290
1342
|
};
|
|
@@ -3019,6 +3071,24 @@ var useRAGChunkPreview = (path) => {
|
|
|
3019
3071
|
const selectChunk = useCallback2((id) => {
|
|
3020
3072
|
setActiveChunkId(id);
|
|
3021
3073
|
}, []);
|
|
3074
|
+
const selectParentSection = useCallback2(() => {
|
|
3075
|
+
const leadChunkId = navigation?.parentSection?.leadChunkId;
|
|
3076
|
+
if (leadChunkId) {
|
|
3077
|
+
setActiveChunkId(leadChunkId);
|
|
3078
|
+
}
|
|
3079
|
+
}, [navigation]);
|
|
3080
|
+
const selectChildSection = useCallback2((sectionId) => {
|
|
3081
|
+
const leadChunkId = navigation?.childSections.find((section) => section.id === sectionId)?.leadChunkId;
|
|
3082
|
+
if (leadChunkId) {
|
|
3083
|
+
setActiveChunkId(leadChunkId);
|
|
3084
|
+
}
|
|
3085
|
+
}, [navigation]);
|
|
3086
|
+
const selectSiblingSection = useCallback2((sectionId) => {
|
|
3087
|
+
const leadChunkId = navigation?.siblingSections.find((section) => section.id === sectionId)?.leadChunkId;
|
|
3088
|
+
if (leadChunkId) {
|
|
3089
|
+
setActiveChunkId(leadChunkId);
|
|
3090
|
+
}
|
|
3091
|
+
}, [navigation]);
|
|
3022
3092
|
return {
|
|
3023
3093
|
activeChunkId,
|
|
3024
3094
|
chunkGraph,
|
|
@@ -3028,7 +3098,10 @@ var useRAGChunkPreview = (path) => {
|
|
|
3028
3098
|
isLoading,
|
|
3029
3099
|
navigation,
|
|
3030
3100
|
preview,
|
|
3031
|
-
|
|
3101
|
+
selectChildSection,
|
|
3102
|
+
selectChunk,
|
|
3103
|
+
selectParentSection,
|
|
3104
|
+
selectSiblingSection
|
|
3032
3105
|
};
|
|
3033
3106
|
};
|
|
3034
3107
|
// src/react/ai/useRAG.ts
|
|
@@ -3603,7 +3676,7 @@ var useRAGSearch = (path) => {
|
|
|
3603
3676
|
};
|
|
3604
3677
|
|
|
3605
3678
|
// src/react/ai/useRAGSources.ts
|
|
3606
|
-
import { useMemo as useMemo10 } from "react";
|
|
3679
|
+
import { useCallback as useCallback9, useMemo as useMemo10 } from "react";
|
|
3607
3680
|
var useRAGSources = (messages) => {
|
|
3608
3681
|
const latestAssistantMessage = useMemo10(() => getLatestAssistantMessage(messages), [messages]);
|
|
3609
3682
|
const sources = useMemo10(() => getLatestRAGSources(messages), [messages]);
|
|
@@ -3611,11 +3684,13 @@ var useRAGSources = (messages) => {
|
|
|
3611
3684
|
const sourceSummaries = useMemo10(() => buildRAGSourceSummaries(sources), [sources]);
|
|
3612
3685
|
const chunkGraph = useMemo10(() => buildRAGChunkGraph(sources), [sources]);
|
|
3613
3686
|
const citationReferenceMap = useMemo10(() => buildRAGCitationReferenceMap(sourceSummaries.flatMap((summary) => summary.citations)), [sourceSummaries]);
|
|
3687
|
+
const navigationForChunk = useCallback9((chunkId) => buildRAGChunkGraphNavigation(chunkGraph, chunkId ?? undefined), [chunkGraph]);
|
|
3614
3688
|
return {
|
|
3615
3689
|
citationReferenceMap,
|
|
3616
3690
|
chunkGraph,
|
|
3617
3691
|
hasSources: sources.length > 0,
|
|
3618
3692
|
latestAssistantMessage,
|
|
3693
|
+
navigationForChunk,
|
|
3619
3694
|
sourceGroups,
|
|
3620
3695
|
sources,
|
|
3621
3696
|
sourceSummaries
|
|
@@ -3623,14 +3698,14 @@ var useRAGSources = (messages) => {
|
|
|
3623
3698
|
};
|
|
3624
3699
|
|
|
3625
3700
|
// src/react/ai/useRAGStatus.ts
|
|
3626
|
-
import { useCallback as
|
|
3701
|
+
import { useCallback as useCallback10, useEffect as useEffect4, useMemo as useMemo11, useState as useState8 } from "react";
|
|
3627
3702
|
var useRAGStatus = (path, autoLoad = true) => {
|
|
3628
3703
|
const client = useMemo11(() => createRAGClient({ path }), [path]);
|
|
3629
3704
|
const [status, setStatus] = useState8();
|
|
3630
3705
|
const [capabilities, setCapabilities] = useState8();
|
|
3631
3706
|
const [error, setError] = useState8(null);
|
|
3632
3707
|
const [isLoading, setIsLoading] = useState8(autoLoad);
|
|
3633
|
-
const refresh =
|
|
3708
|
+
const refresh = useCallback10(async () => {
|
|
3634
3709
|
setIsLoading(true);
|
|
3635
3710
|
setError(null);
|
|
3636
3711
|
try {
|
|
@@ -3646,7 +3721,7 @@ var useRAGStatus = (path, autoLoad = true) => {
|
|
|
3646
3721
|
setIsLoading(false);
|
|
3647
3722
|
}
|
|
3648
3723
|
}, [client]);
|
|
3649
|
-
const reset =
|
|
3724
|
+
const reset = useCallback10(() => {
|
|
3650
3725
|
setCapabilities(undefined);
|
|
3651
3726
|
setError(null);
|
|
3652
3727
|
setIsLoading(false);
|
|
@@ -3673,7 +3748,7 @@ var useRAGStatus = (path, autoLoad = true) => {
|
|
|
3673
3748
|
import { useMemo as useMemo13 } from "react";
|
|
3674
3749
|
|
|
3675
3750
|
// src/react/ai/useRAGStream.ts
|
|
3676
|
-
import { useCallback as
|
|
3751
|
+
import { useCallback as useCallback11, useMemo as useMemo12 } from "react";
|
|
3677
3752
|
var useRAGStream = (path, conversationId) => {
|
|
3678
3753
|
const stream = useAIStream(path, conversationId);
|
|
3679
3754
|
const workflow = useMemo12(() => buildRAGAnswerWorkflowState({
|
|
@@ -3703,7 +3778,7 @@ var useRAGStream = (path, conversationId) => {
|
|
|
3703
3778
|
sourceCount: workflow.sources.length,
|
|
3704
3779
|
stage: workflow.stage
|
|
3705
3780
|
}), [workflow]);
|
|
3706
|
-
const query =
|
|
3781
|
+
const query = useCallback11((content, attachments) => {
|
|
3707
3782
|
stream.send(content, attachments);
|
|
3708
3783
|
}, [stream]);
|
|
3709
3784
|
return {
|
|
@@ -2253,11 +2253,13 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
2253
2253
|
const existing = sections.get(sectionId);
|
|
2254
2254
|
if (!existing) {
|
|
2255
2255
|
sections.set(sectionId, {
|
|
2256
|
+
childSectionIds: [],
|
|
2256
2257
|
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
2257
2258
|
chunkIds: [chunk.chunkId],
|
|
2258
2259
|
depth: structure.section?.depth,
|
|
2259
2260
|
id: sectionId,
|
|
2260
2261
|
kind: structure.section?.kind,
|
|
2262
|
+
leadChunkId: chunk.chunkId,
|
|
2261
2263
|
path: structure.section?.path,
|
|
2262
2264
|
title: structure.section?.title
|
|
2263
2265
|
});
|
|
@@ -2280,6 +2282,48 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
2280
2282
|
}
|
|
2281
2283
|
return left.localeCompare(right);
|
|
2282
2284
|
});
|
|
2285
|
+
section.leadChunkId = section.chunkIds[0];
|
|
2286
|
+
}
|
|
2287
|
+
const sectionPathIndex = new Map;
|
|
2288
|
+
for (const section of sections.values()) {
|
|
2289
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
2290
|
+
if (path && path.length > 0) {
|
|
2291
|
+
sectionPathIndex.set(path.join("\x00"), section);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
for (const section of sections.values()) {
|
|
2295
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
2296
|
+
if (!path || path.length < 2) {
|
|
2297
|
+
continue;
|
|
2298
|
+
}
|
|
2299
|
+
const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
|
|
2300
|
+
if (!parent || parent.id === section.id) {
|
|
2301
|
+
continue;
|
|
2302
|
+
}
|
|
2303
|
+
section.parentSectionId = parent.id;
|
|
2304
|
+
if (!parent.childSectionIds.includes(section.id)) {
|
|
2305
|
+
parent.childSectionIds.push(section.id);
|
|
2306
|
+
}
|
|
2307
|
+
if (parent.leadChunkId && section.leadChunkId) {
|
|
2308
|
+
const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
|
|
2309
|
+
if (!edgeKeys.has(parentKey)) {
|
|
2310
|
+
edgeKeys.add(parentKey);
|
|
2311
|
+
edges.push({
|
|
2312
|
+
fromChunkId: section.leadChunkId,
|
|
2313
|
+
relation: "section_parent",
|
|
2314
|
+
toChunkId: parent.leadChunkId
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
|
|
2318
|
+
if (!edgeKeys.has(childKey)) {
|
|
2319
|
+
edgeKeys.add(childKey);
|
|
2320
|
+
edges.push({
|
|
2321
|
+
fromChunkId: parent.leadChunkId,
|
|
2322
|
+
relation: "section_child",
|
|
2323
|
+
toChunkId: section.leadChunkId
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2283
2327
|
}
|
|
2284
2328
|
nodes.sort((left, right) => {
|
|
2285
2329
|
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -2313,6 +2357,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
2313
2357
|
if (graph.nodes.length === 0) {
|
|
2314
2358
|
return {
|
|
2315
2359
|
activeChunkId,
|
|
2360
|
+
childSections: [],
|
|
2361
|
+
siblingSections: [],
|
|
2316
2362
|
sectionNodes: []
|
|
2317
2363
|
};
|
|
2318
2364
|
}
|
|
@@ -2321,13 +2367,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
2321
2367
|
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
2322
2368
|
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
2323
2369
|
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
2370
|
+
const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
|
|
2371
|
+
const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
|
|
2372
|
+
const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
|
|
2324
2373
|
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
2325
2374
|
return {
|
|
2326
2375
|
activeChunkId: resolvedActiveChunkId,
|
|
2327
2376
|
activeNode,
|
|
2377
|
+
childSections,
|
|
2328
2378
|
nextNode,
|
|
2379
|
+
parentSection,
|
|
2329
2380
|
previousNode,
|
|
2330
2381
|
section,
|
|
2382
|
+
siblingSections,
|
|
2331
2383
|
sectionNodes
|
|
2332
2384
|
};
|
|
2333
2385
|
};
|
|
@@ -2610,6 +2662,24 @@ var useRAGChunkPreview = (path) => {
|
|
|
2610
2662
|
const selectChunk = (id) => {
|
|
2611
2663
|
activeChunkId.value = id;
|
|
2612
2664
|
};
|
|
2665
|
+
const selectParentSection = () => {
|
|
2666
|
+
const leadChunkId = navigation.value?.parentSection?.leadChunkId;
|
|
2667
|
+
if (leadChunkId) {
|
|
2668
|
+
activeChunkId.value = leadChunkId;
|
|
2669
|
+
}
|
|
2670
|
+
};
|
|
2671
|
+
const selectChildSection = (sectionId) => {
|
|
2672
|
+
const leadChunkId = navigation.value?.childSections.find((section) => section.id === sectionId)?.leadChunkId;
|
|
2673
|
+
if (leadChunkId) {
|
|
2674
|
+
activeChunkId.value = leadChunkId;
|
|
2675
|
+
}
|
|
2676
|
+
};
|
|
2677
|
+
const selectSiblingSection = (sectionId) => {
|
|
2678
|
+
const leadChunkId = navigation.value?.siblingSections.find((section) => section.id === sectionId)?.leadChunkId;
|
|
2679
|
+
if (leadChunkId) {
|
|
2680
|
+
activeChunkId.value = leadChunkId;
|
|
2681
|
+
}
|
|
2682
|
+
};
|
|
2613
2683
|
return {
|
|
2614
2684
|
activeChunkId,
|
|
2615
2685
|
clear,
|
|
@@ -2619,7 +2689,10 @@ var useRAGChunkPreview = (path) => {
|
|
|
2619
2689
|
isLoading,
|
|
2620
2690
|
navigation,
|
|
2621
2691
|
preview,
|
|
2622
|
-
|
|
2692
|
+
selectChildSection,
|
|
2693
|
+
selectChunk,
|
|
2694
|
+
selectParentSection,
|
|
2695
|
+
selectSiblingSection
|
|
2623
2696
|
};
|
|
2624
2697
|
};
|
|
2625
2698
|
// src/vue/ai/useRAG.ts
|
|
@@ -3565,11 +3638,13 @@ var useRAGSources = (messages) => {
|
|
|
3565
3638
|
const chunkGraph = computed5(() => buildRAGChunkGraph(sources.value));
|
|
3566
3639
|
const citationReferenceMap = computed5(() => buildRAGCitationReferenceMap(sourceSummaries.value.flatMap((summary) => summary.citations)));
|
|
3567
3640
|
const hasSources = computed5(() => sources.value.length > 0);
|
|
3641
|
+
const navigationForChunk = (chunkId) => buildRAGChunkGraphNavigation(chunkGraph.value, chunkId ?? undefined);
|
|
3568
3642
|
return {
|
|
3569
3643
|
citationReferenceMap,
|
|
3570
3644
|
chunkGraph,
|
|
3571
3645
|
hasSources,
|
|
3572
3646
|
latestAssistantMessage,
|
|
3647
|
+
navigationForChunk,
|
|
3573
3648
|
sourceGroups,
|
|
3574
3649
|
sources,
|
|
3575
3650
|
sourceSummaries
|
package/dist/angular/ai/index.js
CHANGED
|
@@ -1800,11 +1800,13 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1800
1800
|
const existing = sections.get(sectionId);
|
|
1801
1801
|
if (!existing) {
|
|
1802
1802
|
sections.set(sectionId, {
|
|
1803
|
+
childSectionIds: [],
|
|
1803
1804
|
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
1804
1805
|
chunkIds: [chunk.chunkId],
|
|
1805
1806
|
depth: structure.section?.depth,
|
|
1806
1807
|
id: sectionId,
|
|
1807
1808
|
kind: structure.section?.kind,
|
|
1809
|
+
leadChunkId: chunk.chunkId,
|
|
1808
1810
|
path: structure.section?.path,
|
|
1809
1811
|
title: structure.section?.title
|
|
1810
1812
|
});
|
|
@@ -1827,6 +1829,48 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
1827
1829
|
}
|
|
1828
1830
|
return left.localeCompare(right);
|
|
1829
1831
|
});
|
|
1832
|
+
section.leadChunkId = section.chunkIds[0];
|
|
1833
|
+
}
|
|
1834
|
+
const sectionPathIndex = new Map;
|
|
1835
|
+
for (const section of sections.values()) {
|
|
1836
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1837
|
+
if (path && path.length > 0) {
|
|
1838
|
+
sectionPathIndex.set(path.join("\x00"), section);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
for (const section of sections.values()) {
|
|
1842
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
1843
|
+
if (!path || path.length < 2) {
|
|
1844
|
+
continue;
|
|
1845
|
+
}
|
|
1846
|
+
const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
|
|
1847
|
+
if (!parent || parent.id === section.id) {
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
section.parentSectionId = parent.id;
|
|
1851
|
+
if (!parent.childSectionIds.includes(section.id)) {
|
|
1852
|
+
parent.childSectionIds.push(section.id);
|
|
1853
|
+
}
|
|
1854
|
+
if (parent.leadChunkId && section.leadChunkId) {
|
|
1855
|
+
const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
|
|
1856
|
+
if (!edgeKeys.has(parentKey)) {
|
|
1857
|
+
edgeKeys.add(parentKey);
|
|
1858
|
+
edges.push({
|
|
1859
|
+
fromChunkId: section.leadChunkId,
|
|
1860
|
+
relation: "section_parent",
|
|
1861
|
+
toChunkId: parent.leadChunkId
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
|
|
1865
|
+
if (!edgeKeys.has(childKey)) {
|
|
1866
|
+
edgeKeys.add(childKey);
|
|
1867
|
+
edges.push({
|
|
1868
|
+
fromChunkId: parent.leadChunkId,
|
|
1869
|
+
relation: "section_child",
|
|
1870
|
+
toChunkId: section.leadChunkId
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1830
1874
|
}
|
|
1831
1875
|
nodes.sort((left, right) => {
|
|
1832
1876
|
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -1860,6 +1904,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1860
1904
|
if (graph.nodes.length === 0) {
|
|
1861
1905
|
return {
|
|
1862
1906
|
activeChunkId,
|
|
1907
|
+
childSections: [],
|
|
1908
|
+
siblingSections: [],
|
|
1863
1909
|
sectionNodes: []
|
|
1864
1910
|
};
|
|
1865
1911
|
}
|
|
@@ -1868,13 +1914,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
1868
1914
|
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
1869
1915
|
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
1870
1916
|
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
1917
|
+
const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
|
|
1918
|
+
const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
|
|
1919
|
+
const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
|
|
1871
1920
|
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
1872
1921
|
return {
|
|
1873
1922
|
activeChunkId: resolvedActiveChunkId,
|
|
1874
1923
|
activeNode,
|
|
1924
|
+
childSections,
|
|
1875
1925
|
nextNode,
|
|
1926
|
+
parentSection,
|
|
1876
1927
|
previousNode,
|
|
1877
1928
|
section,
|
|
1929
|
+
siblingSections,
|
|
1878
1930
|
sectionNodes
|
|
1879
1931
|
};
|
|
1880
1932
|
};
|
|
@@ -4082,5 +4134,5 @@ export {
|
|
|
4082
4134
|
AIStreamService
|
|
4083
4135
|
};
|
|
4084
4136
|
|
|
4085
|
-
//# debugId=
|
|
4137
|
+
//# debugId=6BA4A5140094B73664756E2164756E21
|
|
4086
4138
|
//# sourceMappingURL=index.js.map
|