@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
package/dist/react/ai/index.js
CHANGED
|
@@ -4204,11 +4204,13 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
4204
4204
|
const existing = sections.get(sectionId);
|
|
4205
4205
|
if (!existing) {
|
|
4206
4206
|
sections.set(sectionId, {
|
|
4207
|
+
childSectionIds: [],
|
|
4207
4208
|
chunkCount: structure.sequence?.sectionChunkCount ?? 1,
|
|
4208
4209
|
chunkIds: [chunk.chunkId],
|
|
4209
4210
|
depth: structure.section?.depth,
|
|
4210
4211
|
id: sectionId,
|
|
4211
4212
|
kind: structure.section?.kind,
|
|
4213
|
+
leadChunkId: chunk.chunkId,
|
|
4212
4214
|
path: structure.section?.path,
|
|
4213
4215
|
title: structure.section?.title
|
|
4214
4216
|
});
|
|
@@ -4231,6 +4233,48 @@ var buildRAGChunkGraph = (chunks) => {
|
|
|
4231
4233
|
}
|
|
4232
4234
|
return left.localeCompare(right);
|
|
4233
4235
|
});
|
|
4236
|
+
section.leadChunkId = section.chunkIds[0];
|
|
4237
|
+
}
|
|
4238
|
+
const sectionPathIndex = new Map;
|
|
4239
|
+
for (const section of sections.values()) {
|
|
4240
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
4241
|
+
if (path && path.length > 0) {
|
|
4242
|
+
sectionPathIndex.set(path.join("\x00"), section);
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
for (const section of sections.values()) {
|
|
4246
|
+
const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
|
|
4247
|
+
if (!path || path.length < 2) {
|
|
4248
|
+
continue;
|
|
4249
|
+
}
|
|
4250
|
+
const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
|
|
4251
|
+
if (!parent || parent.id === section.id) {
|
|
4252
|
+
continue;
|
|
4253
|
+
}
|
|
4254
|
+
section.parentSectionId = parent.id;
|
|
4255
|
+
if (!parent.childSectionIds.includes(section.id)) {
|
|
4256
|
+
parent.childSectionIds.push(section.id);
|
|
4257
|
+
}
|
|
4258
|
+
if (parent.leadChunkId && section.leadChunkId) {
|
|
4259
|
+
const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
|
|
4260
|
+
if (!edgeKeys.has(parentKey)) {
|
|
4261
|
+
edgeKeys.add(parentKey);
|
|
4262
|
+
edges.push({
|
|
4263
|
+
fromChunkId: section.leadChunkId,
|
|
4264
|
+
relation: "section_parent",
|
|
4265
|
+
toChunkId: parent.leadChunkId
|
|
4266
|
+
});
|
|
4267
|
+
}
|
|
4268
|
+
const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
|
|
4269
|
+
if (!edgeKeys.has(childKey)) {
|
|
4270
|
+
edgeKeys.add(childKey);
|
|
4271
|
+
edges.push({
|
|
4272
|
+
fromChunkId: parent.leadChunkId,
|
|
4273
|
+
relation: "section_child",
|
|
4274
|
+
toChunkId: section.leadChunkId
|
|
4275
|
+
});
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4234
4278
|
}
|
|
4235
4279
|
nodes.sort((left, right) => {
|
|
4236
4280
|
const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
|
|
@@ -4264,6 +4308,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
4264
4308
|
if (graph.nodes.length === 0) {
|
|
4265
4309
|
return {
|
|
4266
4310
|
activeChunkId,
|
|
4311
|
+
childSections: [],
|
|
4312
|
+
siblingSections: [],
|
|
4267
4313
|
sectionNodes: []
|
|
4268
4314
|
};
|
|
4269
4315
|
}
|
|
@@ -4272,13 +4318,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
|
|
|
4272
4318
|
const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
|
|
4273
4319
|
const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
|
|
4274
4320
|
const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
|
|
4321
|
+
const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
|
|
4322
|
+
const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
|
|
4323
|
+
const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
|
|
4275
4324
|
const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
|
|
4276
4325
|
return {
|
|
4277
4326
|
activeChunkId: resolvedActiveChunkId,
|
|
4278
4327
|
activeNode,
|
|
4328
|
+
childSections,
|
|
4279
4329
|
nextNode,
|
|
4330
|
+
parentSection,
|
|
4280
4331
|
previousNode,
|
|
4281
4332
|
section,
|
|
4333
|
+
siblingSections,
|
|
4282
4334
|
sectionNodes
|
|
4283
4335
|
};
|
|
4284
4336
|
};
|
|
@@ -6995,6 +7047,24 @@ var useRAGChunkPreview = (path) => {
|
|
|
6995
7047
|
const selectChunk = useCallback2((id) => {
|
|
6996
7048
|
setActiveChunkId(id);
|
|
6997
7049
|
}, []);
|
|
7050
|
+
const selectParentSection = useCallback2(() => {
|
|
7051
|
+
const leadChunkId = navigation?.parentSection?.leadChunkId;
|
|
7052
|
+
if (leadChunkId) {
|
|
7053
|
+
setActiveChunkId(leadChunkId);
|
|
7054
|
+
}
|
|
7055
|
+
}, [navigation]);
|
|
7056
|
+
const selectChildSection = useCallback2((sectionId) => {
|
|
7057
|
+
const leadChunkId = navigation?.childSections.find((section) => section.id === sectionId)?.leadChunkId;
|
|
7058
|
+
if (leadChunkId) {
|
|
7059
|
+
setActiveChunkId(leadChunkId);
|
|
7060
|
+
}
|
|
7061
|
+
}, [navigation]);
|
|
7062
|
+
const selectSiblingSection = useCallback2((sectionId) => {
|
|
7063
|
+
const leadChunkId = navigation?.siblingSections.find((section) => section.id === sectionId)?.leadChunkId;
|
|
7064
|
+
if (leadChunkId) {
|
|
7065
|
+
setActiveChunkId(leadChunkId);
|
|
7066
|
+
}
|
|
7067
|
+
}, [navigation]);
|
|
6998
7068
|
return {
|
|
6999
7069
|
activeChunkId,
|
|
7000
7070
|
chunkGraph,
|
|
@@ -7004,7 +7074,10 @@ var useRAGChunkPreview = (path) => {
|
|
|
7004
7074
|
isLoading,
|
|
7005
7075
|
navigation,
|
|
7006
7076
|
preview,
|
|
7007
|
-
|
|
7077
|
+
selectChildSection,
|
|
7078
|
+
selectChunk,
|
|
7079
|
+
selectParentSection,
|
|
7080
|
+
selectSiblingSection
|
|
7008
7081
|
};
|
|
7009
7082
|
};
|
|
7010
7083
|
// src/react/ai/useRAG.ts
|
|
@@ -7579,7 +7652,7 @@ var useRAGSearch = (path) => {
|
|
|
7579
7652
|
};
|
|
7580
7653
|
|
|
7581
7654
|
// src/react/ai/useRAGSources.ts
|
|
7582
|
-
import { useMemo as useMemo10 } from "react";
|
|
7655
|
+
import { useCallback as useCallback9, useMemo as useMemo10 } from "react";
|
|
7583
7656
|
var useRAGSources = (messages) => {
|
|
7584
7657
|
const latestAssistantMessage = useMemo10(() => getLatestAssistantMessage(messages), [messages]);
|
|
7585
7658
|
const sources = useMemo10(() => getLatestRAGSources(messages), [messages]);
|
|
@@ -7587,11 +7660,13 @@ var useRAGSources = (messages) => {
|
|
|
7587
7660
|
const sourceSummaries = useMemo10(() => buildRAGSourceSummaries(sources), [sources]);
|
|
7588
7661
|
const chunkGraph = useMemo10(() => buildRAGChunkGraph(sources), [sources]);
|
|
7589
7662
|
const citationReferenceMap = useMemo10(() => buildRAGCitationReferenceMap(sourceSummaries.flatMap((summary) => summary.citations)), [sourceSummaries]);
|
|
7663
|
+
const navigationForChunk = useCallback9((chunkId) => buildRAGChunkGraphNavigation(chunkGraph, chunkId ?? undefined), [chunkGraph]);
|
|
7590
7664
|
return {
|
|
7591
7665
|
citationReferenceMap,
|
|
7592
7666
|
chunkGraph,
|
|
7593
7667
|
hasSources: sources.length > 0,
|
|
7594
7668
|
latestAssistantMessage,
|
|
7669
|
+
navigationForChunk,
|
|
7595
7670
|
sourceGroups,
|
|
7596
7671
|
sources,
|
|
7597
7672
|
sourceSummaries
|
|
@@ -7599,14 +7674,14 @@ var useRAGSources = (messages) => {
|
|
|
7599
7674
|
};
|
|
7600
7675
|
|
|
7601
7676
|
// src/react/ai/useRAGStatus.ts
|
|
7602
|
-
import { useCallback as
|
|
7677
|
+
import { useCallback as useCallback10, useEffect as useEffect4, useMemo as useMemo11, useState as useState8 } from "react";
|
|
7603
7678
|
var useRAGStatus = (path, autoLoad = true) => {
|
|
7604
7679
|
const client = useMemo11(() => createRAGClient({ path }), [path]);
|
|
7605
7680
|
const [status, setStatus] = useState8();
|
|
7606
7681
|
const [capabilities, setCapabilities] = useState8();
|
|
7607
7682
|
const [error, setError] = useState8(null);
|
|
7608
7683
|
const [isLoading, setIsLoading] = useState8(autoLoad);
|
|
7609
|
-
const refresh =
|
|
7684
|
+
const refresh = useCallback10(async () => {
|
|
7610
7685
|
setIsLoading(true);
|
|
7611
7686
|
setError(null);
|
|
7612
7687
|
try {
|
|
@@ -7622,7 +7697,7 @@ var useRAGStatus = (path, autoLoad = true) => {
|
|
|
7622
7697
|
setIsLoading(false);
|
|
7623
7698
|
}
|
|
7624
7699
|
}, [client]);
|
|
7625
|
-
const reset =
|
|
7700
|
+
const reset = useCallback10(() => {
|
|
7626
7701
|
setCapabilities(undefined);
|
|
7627
7702
|
setError(null);
|
|
7628
7703
|
setIsLoading(false);
|
|
@@ -7649,7 +7724,7 @@ var useRAGStatus = (path, autoLoad = true) => {
|
|
|
7649
7724
|
import { useMemo as useMemo13 } from "react";
|
|
7650
7725
|
|
|
7651
7726
|
// src/react/ai/useRAGStream.ts
|
|
7652
|
-
import { useCallback as
|
|
7727
|
+
import { useCallback as useCallback11, useMemo as useMemo12 } from "react";
|
|
7653
7728
|
var useRAGStream = (path, conversationId) => {
|
|
7654
7729
|
const stream = useAIStream(path, conversationId);
|
|
7655
7730
|
const workflow = useMemo12(() => buildRAGAnswerWorkflowState({
|
|
@@ -7679,7 +7754,7 @@ var useRAGStream = (path, conversationId) => {
|
|
|
7679
7754
|
sourceCount: workflow.sources.length,
|
|
7680
7755
|
stage: workflow.stage
|
|
7681
7756
|
}), [workflow]);
|
|
7682
|
-
const query =
|
|
7757
|
+
const query = useCallback11((content, attachments) => {
|
|
7683
7758
|
stream.send(content, attachments);
|
|
7684
7759
|
}, [stream]);
|
|
7685
7760
|
return {
|
|
@@ -7791,5 +7866,5 @@ export {
|
|
|
7791
7866
|
AIStreamProvider
|
|
7792
7867
|
};
|
|
7793
7868
|
|
|
7794
|
-
//# debugId=
|
|
7869
|
+
//# debugId=97115FA6E1742FB464756E2164756E21
|
|
7795
7870
|
//# sourceMappingURL=index.js.map
|