@absolutejs/absolute 0.19.0-beta.439 → 0.19.0-beta.440
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/vue/ai/index.js +459 -17
- package/dist/angular/index.js +2 -2
- package/dist/angular/index.js.map +1 -1
- package/dist/angular/server.js +2 -2
- package/dist/angular/server.js.map +1 -1
- package/dist/build.js +2 -2
- package/dist/build.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/src/vue/ai/index.d.ts +6 -0
- package/dist/src/vue/ai/useRAG.d.ts +434 -0
- package/dist/src/vue/ai/useRAGChunkPreview.d.ts +57 -0
- package/dist/src/vue/ai/useRAGCitations.d.ts +8 -0
- package/dist/src/vue/ai/useRAGDocuments.d.ts +70 -0
- package/dist/src/vue/ai/useRAGIndexAdmin.d.ts +206 -0
- package/dist/src/vue/ai/useRAGIngest.d.ts +20 -2
- package/dist/src/vue/ai/useRAGSearch.d.ts +15 -0
- package/dist/src/vue/ai/useRAGSources.d.ts +9 -0
- package/dist/src/vue/ai/useRAGStatus.d.ts +1 -0
- package/dist/src/vue/ai/useRAGStream.d.ts +14 -1
- package/dist/vue/ai/index.js +460 -18
- package/dist/vue/ai/index.js.map +14 -7
- package/dist/vue/components/index.js +17 -4
- package/dist/vue/components/index.js.map +3 -3
- package/dist/vue/index.js +17 -4
- package/dist/vue/index.js.map +3 -3
- package/package.json +1 -1
package/dist/vue/ai/index.js
CHANGED
|
@@ -728,7 +728,7 @@ var useAIStream = (path, conversationId) => {
|
|
|
728
728
|
send
|
|
729
729
|
};
|
|
730
730
|
};
|
|
731
|
-
// src/vue/ai/
|
|
731
|
+
// src/vue/ai/useRAGChunkPreview.ts
|
|
732
732
|
import { ref as ref2 } from "vue";
|
|
733
733
|
|
|
734
734
|
// src/ai/client/ragClient.ts
|
|
@@ -888,13 +888,220 @@ var createRAGClient = (options) => {
|
|
|
888
888
|
};
|
|
889
889
|
};
|
|
890
890
|
|
|
891
|
+
// src/vue/ai/useRAGChunkPreview.ts
|
|
892
|
+
var useRAGChunkPreview = (path) => {
|
|
893
|
+
const client = createRAGClient({ path });
|
|
894
|
+
const preview = ref2(null);
|
|
895
|
+
const error = ref2(null);
|
|
896
|
+
const isLoading = ref2(false);
|
|
897
|
+
const inspect = async (id) => {
|
|
898
|
+
isLoading.value = true;
|
|
899
|
+
error.value = null;
|
|
900
|
+
try {
|
|
901
|
+
const response = await client.documentChunks(id);
|
|
902
|
+
if (!response.ok) {
|
|
903
|
+
throw new Error(response.error);
|
|
904
|
+
}
|
|
905
|
+
preview.value = response;
|
|
906
|
+
return response;
|
|
907
|
+
} catch (caught) {
|
|
908
|
+
error.value = caught instanceof Error ? caught.message : String(caught);
|
|
909
|
+
throw caught;
|
|
910
|
+
} finally {
|
|
911
|
+
isLoading.value = false;
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
const clear = () => {
|
|
915
|
+
error.value = null;
|
|
916
|
+
isLoading.value = false;
|
|
917
|
+
preview.value = null;
|
|
918
|
+
};
|
|
919
|
+
return {
|
|
920
|
+
clear,
|
|
921
|
+
error,
|
|
922
|
+
inspect,
|
|
923
|
+
isLoading,
|
|
924
|
+
preview
|
|
925
|
+
};
|
|
926
|
+
};
|
|
927
|
+
// src/vue/ai/useRAGCitations.ts
|
|
928
|
+
import { computed } from "vue";
|
|
929
|
+
|
|
930
|
+
// src/ai/rag/presentation.ts
|
|
931
|
+
var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.chunkId;
|
|
932
|
+
var buildSourceLabel = (source) => source.source ?? source.title ?? source.chunkId;
|
|
933
|
+
var getLatestAssistantMessage = (messages) => {
|
|
934
|
+
for (let index = messages.length - 1;index >= 0; index -= 1) {
|
|
935
|
+
const message = messages[index];
|
|
936
|
+
if (message?.role === "assistant") {
|
|
937
|
+
return message;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return;
|
|
941
|
+
};
|
|
942
|
+
var getLatestRAGSources = (messages) => getLatestAssistantMessage(messages)?.sources ?? [];
|
|
943
|
+
var getLatestRetrievedMessage = (messages) => {
|
|
944
|
+
for (let index = messages.length - 1;index >= 0; index -= 1) {
|
|
945
|
+
const message = messages[index];
|
|
946
|
+
if (message?.role === "assistant" && (message.sources?.length ?? 0) > 0) {
|
|
947
|
+
return message;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return;
|
|
951
|
+
};
|
|
952
|
+
var buildRAGSourceGroups = (sources) => {
|
|
953
|
+
const groups = new Map;
|
|
954
|
+
for (const source of sources) {
|
|
955
|
+
const key = buildSourceGroupKey(source);
|
|
956
|
+
const existing = groups.get(key);
|
|
957
|
+
if (existing) {
|
|
958
|
+
existing.bestScore = Math.max(existing.bestScore, source.score);
|
|
959
|
+
existing.count += 1;
|
|
960
|
+
existing.chunks.push(source);
|
|
961
|
+
continue;
|
|
962
|
+
}
|
|
963
|
+
groups.set(key, {
|
|
964
|
+
bestScore: source.score,
|
|
965
|
+
chunks: [source],
|
|
966
|
+
count: 1,
|
|
967
|
+
key,
|
|
968
|
+
label: buildSourceLabel(source),
|
|
969
|
+
source: source.source,
|
|
970
|
+
title: source.title
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
return [...groups.values()].sort((left, right) => {
|
|
974
|
+
if (right.bestScore !== left.bestScore) {
|
|
975
|
+
return right.bestScore - left.bestScore;
|
|
976
|
+
}
|
|
977
|
+
return left.label.localeCompare(right.label);
|
|
978
|
+
});
|
|
979
|
+
};
|
|
980
|
+
var buildRAGCitations = (sources) => {
|
|
981
|
+
const unique = new Map;
|
|
982
|
+
for (const source of sources) {
|
|
983
|
+
const key = source.chunkId;
|
|
984
|
+
const existing = unique.get(key);
|
|
985
|
+
if (existing && existing.score >= source.score) {
|
|
986
|
+
continue;
|
|
987
|
+
}
|
|
988
|
+
unique.set(key, {
|
|
989
|
+
chunkId: source.chunkId,
|
|
990
|
+
key,
|
|
991
|
+
label: buildSourceLabel(source),
|
|
992
|
+
metadata: source.metadata,
|
|
993
|
+
score: source.score,
|
|
994
|
+
source: source.source,
|
|
995
|
+
text: source.text,
|
|
996
|
+
title: source.title
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
return [...unique.values()].sort((left, right) => {
|
|
1000
|
+
if (right.score !== left.score) {
|
|
1001
|
+
return right.score - left.score;
|
|
1002
|
+
}
|
|
1003
|
+
return left.label.localeCompare(right.label);
|
|
1004
|
+
});
|
|
1005
|
+
};
|
|
1006
|
+
var buildRAGRetrievedState = (messages) => {
|
|
1007
|
+
const message = getLatestRetrievedMessage(messages);
|
|
1008
|
+
if (!message) {
|
|
1009
|
+
return null;
|
|
1010
|
+
}
|
|
1011
|
+
const sources = message.sources ?? [];
|
|
1012
|
+
return {
|
|
1013
|
+
citations: buildRAGCitations(sources),
|
|
1014
|
+
conversationId: message.conversationId,
|
|
1015
|
+
messageId: message.id,
|
|
1016
|
+
retrievedAt: message.retrievedAt,
|
|
1017
|
+
sourceGroups: buildRAGSourceGroups(sources),
|
|
1018
|
+
sources
|
|
1019
|
+
};
|
|
1020
|
+
};
|
|
1021
|
+
var resolveRAGStreamStage = ({
|
|
1022
|
+
error,
|
|
1023
|
+
isStreaming,
|
|
1024
|
+
messages
|
|
1025
|
+
}) => {
|
|
1026
|
+
if (error) {
|
|
1027
|
+
return "error";
|
|
1028
|
+
}
|
|
1029
|
+
const assistantMessage = getLatestAssistantMessage(messages);
|
|
1030
|
+
if (!assistantMessage) {
|
|
1031
|
+
return isStreaming ? "submitting" : "idle";
|
|
1032
|
+
}
|
|
1033
|
+
if (!isStreaming) {
|
|
1034
|
+
return "complete";
|
|
1035
|
+
}
|
|
1036
|
+
const hasSources = (assistantMessage.sources?.length ?? 0) > 0;
|
|
1037
|
+
const hasContent = assistantMessage.content.trim().length > 0 || assistantMessage.thinking?.trim().length || (assistantMessage.toolCalls?.length ?? 0) > 0 || (assistantMessage.images?.length ?? 0) > 0;
|
|
1038
|
+
if (hasSources && !hasContent) {
|
|
1039
|
+
return "retrieved";
|
|
1040
|
+
}
|
|
1041
|
+
return "streaming";
|
|
1042
|
+
};
|
|
1043
|
+
|
|
1044
|
+
// src/vue/ai/useRAGCitations.ts
|
|
1045
|
+
var useRAGCitations = (sources) => {
|
|
1046
|
+
const citations = computed(() => buildRAGCitations(sources.value));
|
|
1047
|
+
const sourceGroups = computed(() => buildRAGSourceGroups(sources.value));
|
|
1048
|
+
const hasCitations = computed(() => citations.value.length > 0);
|
|
1049
|
+
return {
|
|
1050
|
+
citations,
|
|
1051
|
+
hasCitations,
|
|
1052
|
+
sourceGroups
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// src/vue/ai/useRAGDocuments.ts
|
|
1057
|
+
import { ref as ref3 } from "vue";
|
|
1058
|
+
var useRAGDocuments = (path) => {
|
|
1059
|
+
const client = createRAGClient({ path });
|
|
1060
|
+
const documents = ref3([]);
|
|
1061
|
+
const error = ref3(null);
|
|
1062
|
+
const isLoading = ref3(false);
|
|
1063
|
+
const lastResponse = ref3(null);
|
|
1064
|
+
const load = async (kind) => {
|
|
1065
|
+
isLoading.value = true;
|
|
1066
|
+
error.value = null;
|
|
1067
|
+
try {
|
|
1068
|
+
const response = await client.documents(kind);
|
|
1069
|
+
documents.value = response.documents;
|
|
1070
|
+
lastResponse.value = response;
|
|
1071
|
+
return response;
|
|
1072
|
+
} catch (caught) {
|
|
1073
|
+
error.value = caught instanceof Error ? caught.message : String(caught);
|
|
1074
|
+
throw caught;
|
|
1075
|
+
} finally {
|
|
1076
|
+
isLoading.value = false;
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
const reset = () => {
|
|
1080
|
+
documents.value = [];
|
|
1081
|
+
error.value = null;
|
|
1082
|
+
isLoading.value = false;
|
|
1083
|
+
lastResponse.value = null;
|
|
1084
|
+
};
|
|
1085
|
+
return {
|
|
1086
|
+
documents,
|
|
1087
|
+
error,
|
|
1088
|
+
isLoading,
|
|
1089
|
+
lastResponse,
|
|
1090
|
+
load,
|
|
1091
|
+
reset
|
|
1092
|
+
};
|
|
1093
|
+
};
|
|
1094
|
+
|
|
891
1095
|
// src/vue/ai/useRAGIngest.ts
|
|
1096
|
+
import { ref as ref4 } from "vue";
|
|
892
1097
|
var useRAGIngest = (path) => {
|
|
893
1098
|
const client = createRAGClient({ path });
|
|
894
|
-
const error =
|
|
895
|
-
const isIngesting =
|
|
896
|
-
const lastIngestCount =
|
|
897
|
-
const
|
|
1099
|
+
const error = ref4(null);
|
|
1100
|
+
const isIngesting = ref4(false);
|
|
1101
|
+
const lastIngestCount = ref4(null);
|
|
1102
|
+
const lastDocumentCount = ref4(null);
|
|
1103
|
+
const lastResponse = ref4(null);
|
|
1104
|
+
const ingestChunks = async (chunks) => {
|
|
898
1105
|
isIngesting.value = true;
|
|
899
1106
|
error.value = null;
|
|
900
1107
|
try {
|
|
@@ -903,6 +1110,27 @@ var useRAGIngest = (path) => {
|
|
|
903
1110
|
throw new Error(response.error ?? "RAG ingest failed");
|
|
904
1111
|
}
|
|
905
1112
|
lastIngestCount.value = response.count ?? chunks.length;
|
|
1113
|
+
lastDocumentCount.value = null;
|
|
1114
|
+
lastResponse.value = response;
|
|
1115
|
+
return response;
|
|
1116
|
+
} catch (caught) {
|
|
1117
|
+
error.value = caught instanceof Error ? caught.message : String(caught);
|
|
1118
|
+
throw caught;
|
|
1119
|
+
} finally {
|
|
1120
|
+
isIngesting.value = false;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
const ingestDocuments = async (input) => {
|
|
1124
|
+
isIngesting.value = true;
|
|
1125
|
+
error.value = null;
|
|
1126
|
+
try {
|
|
1127
|
+
const response = await client.ingestDocuments(input);
|
|
1128
|
+
if (!response.ok) {
|
|
1129
|
+
throw new Error(response.error ?? "RAG document ingest failed");
|
|
1130
|
+
}
|
|
1131
|
+
lastDocumentCount.value = response.documentCount ?? input.documents.length;
|
|
1132
|
+
lastIngestCount.value = response.count ?? null;
|
|
1133
|
+
lastResponse.value = response;
|
|
906
1134
|
return response;
|
|
907
1135
|
} catch (caught) {
|
|
908
1136
|
error.value = caught instanceof Error ? caught.message : String(caught);
|
|
@@ -911,26 +1139,140 @@ var useRAGIngest = (path) => {
|
|
|
911
1139
|
isIngesting.value = false;
|
|
912
1140
|
}
|
|
913
1141
|
};
|
|
1142
|
+
const clearIndex = async () => {
|
|
1143
|
+
isIngesting.value = true;
|
|
1144
|
+
error.value = null;
|
|
1145
|
+
try {
|
|
1146
|
+
return await client.clearIndex();
|
|
1147
|
+
} catch (caught) {
|
|
1148
|
+
error.value = caught instanceof Error ? caught.message : String(caught);
|
|
1149
|
+
throw caught;
|
|
1150
|
+
} finally {
|
|
1151
|
+
isIngesting.value = false;
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
const reset = () => {
|
|
1155
|
+
error.value = null;
|
|
1156
|
+
isIngesting.value = false;
|
|
1157
|
+
lastDocumentCount.value = null;
|
|
1158
|
+
lastIngestCount.value = null;
|
|
1159
|
+
lastResponse.value = null;
|
|
1160
|
+
};
|
|
914
1161
|
return {
|
|
1162
|
+
clearIndex,
|
|
915
1163
|
error,
|
|
916
|
-
ingest,
|
|
1164
|
+
ingest: ingestChunks,
|
|
1165
|
+
ingestChunks,
|
|
1166
|
+
ingestDocuments,
|
|
917
1167
|
isIngesting,
|
|
918
|
-
|
|
1168
|
+
lastDocumentCount,
|
|
1169
|
+
lastIngestCount,
|
|
1170
|
+
lastResponse,
|
|
1171
|
+
reset
|
|
919
1172
|
};
|
|
920
1173
|
};
|
|
1174
|
+
|
|
1175
|
+
// src/vue/ai/useRAGIndexAdmin.ts
|
|
1176
|
+
import { ref as ref5 } from "vue";
|
|
1177
|
+
var useRAGIndexAdmin = (path) => {
|
|
1178
|
+
const client = createRAGClient({ path });
|
|
1179
|
+
const isLoading = ref5(false);
|
|
1180
|
+
const error = ref5(null);
|
|
1181
|
+
const lastMutation = ref5(null);
|
|
1182
|
+
const backends = ref5(null);
|
|
1183
|
+
const run = async (operation) => {
|
|
1184
|
+
isLoading.value = true;
|
|
1185
|
+
error.value = null;
|
|
1186
|
+
try {
|
|
1187
|
+
return await operation();
|
|
1188
|
+
} catch (caught) {
|
|
1189
|
+
error.value = caught instanceof Error ? caught.message : String(caught);
|
|
1190
|
+
throw caught;
|
|
1191
|
+
} finally {
|
|
1192
|
+
isLoading.value = false;
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
const createDocument = async (input) => run(async () => {
|
|
1196
|
+
const response = await client.createDocument(input);
|
|
1197
|
+
lastMutation.value = response;
|
|
1198
|
+
if (!response.ok) {
|
|
1199
|
+
throw new Error(response.error ?? "Failed to create document");
|
|
1200
|
+
}
|
|
1201
|
+
return response;
|
|
1202
|
+
});
|
|
1203
|
+
const deleteDocument = async (id) => run(async () => {
|
|
1204
|
+
const response = await client.deleteDocument(id);
|
|
1205
|
+
lastMutation.value = response;
|
|
1206
|
+
if (!response.ok) {
|
|
1207
|
+
throw new Error(response.error ?? "Failed to delete document");
|
|
1208
|
+
}
|
|
1209
|
+
return response;
|
|
1210
|
+
});
|
|
1211
|
+
const reseed = async () => run(async () => {
|
|
1212
|
+
const response = await client.reseed();
|
|
1213
|
+
lastMutation.value = response;
|
|
1214
|
+
if (!response.ok) {
|
|
1215
|
+
throw new Error(response.error ?? "Failed to reseed index");
|
|
1216
|
+
}
|
|
1217
|
+
return response;
|
|
1218
|
+
});
|
|
1219
|
+
const reset = async () => run(async () => {
|
|
1220
|
+
const response = await client.reset();
|
|
1221
|
+
lastMutation.value = response;
|
|
1222
|
+
if (!response.ok) {
|
|
1223
|
+
throw new Error(response.error ?? "Failed to reset index");
|
|
1224
|
+
}
|
|
1225
|
+
return response;
|
|
1226
|
+
});
|
|
1227
|
+
const loadBackends = async () => run(async () => {
|
|
1228
|
+
const response = await client.backends();
|
|
1229
|
+
backends.value = response;
|
|
1230
|
+
return response;
|
|
1231
|
+
});
|
|
1232
|
+
const clearIndex = async () => run(async () => {
|
|
1233
|
+
const response = await client.clearIndex();
|
|
1234
|
+
const mutation = { ok: response.ok };
|
|
1235
|
+
lastMutation.value = mutation;
|
|
1236
|
+
return mutation;
|
|
1237
|
+
});
|
|
1238
|
+
const resetState = () => {
|
|
1239
|
+
backends.value = null;
|
|
1240
|
+
error.value = null;
|
|
1241
|
+
isLoading.value = false;
|
|
1242
|
+
lastMutation.value = null;
|
|
1243
|
+
};
|
|
1244
|
+
return {
|
|
1245
|
+
backends,
|
|
1246
|
+
clearIndex,
|
|
1247
|
+
createDocument,
|
|
1248
|
+
deleteDocument,
|
|
1249
|
+
error,
|
|
1250
|
+
isLoading,
|
|
1251
|
+
lastMutation,
|
|
1252
|
+
loadBackends,
|
|
1253
|
+
reseed,
|
|
1254
|
+
reset,
|
|
1255
|
+
resetState
|
|
1256
|
+
};
|
|
1257
|
+
};
|
|
1258
|
+
|
|
921
1259
|
// src/vue/ai/useRAGSearch.ts
|
|
922
|
-
import { ref as
|
|
1260
|
+
import { ref as ref6 } from "vue";
|
|
923
1261
|
var useRAGSearch = (path) => {
|
|
924
1262
|
const client = createRAGClient({ path });
|
|
925
|
-
const results =
|
|
926
|
-
const error =
|
|
927
|
-
const isSearching =
|
|
1263
|
+
const results = ref6([]);
|
|
1264
|
+
const error = ref6(null);
|
|
1265
|
+
const isSearching = ref6(false);
|
|
1266
|
+
const hasSearched = ref6(false);
|
|
1267
|
+
const lastRequest = ref6(null);
|
|
928
1268
|
const search = async (input) => {
|
|
929
1269
|
isSearching.value = true;
|
|
930
1270
|
error.value = null;
|
|
1271
|
+
lastRequest.value = input;
|
|
931
1272
|
try {
|
|
932
1273
|
const nextResults = await client.search(input);
|
|
933
1274
|
results.value = nextResults;
|
|
1275
|
+
hasSearched.value = true;
|
|
934
1276
|
return nextResults;
|
|
935
1277
|
} catch (caught) {
|
|
936
1278
|
error.value = caught instanceof Error ? caught.message : String(caught);
|
|
@@ -939,21 +1281,47 @@ var useRAGSearch = (path) => {
|
|
|
939
1281
|
isSearching.value = false;
|
|
940
1282
|
}
|
|
941
1283
|
};
|
|
1284
|
+
const reset = () => {
|
|
1285
|
+
error.value = null;
|
|
1286
|
+
hasSearched.value = false;
|
|
1287
|
+
isSearching.value = false;
|
|
1288
|
+
lastRequest.value = null;
|
|
1289
|
+
results.value = [];
|
|
1290
|
+
};
|
|
942
1291
|
return {
|
|
943
1292
|
error,
|
|
1293
|
+
hasSearched,
|
|
944
1294
|
isSearching,
|
|
1295
|
+
lastRequest,
|
|
1296
|
+
reset,
|
|
945
1297
|
results,
|
|
946
1298
|
search
|
|
947
1299
|
};
|
|
948
1300
|
};
|
|
1301
|
+
|
|
1302
|
+
// src/vue/ai/useRAGSources.ts
|
|
1303
|
+
import { computed as computed2 } from "vue";
|
|
1304
|
+
var useRAGSources = (messages) => {
|
|
1305
|
+
const latestAssistantMessage = computed2(() => getLatestAssistantMessage(messages.value));
|
|
1306
|
+
const sources = computed2(() => getLatestRAGSources(messages.value));
|
|
1307
|
+
const sourceGroups = computed2(() => buildRAGSourceGroups(sources.value));
|
|
1308
|
+
const hasSources = computed2(() => sources.value.length > 0);
|
|
1309
|
+
return {
|
|
1310
|
+
hasSources,
|
|
1311
|
+
latestAssistantMessage,
|
|
1312
|
+
sourceGroups,
|
|
1313
|
+
sources
|
|
1314
|
+
};
|
|
1315
|
+
};
|
|
1316
|
+
|
|
949
1317
|
// src/vue/ai/useRAGStatus.ts
|
|
950
|
-
import { onMounted, ref as
|
|
1318
|
+
import { onMounted, ref as ref7 } from "vue";
|
|
951
1319
|
var useRAGStatus = (path, autoLoad = true) => {
|
|
952
1320
|
const client = createRAGClient({ path });
|
|
953
|
-
const status =
|
|
954
|
-
const capabilities =
|
|
955
|
-
const error =
|
|
956
|
-
const isLoading =
|
|
1321
|
+
const status = ref7();
|
|
1322
|
+
const capabilities = ref7();
|
|
1323
|
+
const error = ref7(null);
|
|
1324
|
+
const isLoading = ref7(autoLoad);
|
|
957
1325
|
const refresh = async () => {
|
|
958
1326
|
isLoading.value = true;
|
|
959
1327
|
error.value = null;
|
|
@@ -969,6 +1337,12 @@ var useRAGStatus = (path, autoLoad = true) => {
|
|
|
969
1337
|
isLoading.value = false;
|
|
970
1338
|
}
|
|
971
1339
|
};
|
|
1340
|
+
const reset = () => {
|
|
1341
|
+
capabilities.value = undefined;
|
|
1342
|
+
error.value = null;
|
|
1343
|
+
isLoading.value = false;
|
|
1344
|
+
status.value = undefined;
|
|
1345
|
+
};
|
|
972
1346
|
onMounted(() => {
|
|
973
1347
|
if (!autoLoad) {
|
|
974
1348
|
isLoading.value = false;
|
|
@@ -981,19 +1355,87 @@ var useRAGStatus = (path, autoLoad = true) => {
|
|
|
981
1355
|
error,
|
|
982
1356
|
isLoading,
|
|
983
1357
|
refresh,
|
|
1358
|
+
reset,
|
|
984
1359
|
status
|
|
985
1360
|
};
|
|
986
1361
|
};
|
|
1362
|
+
|
|
987
1363
|
// src/vue/ai/useRAGStream.ts
|
|
988
|
-
|
|
1364
|
+
import { computed as computed3 } from "vue";
|
|
1365
|
+
var useRAGStream = (path, conversationId) => {
|
|
1366
|
+
const stream = useAIStream(path, conversationId);
|
|
1367
|
+
const latestAssistantMessage = computed3(() => getLatestAssistantMessage(stream.messages.value));
|
|
1368
|
+
const sources = computed3(() => getLatestRAGSources(stream.messages.value));
|
|
1369
|
+
const sourceGroups = computed3(() => buildRAGSourceGroups(sources.value));
|
|
1370
|
+
const citations = computed3(() => buildRAGCitations(sources.value));
|
|
1371
|
+
const retrieval = computed3(() => buildRAGRetrievedState(stream.messages.value));
|
|
1372
|
+
const stage = computed3(() => resolveRAGStreamStage({
|
|
1373
|
+
error: stream.error.value,
|
|
1374
|
+
isStreaming: stream.isStreaming.value,
|
|
1375
|
+
messages: stream.messages.value
|
|
1376
|
+
}));
|
|
1377
|
+
const query = (content, attachments) => {
|
|
1378
|
+
stream.send(content, attachments);
|
|
1379
|
+
};
|
|
1380
|
+
const hasRetrieved = computed3(() => (retrieval.value?.sources.length ?? 0) > 0);
|
|
1381
|
+
const isRetrieving = computed3(() => stage.value === "submitting" || stage.value === "retrieved");
|
|
1382
|
+
const isAnswerStreaming = computed3(() => stage.value === "streaming");
|
|
1383
|
+
const isComplete = computed3(() => stage.value === "complete");
|
|
1384
|
+
const hasSources = computed3(() => sources.value.length > 0);
|
|
1385
|
+
return {
|
|
1386
|
+
...stream,
|
|
1387
|
+
citations,
|
|
1388
|
+
hasRetrieved,
|
|
1389
|
+
hasSources,
|
|
1390
|
+
isAnswerStreaming,
|
|
1391
|
+
isComplete,
|
|
1392
|
+
isRetrieving,
|
|
1393
|
+
latestAssistantMessage,
|
|
1394
|
+
query,
|
|
1395
|
+
retrieval,
|
|
1396
|
+
sourceGroups,
|
|
1397
|
+
sources,
|
|
1398
|
+
stage
|
|
1399
|
+
};
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
// src/vue/ai/useRAG.ts
|
|
1403
|
+
var useRAG = (path, options = {}) => {
|
|
1404
|
+
const search = useRAGSearch(path);
|
|
1405
|
+
const ingest = useRAGIngest(path);
|
|
1406
|
+
const status = useRAGStatus(path, options.autoLoadStatus ?? true);
|
|
1407
|
+
const documents = useRAGDocuments(path);
|
|
1408
|
+
const chunkPreview = useRAGChunkPreview(path);
|
|
1409
|
+
const index = useRAGIndexAdmin(path);
|
|
1410
|
+
const stream = useRAGStream(options.streamPath ?? path, options.conversationId);
|
|
1411
|
+
const sources = useRAGSources(stream.messages);
|
|
1412
|
+
const citations = useRAGCitations(sources.sources);
|
|
1413
|
+
return {
|
|
1414
|
+
citations,
|
|
1415
|
+
chunkPreview,
|
|
1416
|
+
documents,
|
|
1417
|
+
ingest,
|
|
1418
|
+
index,
|
|
1419
|
+
search,
|
|
1420
|
+
sources,
|
|
1421
|
+
status,
|
|
1422
|
+
stream
|
|
1423
|
+
};
|
|
1424
|
+
};
|
|
989
1425
|
export {
|
|
990
1426
|
useRAGStream,
|
|
991
1427
|
useRAGStatus,
|
|
1428
|
+
useRAGSources,
|
|
992
1429
|
useRAGSearch,
|
|
993
1430
|
useRAGIngest,
|
|
1431
|
+
useRAGIndexAdmin,
|
|
1432
|
+
useRAGDocuments,
|
|
1433
|
+
useRAGCitations,
|
|
1434
|
+
useRAGChunkPreview,
|
|
1435
|
+
useRAG,
|
|
994
1436
|
useAIStream,
|
|
995
1437
|
AIStreamKey
|
|
996
1438
|
};
|
|
997
1439
|
|
|
998
|
-
//# debugId=
|
|
1440
|
+
//# debugId=184D3E2E13375CB464756E2164756E21
|
|
999
1441
|
//# sourceMappingURL=index.js.map
|