@absolutejs/rag 0.0.27 → 0.0.29
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/adapter-kit/index.js +134 -3
- package/dist/adapter-kit/index.js.map +3 -3
- package/dist/client/index.js +16 -1
- package/dist/client/index.js.map +2 -2
- package/dist/client/ui.js +16 -1
- package/dist/client/ui.js.map +2 -2
- package/dist/index.js +136 -3
- package/dist/index.js.map +3 -3
- package/dist/manifest.js +8904 -0
- package/dist/manifest.js.map +123 -0
- package/dist/manifest.json +515 -0
- package/dist/presentation/ui.js +16 -1
- package/dist/presentation/ui.js.map +2 -2
- package/dist/quality/quality.js +16 -1
- package/dist/quality/quality.js.map +2 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/manifest.d.ts +2 -0
- package/dist/src/retrieval/collection.d.ts +3 -1
- package/dist/types/engine.d.ts +82 -0
- package/package.json +17 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
2
17
|
// src/quality/quality.ts
|
|
3
18
|
import { mkdir, readFile } from "fs/promises";
|
|
4
19
|
|
|
@@ -21092,7 +21107,10 @@ var createRAGCollection = (options) => {
|
|
|
21092
21107
|
const embeddingProvider = resolveRAGEmbeddingProvider(options.embedding, options.store.embed, options.defaultModel);
|
|
21093
21108
|
const getExpectedDimensions = () => embeddingProvider.dimensions ?? getStatus?.()?.dimensions;
|
|
21094
21109
|
const embed = async (input, context) => {
|
|
21095
|
-
const vector = await embeddingProvider.embed(
|
|
21110
|
+
const vector = await embeddingProvider.embed({
|
|
21111
|
+
...input,
|
|
21112
|
+
kind: input.kind ?? (context === "query" ? "query" : "passage")
|
|
21113
|
+
});
|
|
21096
21114
|
validateRAGEmbeddingDimensions(vector, getExpectedDimensions(), context);
|
|
21097
21115
|
return vector;
|
|
21098
21116
|
};
|
|
@@ -21552,6 +21570,115 @@ var createRAGCollection = (options) => {
|
|
|
21552
21570
|
}))).flat();
|
|
21553
21571
|
await options.store.upsert({ chunks });
|
|
21554
21572
|
};
|
|
21573
|
+
const buildSourceUpsertInput = async (sourceId, input) => {
|
|
21574
|
+
const sharedMetadata = input.metadata;
|
|
21575
|
+
if (input.document) {
|
|
21576
|
+
return buildRAGUpsertInputFromDocuments({
|
|
21577
|
+
chunkingRegistry: input.chunkingRegistry,
|
|
21578
|
+
defaultChunking: input.chunking,
|
|
21579
|
+
documents: [
|
|
21580
|
+
{
|
|
21581
|
+
...input.document,
|
|
21582
|
+
chunking: input.document.chunking ?? input.chunking,
|
|
21583
|
+
metadata: { ...input.document.metadata ?? {}, ...sharedMetadata },
|
|
21584
|
+
source: input.document.source ?? sourceId
|
|
21585
|
+
}
|
|
21586
|
+
]
|
|
21587
|
+
});
|
|
21588
|
+
}
|
|
21589
|
+
if (input.upload) {
|
|
21590
|
+
return buildRAGUpsertInputFromUploads({
|
|
21591
|
+
chunkingRegistry: input.chunkingRegistry,
|
|
21592
|
+
extractorRegistry: input.extractorRegistry,
|
|
21593
|
+
extractors: input.extractors,
|
|
21594
|
+
uploads: [
|
|
21595
|
+
{
|
|
21596
|
+
...input.upload,
|
|
21597
|
+
chunking: input.upload.chunking ?? input.chunking,
|
|
21598
|
+
metadata: { ...input.upload.metadata ?? {}, ...sharedMetadata },
|
|
21599
|
+
source: input.upload.source ?? sourceId
|
|
21600
|
+
}
|
|
21601
|
+
]
|
|
21602
|
+
});
|
|
21603
|
+
}
|
|
21604
|
+
if (input.url) {
|
|
21605
|
+
return buildRAGUpsertInputFromURLs({
|
|
21606
|
+
chunkingRegistry: input.chunkingRegistry,
|
|
21607
|
+
extractorRegistry: input.extractorRegistry,
|
|
21608
|
+
extractors: input.extractors,
|
|
21609
|
+
urls: [
|
|
21610
|
+
{
|
|
21611
|
+
...input.url,
|
|
21612
|
+
chunking: input.url.chunking ?? input.chunking,
|
|
21613
|
+
extractorRegistry: input.url.extractorRegistry ?? input.extractorRegistry,
|
|
21614
|
+
extractors: input.url.extractors ?? input.extractors,
|
|
21615
|
+
metadata: { ...input.url.metadata ?? {}, ...sharedMetadata },
|
|
21616
|
+
source: input.url.source ?? sourceId
|
|
21617
|
+
}
|
|
21618
|
+
]
|
|
21619
|
+
});
|
|
21620
|
+
}
|
|
21621
|
+
throw new Error("ingestSource requires one of upload, url, or document to be provided.");
|
|
21622
|
+
};
|
|
21623
|
+
const removeSource = async (input) => {
|
|
21624
|
+
const sourceId = input.sourceId?.trim();
|
|
21625
|
+
if (!sourceId) {
|
|
21626
|
+
throw new Error("removeSource requires a non-empty sourceId.");
|
|
21627
|
+
}
|
|
21628
|
+
const deleteFromStore = options.store.delete;
|
|
21629
|
+
if (typeof deleteFromStore !== "function") {
|
|
21630
|
+
throw new Error("removeSource requires a store that implements delete().");
|
|
21631
|
+
}
|
|
21632
|
+
let deleted = 0;
|
|
21633
|
+
const chunkIds = input.chunkIds ?? (typeof input.chunkCount === "number" && input.chunkCount > 0 ? Array.from({ length: input.chunkCount }, (_unused, index) => `${sourceId}#${index}`) : undefined);
|
|
21634
|
+
if (chunkIds && chunkIds.length > 0) {
|
|
21635
|
+
deleted += await deleteFromStore({ chunkIds });
|
|
21636
|
+
}
|
|
21637
|
+
if (input.filterDelete !== false) {
|
|
21638
|
+
try {
|
|
21639
|
+
deleted += await deleteFromStore({ filter: { sourceId } });
|
|
21640
|
+
} catch {}
|
|
21641
|
+
}
|
|
21642
|
+
return { deleted, sourceId };
|
|
21643
|
+
};
|
|
21644
|
+
const ingestSource = async (input) => {
|
|
21645
|
+
const sourceId = input.sourceId?.trim();
|
|
21646
|
+
if (!sourceId) {
|
|
21647
|
+
throw new Error("ingestSource requires a non-empty sourceId.");
|
|
21648
|
+
}
|
|
21649
|
+
if (input.replace !== false) {
|
|
21650
|
+
await removeSource({
|
|
21651
|
+
chunkCount: input.previousChunkCount,
|
|
21652
|
+
sourceId
|
|
21653
|
+
});
|
|
21654
|
+
}
|
|
21655
|
+
const built = await buildSourceUpsertInput(sourceId, input);
|
|
21656
|
+
const embedKind = input.embedKind ?? "passage";
|
|
21657
|
+
const chunks = await Promise.all(built.chunks.map(async (chunk, index) => {
|
|
21658
|
+
const chunkId = `${sourceId}#${index}`;
|
|
21659
|
+
const embedding = chunk.embedding ?? await embed({
|
|
21660
|
+
kind: embedKind,
|
|
21661
|
+
model: options.defaultModel,
|
|
21662
|
+
text: chunk.text
|
|
21663
|
+
}, "chunk");
|
|
21664
|
+
return {
|
|
21665
|
+
...chunk,
|
|
21666
|
+
chunkId,
|
|
21667
|
+
embedding,
|
|
21668
|
+
metadata: {
|
|
21669
|
+
...chunk.metadata ?? {},
|
|
21670
|
+
sourceId
|
|
21671
|
+
},
|
|
21672
|
+
source: chunk.source ?? sourceId
|
|
21673
|
+
};
|
|
21674
|
+
}));
|
|
21675
|
+
await ingest({ chunks });
|
|
21676
|
+
return {
|
|
21677
|
+
chunkCount: chunks.length,
|
|
21678
|
+
chunkIds: chunks.map((chunk) => chunk.chunkId),
|
|
21679
|
+
sourceId
|
|
21680
|
+
};
|
|
21681
|
+
};
|
|
21555
21682
|
return {
|
|
21556
21683
|
clear: typeof options.store.clear === "function" ? () => options.store.clear?.() : undefined,
|
|
21557
21684
|
getCapabilities: typeof getCapabilities === "function" ? () => getCapabilities() : undefined,
|
|
@@ -21559,12 +21686,16 @@ var createRAGCollection = (options) => {
|
|
|
21559
21686
|
searchWithTrace,
|
|
21560
21687
|
search,
|
|
21561
21688
|
store: options.store,
|
|
21562
|
-
ingest
|
|
21689
|
+
ingest,
|
|
21690
|
+
ingestSource,
|
|
21691
|
+
removeSource
|
|
21563
21692
|
};
|
|
21564
21693
|
};
|
|
21565
21694
|
var ingestDocuments = async (collection, input) => collection.ingest(input);
|
|
21566
21695
|
var ingestRAGDocuments = async (collection, input) => collection.ingest(buildRAGUpsertInputFromDocuments(input));
|
|
21567
21696
|
var searchDocuments = async (collection, input) => collection.search(input);
|
|
21697
|
+
var ingestRAGSource = async (collection, input) => collection.ingestSource(input);
|
|
21698
|
+
var removeRAGSource = async (collection, input) => collection.removeSource(input);
|
|
21568
21699
|
|
|
21569
21700
|
// src/presentation/htmxWorkflowRenderers.ts
|
|
21570
21701
|
var escapeHtml2 = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
@@ -35882,6 +36013,7 @@ export {
|
|
|
35882
36013
|
resolveRAGHybridSearchOptions,
|
|
35883
36014
|
resolveRAGEmbeddingProvider,
|
|
35884
36015
|
reorderRAGEvaluationSuiteCases,
|
|
36016
|
+
removeRAGSource,
|
|
35885
36017
|
removeRAGEvaluationSuiteCaseHardNegative,
|
|
35886
36018
|
removeRAGEvaluationSuiteCase,
|
|
35887
36019
|
ragChat as ragPlugin,
|
|
@@ -35953,6 +36085,7 @@ export {
|
|
|
35953
36085
|
loadRAGAnswerGroundingEvaluationHistory,
|
|
35954
36086
|
loadRAGAnswerGroundingCaseDifficultyHistory,
|
|
35955
36087
|
inspectRAGSQLiteStoreMigrations,
|
|
36088
|
+
ingestRAGSource,
|
|
35956
36089
|
ingestRAGDocuments,
|
|
35957
36090
|
ingestDocuments,
|
|
35958
36091
|
googleEmbeddings,
|
|
@@ -36153,5 +36286,5 @@ export {
|
|
|
36153
36286
|
addRAGEvaluationSuiteCase
|
|
36154
36287
|
};
|
|
36155
36288
|
|
|
36156
|
-
//# debugId=
|
|
36289
|
+
//# debugId=CB9ED8A4182DD67364756E2164756E21
|
|
36157
36290
|
//# sourceMappingURL=index.js.map
|