@absolutejs/absolute 0.19.0-beta.363 → 0.19.0-beta.364
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/index.js +276 -35
- package/dist/ai/index.js.map +9 -8
- package/dist/angular/index.js +2 -2
- package/dist/angular/index.js.map +2 -2
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +2 -2
- package/dist/react/components/browser/index.js +2 -1
- package/dist/react/components/index.js +3 -2
- package/dist/react/components/index.js.map +3 -3
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +2 -2
- package/dist/src/ai/index.d.ts +2 -1
- package/dist/src/ai/rag/adapters/sqlite.d.ts +2 -11
- package/dist/src/ai/rag/index.d.ts +3 -2
- package/dist/src/ai/rag/resolveAbsoluteSQLiteVec.d.ts +2 -0
- package/dist/src/ai/rag/types.d.ts +1 -1
- package/dist/svelte/index.js +2 -2
- package/dist/svelte/index.js.map +2 -2
- package/dist/types/ai.d.ts +43 -0
- package/dist/vue/index.js +2 -2
- package/dist/vue/index.js.map +2 -2
- package/package.json +1 -1
package/dist/ai/index.js
CHANGED
|
@@ -2101,6 +2101,42 @@ var aiChat = (config) => {
|
|
|
2101
2101
|
// src/ai/rag/chat.ts
|
|
2102
2102
|
import { Elysia as Elysia2 } from "elysia";
|
|
2103
2103
|
|
|
2104
|
+
// src/ai/rag/collection.ts
|
|
2105
|
+
var DEFAULT_TOP_K = 6;
|
|
2106
|
+
var searchDocuments = async (collection, input) => collection.search(input);
|
|
2107
|
+
var ingestDocuments = async (collection, input) => collection.ingest(input);
|
|
2108
|
+
var createRAGCollection = (options) => {
|
|
2109
|
+
const defaultTopK = options.defaultTopK ?? DEFAULT_TOP_K;
|
|
2110
|
+
const getCapabilities = options.store.getCapabilities;
|
|
2111
|
+
const getStatus = options.store.getStatus;
|
|
2112
|
+
const search = async (input) => {
|
|
2113
|
+
const queryVector = await options.store.embed({
|
|
2114
|
+
model: input.model ?? options.defaultModel,
|
|
2115
|
+
signal: input.signal,
|
|
2116
|
+
text: input.query
|
|
2117
|
+
});
|
|
2118
|
+
const topK = input.topK ?? defaultTopK;
|
|
2119
|
+
const results = await options.store.query({
|
|
2120
|
+
filter: input.filter,
|
|
2121
|
+
queryVector,
|
|
2122
|
+
topK
|
|
2123
|
+
});
|
|
2124
|
+
if (typeof input.scoreThreshold !== "number") {
|
|
2125
|
+
return results;
|
|
2126
|
+
}
|
|
2127
|
+
const scoreThreshold = input.scoreThreshold;
|
|
2128
|
+
return results.filter((entry) => entry.score >= scoreThreshold);
|
|
2129
|
+
};
|
|
2130
|
+
return {
|
|
2131
|
+
clear: typeof options.store.clear === "function" ? () => options.store.clear?.() : undefined,
|
|
2132
|
+
getCapabilities: typeof getCapabilities === "function" ? () => getCapabilities() : undefined,
|
|
2133
|
+
getStatus: typeof getStatus === "function" ? () => getStatus() : undefined,
|
|
2134
|
+
ingest: (input) => options.store.upsert(input),
|
|
2135
|
+
search,
|
|
2136
|
+
store: options.store
|
|
2137
|
+
};
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2104
2140
|
// src/ai/rag/types.ts
|
|
2105
2141
|
var buildRAGContext = (hits) => {
|
|
2106
2142
|
if (hits.length === 0) {
|
|
@@ -2122,7 +2158,7 @@ Answer with citations like [1], [2] when you use specific context.`;
|
|
|
2122
2158
|
|
|
2123
2159
|
// src/ai/rag/chat.ts
|
|
2124
2160
|
var DEFAULT_PATH2 = "/rag";
|
|
2125
|
-
var
|
|
2161
|
+
var DEFAULT_TOP_K2 = 6;
|
|
2126
2162
|
var DEFAULT_PREFIX_LEN = 12;
|
|
2127
2163
|
var DEFAULT_PROVIDER = "anthropic";
|
|
2128
2164
|
var TITLE_MAX_LENGTH2 = 80;
|
|
@@ -2219,34 +2255,35 @@ var branchConversation2 = (source, fromMessageId) => {
|
|
|
2219
2255
|
messages: branchedMessages
|
|
2220
2256
|
};
|
|
2221
2257
|
};
|
|
2222
|
-
var buildRAGContextFromQuery = async (
|
|
2223
|
-
|
|
2258
|
+
var buildRAGContextFromQuery = async (config, topK, scoreThreshold, queryText, ragModel) => {
|
|
2259
|
+
const collection = config.collection ?? (config.ragStore ? createRAGCollection({
|
|
2260
|
+
defaultModel: ragModel,
|
|
2261
|
+
defaultTopK: topK,
|
|
2262
|
+
store: config.ragStore
|
|
2263
|
+
}) : null);
|
|
2264
|
+
if (!collection) {
|
|
2224
2265
|
return {
|
|
2225
2266
|
ragContext: "",
|
|
2226
2267
|
sources: []
|
|
2227
2268
|
};
|
|
2228
2269
|
}
|
|
2229
|
-
const
|
|
2270
|
+
const queried = await collection.search({
|
|
2230
2271
|
model: ragModel,
|
|
2231
|
-
|
|
2272
|
+
query: queryText,
|
|
2273
|
+
scoreThreshold,
|
|
2274
|
+
topK
|
|
2232
2275
|
});
|
|
2233
|
-
const
|
|
2234
|
-
queryVector,
|
|
2235
|
-
topK,
|
|
2236
|
-
filter: undefined
|
|
2237
|
-
});
|
|
2238
|
-
const filtered = typeof scoreThreshold === "number" ? queried.filter((entry) => entry.score >= scoreThreshold) : queried;
|
|
2239
|
-
const sources = buildSources(filtered);
|
|
2276
|
+
const sources = buildSources(queried);
|
|
2240
2277
|
return {
|
|
2241
|
-
ragContext: buildRAGContext(
|
|
2278
|
+
ragContext: buildRAGContext(queried),
|
|
2242
2279
|
sources
|
|
2243
2280
|
};
|
|
2244
2281
|
};
|
|
2245
2282
|
var ragChat = (config) => {
|
|
2246
2283
|
const path = config.path ?? DEFAULT_PATH2;
|
|
2247
|
-
const topK = config.topK ??
|
|
2284
|
+
const topK = config.topK ?? DEFAULT_TOP_K2;
|
|
2248
2285
|
const scoreThreshold = config.scoreThreshold;
|
|
2249
|
-
const ragStore = config.ragStore;
|
|
2286
|
+
const ragStore = config.ragStore ?? config.collection?.store;
|
|
2250
2287
|
const parseProvider = config.parseProvider ?? defaultParseProvider2;
|
|
2251
2288
|
const store = config.store ?? createMemoryStore();
|
|
2252
2289
|
const abortControllers = new Map;
|
|
@@ -2319,7 +2356,7 @@ var ragChat = (config) => {
|
|
|
2319
2356
|
const model = resolveModel2(config, parsed);
|
|
2320
2357
|
const ragModel = parsed.model ?? model;
|
|
2321
2358
|
const provider = config.provider(providerName);
|
|
2322
|
-
const rag = await buildRAGContextFromQuery(
|
|
2359
|
+
const rag = await buildRAGContextFromQuery(config, topK, scoreThreshold, content, ragModel);
|
|
2323
2360
|
appendMessage2(conversation, {
|
|
2324
2361
|
attachments: rawAttachments,
|
|
2325
2362
|
content,
|
|
@@ -2425,7 +2462,7 @@ var ragChat = (config) => {
|
|
|
2425
2462
|
const model = resolveModel2(config, parsed);
|
|
2426
2463
|
const ragModel = parsed.model ?? model;
|
|
2427
2464
|
const provider = config.provider(providerName);
|
|
2428
|
-
const { ragContext, sources } = await buildRAGContextFromQuery(
|
|
2465
|
+
const { ragContext, sources } = await buildRAGContextFromQuery(config, topK, scoreThreshold, content, ragModel);
|
|
2429
2466
|
const assistantMessageId = generateId();
|
|
2430
2467
|
if (sources.length > 0) {
|
|
2431
2468
|
yield {
|
|
@@ -2585,14 +2622,27 @@ var createInMemoryRAGStore = (options = {}) => {
|
|
|
2585
2622
|
embed,
|
|
2586
2623
|
query,
|
|
2587
2624
|
upsert,
|
|
2588
|
-
clear
|
|
2625
|
+
clear,
|
|
2626
|
+
getCapabilities: () => ({
|
|
2627
|
+
backend: "in_memory",
|
|
2628
|
+
persistence: "memory_only",
|
|
2629
|
+
nativeVectorSearch: false,
|
|
2630
|
+
serverSideFiltering: false,
|
|
2631
|
+
streamingIngestStatus: false
|
|
2632
|
+
}),
|
|
2633
|
+
getStatus: () => ({
|
|
2634
|
+
backend: "in_memory",
|
|
2635
|
+
vectorMode: "in_memory",
|
|
2636
|
+
dimensions
|
|
2637
|
+
})
|
|
2589
2638
|
};
|
|
2590
2639
|
};
|
|
2591
2640
|
// src/ai/rag/adapters/sqlite.ts
|
|
2592
2641
|
import { Database } from "bun:sqlite";
|
|
2642
|
+
import { existsSync as existsSync2 } from "fs";
|
|
2593
2643
|
|
|
2594
2644
|
// src/ai/rag/resolveAbsoluteSQLiteVec.ts
|
|
2595
|
-
import { existsSync } from "fs";
|
|
2645
|
+
import { existsSync, readFileSync } from "fs";
|
|
2596
2646
|
import { createRequire } from "module";
|
|
2597
2647
|
import { arch, platform } from "os";
|
|
2598
2648
|
import { dirname, join } from "path";
|
|
@@ -2623,19 +2673,64 @@ var PLATFORM_PACKAGE_MAP = {
|
|
|
2623
2673
|
libraryFile: "sqlite-vec.dll"
|
|
2624
2674
|
}
|
|
2625
2675
|
};
|
|
2626
|
-
var
|
|
2627
|
-
|
|
2676
|
+
var currentPlatformKey = () => `${platform()}-${arch()}`;
|
|
2677
|
+
var getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
2678
|
+
var readPackageVersion = (packageJsonPath) => {
|
|
2679
|
+
try {
|
|
2680
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
2681
|
+
return typeof packageJson.version === "string" ? packageJson.version : undefined;
|
|
2682
|
+
} catch {
|
|
2683
|
+
return;
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
var resolveAbsoluteSQLiteVec = () => {
|
|
2687
|
+
const platformKey = currentPlatformKey();
|
|
2628
2688
|
const packageInfo = PLATFORM_PACKAGE_MAP[platformKey];
|
|
2629
2689
|
if (!packageInfo) {
|
|
2630
|
-
return
|
|
2690
|
+
return {
|
|
2691
|
+
status: "unsupported_platform",
|
|
2692
|
+
source: "absolute-package",
|
|
2693
|
+
platformKey,
|
|
2694
|
+
reason: `No AbsoluteJS sqlite-vec package is defined for ${platformKey}.`
|
|
2695
|
+
};
|
|
2631
2696
|
}
|
|
2632
2697
|
try {
|
|
2633
2698
|
const packageJsonPath = require2.resolve(`${packageInfo.packageName}/package.json`);
|
|
2634
2699
|
const packageRoot = dirname(packageJsonPath);
|
|
2635
2700
|
const libraryPath = join(packageRoot, packageInfo.libraryFile);
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2701
|
+
const packageVersion = readPackageVersion(packageJsonPath);
|
|
2702
|
+
if (!existsSync(libraryPath)) {
|
|
2703
|
+
return {
|
|
2704
|
+
status: "binary_missing",
|
|
2705
|
+
source: "absolute-package",
|
|
2706
|
+
platformKey,
|
|
2707
|
+
packageName: packageInfo.packageName,
|
|
2708
|
+
packageVersion,
|
|
2709
|
+
packageRoot,
|
|
2710
|
+
libraryFile: packageInfo.libraryFile,
|
|
2711
|
+
libraryPath,
|
|
2712
|
+
reason: `Resolved ${packageInfo.packageName} but ${packageInfo.libraryFile} was not found.`
|
|
2713
|
+
};
|
|
2714
|
+
}
|
|
2715
|
+
return {
|
|
2716
|
+
status: "resolved",
|
|
2717
|
+
source: "absolute-package",
|
|
2718
|
+
platformKey,
|
|
2719
|
+
packageName: packageInfo.packageName,
|
|
2720
|
+
packageVersion,
|
|
2721
|
+
packageRoot,
|
|
2722
|
+
libraryFile: packageInfo.libraryFile,
|
|
2723
|
+
libraryPath
|
|
2724
|
+
};
|
|
2725
|
+
} catch (error) {
|
|
2726
|
+
return {
|
|
2727
|
+
status: "package_not_installed",
|
|
2728
|
+
source: "absolute-package",
|
|
2729
|
+
platformKey,
|
|
2730
|
+
packageName: packageInfo.packageName,
|
|
2731
|
+
libraryFile: packageInfo.libraryFile,
|
|
2732
|
+
reason: getErrorMessage(error)
|
|
2733
|
+
};
|
|
2639
2734
|
}
|
|
2640
2735
|
};
|
|
2641
2736
|
|
|
@@ -2827,6 +2922,90 @@ var executeNativeInitSql = (db, initSql) => {
|
|
|
2827
2922
|
db.exec(command);
|
|
2828
2923
|
}
|
|
2829
2924
|
};
|
|
2925
|
+
var getErrorMessage2 = (error) => error instanceof Error ? error.message : String(error);
|
|
2926
|
+
var resolveConfiguredNativeExtension = (nativeConfig) => {
|
|
2927
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
2928
|
+
if (nativeConfig?.extensionPath) {
|
|
2929
|
+
return existsSync2(nativeConfig.extensionPath) ? {
|
|
2930
|
+
status: "resolved",
|
|
2931
|
+
source: "explicit",
|
|
2932
|
+
platformKey,
|
|
2933
|
+
libraryPath: nativeConfig.extensionPath
|
|
2934
|
+
} : {
|
|
2935
|
+
status: "binary_missing",
|
|
2936
|
+
source: "explicit",
|
|
2937
|
+
platformKey,
|
|
2938
|
+
libraryPath: nativeConfig.extensionPath,
|
|
2939
|
+
reason: `Configured native.extensionPath was not found: ${nativeConfig.extensionPath}`
|
|
2940
|
+
};
|
|
2941
|
+
}
|
|
2942
|
+
if (nativeConfig?.resolveFromAbsolutePackages !== false) {
|
|
2943
|
+
const packageResolution = resolveAbsoluteSQLiteVec();
|
|
2944
|
+
if (packageResolution.status === "resolved") {
|
|
2945
|
+
return packageResolution;
|
|
2946
|
+
}
|
|
2947
|
+
if (packageResolution.status === "binary_missing" || packageResolution.status === "package_not_installed" || packageResolution.status === "unsupported_platform") {
|
|
2948
|
+
const envPath2 = process.env.SQLITE_VEC_EXTENSION_PATH;
|
|
2949
|
+
if (envPath2) {
|
|
2950
|
+
return existsSync2(envPath2) ? {
|
|
2951
|
+
status: "resolved",
|
|
2952
|
+
source: "env",
|
|
2953
|
+
platformKey,
|
|
2954
|
+
libraryPath: envPath2
|
|
2955
|
+
} : {
|
|
2956
|
+
status: "binary_missing",
|
|
2957
|
+
source: "env",
|
|
2958
|
+
platformKey,
|
|
2959
|
+
libraryPath: envPath2,
|
|
2960
|
+
reason: `SQLITE_VEC_EXTENSION_PATH was set but not found: ${envPath2}`
|
|
2961
|
+
};
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
return packageResolution;
|
|
2965
|
+
}
|
|
2966
|
+
const envPath = process.env.SQLITE_VEC_EXTENSION_PATH;
|
|
2967
|
+
if (envPath) {
|
|
2968
|
+
return existsSync2(envPath) ? {
|
|
2969
|
+
status: "resolved",
|
|
2970
|
+
source: "env",
|
|
2971
|
+
platformKey,
|
|
2972
|
+
libraryPath: envPath
|
|
2973
|
+
} : {
|
|
2974
|
+
status: "binary_missing",
|
|
2975
|
+
source: "env",
|
|
2976
|
+
platformKey,
|
|
2977
|
+
libraryPath: envPath,
|
|
2978
|
+
reason: `SQLITE_VEC_EXTENSION_PATH was set but not found: ${envPath}`
|
|
2979
|
+
};
|
|
2980
|
+
}
|
|
2981
|
+
return {
|
|
2982
|
+
status: "not_configured",
|
|
2983
|
+
source: "database",
|
|
2984
|
+
platformKey,
|
|
2985
|
+
reason: "No native sqlite-vec path was configured. AbsoluteJS will still attempt vec0 initialization in case the extension is already registered on the Database connection."
|
|
2986
|
+
};
|
|
2987
|
+
};
|
|
2988
|
+
var describeNativeFallbackReason = (resolution) => {
|
|
2989
|
+
if (!resolution) {
|
|
2990
|
+
return "Native sqlite vec0 was not configured.";
|
|
2991
|
+
}
|
|
2992
|
+
switch (resolution.status) {
|
|
2993
|
+
case "resolved":
|
|
2994
|
+
return;
|
|
2995
|
+
case "package_not_installed":
|
|
2996
|
+
return `Install ${resolution.packageName ?? "@absolutejs/absolute-rag-sqlite"} for ${resolution.platformKey}, or provide native.extensionPath.`;
|
|
2997
|
+
case "binary_missing":
|
|
2998
|
+
return resolution.reason ?? "Resolved sqlite-vec binary was missing.";
|
|
2999
|
+
case "unsupported_platform":
|
|
3000
|
+
return resolution.reason ?? "This platform is not yet supported by AbsoluteJS sqlite-vec packages.";
|
|
3001
|
+
case "not_configured":
|
|
3002
|
+
return resolution.reason ?? "No sqlite-vec binary path was configured.";
|
|
3003
|
+
case "package_invalid":
|
|
3004
|
+
return resolution.reason ?? "The sqlite-vec package manifest was invalid.";
|
|
3005
|
+
default:
|
|
3006
|
+
return "Native sqlite vec0 could not be initialized.";
|
|
3007
|
+
}
|
|
3008
|
+
};
|
|
2830
3009
|
var createSQLiteRAGStore = (options = {}) => {
|
|
2831
3010
|
const dimensions = options.dimensions ?? DEFAULT_DIMENSIONS;
|
|
2832
3011
|
const tableName = options.tableName ?? DEFAULT_TABLE_NAME;
|
|
@@ -2842,23 +3021,52 @@ var createSQLiteRAGStore = (options = {}) => {
|
|
|
2842
3021
|
const db = options.db ?? new Database(options.path ?? ":memory:");
|
|
2843
3022
|
const nativeDistanceMetric = nativeConfig?.distanceMetric === "l2" ? "l2" : "cosine";
|
|
2844
3023
|
const nativeQueryMultiplier = normalizeQueryMultiplier(nativeConfig?.queryMultiplier);
|
|
2845
|
-
const
|
|
3024
|
+
const nativeResolution = nativeConfig?.mode === "vec0" ? resolveConfiguredNativeExtension(nativeConfig) : undefined;
|
|
3025
|
+
const nativeDiagnostics = nativeConfig?.mode === "vec0" ? {
|
|
3026
|
+
requested: true,
|
|
3027
|
+
available: false,
|
|
3028
|
+
active: false,
|
|
3029
|
+
mode: nativeConfig.mode,
|
|
3030
|
+
tableName: nativeTableName,
|
|
3031
|
+
distanceMetric: nativeDistanceMetric,
|
|
3032
|
+
resolution: nativeResolution,
|
|
3033
|
+
fallbackReason: describeNativeFallbackReason(nativeResolution)
|
|
3034
|
+
} : undefined;
|
|
2846
3035
|
const jsonStatements = createJsonStatements(db, tableName);
|
|
2847
3036
|
jsonStatements.init();
|
|
2848
3037
|
let useNative = false;
|
|
2849
3038
|
let nativeStatements;
|
|
2850
3039
|
if (nativeConfig?.mode === "vec0") {
|
|
2851
3040
|
try {
|
|
2852
|
-
if (
|
|
2853
|
-
db.loadExtension(
|
|
3041
|
+
if (nativeResolution?.status === "resolved" && nativeResolution.libraryPath) {
|
|
3042
|
+
db.loadExtension(nativeResolution.libraryPath);
|
|
2854
3043
|
}
|
|
2855
3044
|
executeNativeInitSql(db, nativeConfig.extensionInitSql);
|
|
2856
3045
|
createNativeVec0Table(db, nativeTableName, dimensions, nativeDistanceMetric);
|
|
2857
3046
|
nativeStatements = createNativeVec0Statements(db, nativeTableName);
|
|
2858
3047
|
useNative = true;
|
|
3048
|
+
if (nativeDiagnostics) {
|
|
3049
|
+
nativeDiagnostics.available = true;
|
|
3050
|
+
nativeDiagnostics.active = true;
|
|
3051
|
+
nativeDiagnostics.fallbackReason = undefined;
|
|
3052
|
+
if (!nativeDiagnostics.resolution || nativeDiagnostics.resolution.status !== "resolved") {
|
|
3053
|
+
nativeDiagnostics.resolution = {
|
|
3054
|
+
status: "resolved",
|
|
3055
|
+
source: "database",
|
|
3056
|
+
platformKey: `${process.platform}-${process.arch}`,
|
|
3057
|
+
reason: "sqlite-vec was already available on the Database connection or loaded by native.extensionInitSql."
|
|
3058
|
+
};
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
2859
3061
|
} catch (error) {
|
|
3062
|
+
if (nativeDiagnostics) {
|
|
3063
|
+
nativeDiagnostics.available = false;
|
|
3064
|
+
nativeDiagnostics.active = false;
|
|
3065
|
+
nativeDiagnostics.lastLoadError = getErrorMessage2(error);
|
|
3066
|
+
nativeDiagnostics.fallbackReason = describeNativeFallbackReason(nativeResolution) ?? nativeDiagnostics.lastLoadError;
|
|
3067
|
+
}
|
|
2860
3068
|
if (nativeConfig.requireAvailable) {
|
|
2861
|
-
throw new Error(`Failed to initialize sqlite vec0 backend for table "${nativeTableName}". ` + `Install @absolutejs/absolute-rag-sqlite for your platform, set native.extensionPath, or pre-register the sqlite-vec extension in the Database connection
|
|
3069
|
+
throw new Error(`Failed to initialize sqlite vec0 backend for table "${nativeTableName}". ` + `Install @absolutejs/absolute-rag-sqlite for your platform, set native.extensionPath, or pre-register the sqlite-vec extension in the Database connection. ` + `Details: ${getErrorMessage2(error)}`);
|
|
2862
3070
|
}
|
|
2863
3071
|
useNative = false;
|
|
2864
3072
|
}
|
|
@@ -2924,11 +3132,18 @@ var createSQLiteRAGStore = (options = {}) => {
|
|
|
2924
3132
|
}
|
|
2925
3133
|
try {
|
|
2926
3134
|
return await queryNative(input);
|
|
2927
|
-
} catch {
|
|
3135
|
+
} catch (error) {
|
|
3136
|
+
if (nativeDiagnostics) {
|
|
3137
|
+
nativeDiagnostics.lastQueryError = getErrorMessage2(error);
|
|
3138
|
+
}
|
|
2928
3139
|
if (!nativeConfig?.requireAvailable) {
|
|
3140
|
+
if (nativeDiagnostics) {
|
|
3141
|
+
nativeDiagnostics.active = false;
|
|
3142
|
+
nativeDiagnostics.fallbackReason = nativeDiagnostics.lastQueryError;
|
|
3143
|
+
}
|
|
2929
3144
|
return queryFallback(input);
|
|
2930
3145
|
}
|
|
2931
|
-
throw new Error(`Native vector query failed for table "${nativeTableName}"
|
|
3146
|
+
throw new Error(`Native vector query failed for table "${nativeTableName}". ${getErrorMessage2(error)}`);
|
|
2932
3147
|
}
|
|
2933
3148
|
};
|
|
2934
3149
|
const upsert = async (input) => {
|
|
@@ -2955,11 +3170,18 @@ var createSQLiteRAGStore = (options = {}) => {
|
|
|
2955
3170
|
nativeStatements.insert.run(chunk.chunkId, toVectorText(chunk.vector), chunk.text, chunk.title ?? null, chunk.source ?? null, toJSONString(chunk.metadata));
|
|
2956
3171
|
}
|
|
2957
3172
|
return;
|
|
2958
|
-
} catch {
|
|
3173
|
+
} catch (error) {
|
|
3174
|
+
if (nativeDiagnostics) {
|
|
3175
|
+
nativeDiagnostics.lastUpsertError = getErrorMessage2(error);
|
|
3176
|
+
}
|
|
2959
3177
|
if (nativeConfig?.requireAvailable) {
|
|
2960
|
-
throw new Error(`Native vector upsert failed for table "${nativeTableName}"
|
|
3178
|
+
throw new Error(`Native vector upsert failed for table "${nativeTableName}". ${getErrorMessage2(error)}`);
|
|
2961
3179
|
}
|
|
2962
3180
|
useNative = false;
|
|
3181
|
+
if (nativeDiagnostics) {
|
|
3182
|
+
nativeDiagnostics.active = false;
|
|
3183
|
+
nativeDiagnostics.fallbackReason = nativeDiagnostics.lastUpsertError;
|
|
3184
|
+
}
|
|
2963
3185
|
for (const chunk of chunks) {
|
|
2964
3186
|
jsonStatements.insert.run(chunk.chunkId, chunk.text, chunk.title ?? null, chunk.source ?? null, toJSONString(chunk.metadata), toVectorText(chunk.vector));
|
|
2965
3187
|
}
|
|
@@ -2976,11 +3198,26 @@ var createSQLiteRAGStore = (options = {}) => {
|
|
|
2976
3198
|
jsonStatements.clear.run();
|
|
2977
3199
|
}
|
|
2978
3200
|
};
|
|
3201
|
+
const getStatus = () => ({
|
|
3202
|
+
backend: "sqlite",
|
|
3203
|
+
vectorMode: useNative ? "native_vec0" : "json_fallback",
|
|
3204
|
+
dimensions,
|
|
3205
|
+
native: nativeDiagnostics
|
|
3206
|
+
});
|
|
3207
|
+
const getCapabilities = () => ({
|
|
3208
|
+
backend: "sqlite",
|
|
3209
|
+
persistence: "embedded",
|
|
3210
|
+
nativeVectorSearch: useNative,
|
|
3211
|
+
serverSideFiltering: useNative,
|
|
3212
|
+
streamingIngestStatus: false
|
|
3213
|
+
});
|
|
2979
3214
|
return {
|
|
2980
3215
|
embed,
|
|
2981
3216
|
query,
|
|
2982
3217
|
upsert,
|
|
2983
|
-
clear
|
|
3218
|
+
clear,
|
|
3219
|
+
getCapabilities,
|
|
3220
|
+
getStatus
|
|
2984
3221
|
};
|
|
2985
3222
|
};
|
|
2986
3223
|
// src/ai/conversationManager.ts
|
|
@@ -3082,6 +3319,8 @@ export {
|
|
|
3082
3319
|
xai,
|
|
3083
3320
|
streamAI,
|
|
3084
3321
|
serializeAIMessage,
|
|
3322
|
+
searchDocuments,
|
|
3323
|
+
ragChat as ragPlugin,
|
|
3085
3324
|
ragChat,
|
|
3086
3325
|
querySimilarity,
|
|
3087
3326
|
parseAIMessage,
|
|
@@ -3091,12 +3330,14 @@ export {
|
|
|
3091
3330
|
moonshot,
|
|
3092
3331
|
mistralai,
|
|
3093
3332
|
meta,
|
|
3333
|
+
ingestDocuments,
|
|
3094
3334
|
google,
|
|
3095
3335
|
generateId,
|
|
3096
3336
|
gemini,
|
|
3097
3337
|
deepseek,
|
|
3098
3338
|
createSQLiteRAGStore,
|
|
3099
3339
|
createRAGVector,
|
|
3340
|
+
createRAGCollection,
|
|
3100
3341
|
createMemoryStore,
|
|
3101
3342
|
createInMemoryRAGStore,
|
|
3102
3343
|
createConversationManager,
|
|
@@ -3104,5 +3345,5 @@ export {
|
|
|
3104
3345
|
aiChat
|
|
3105
3346
|
};
|
|
3106
3347
|
|
|
3107
|
-
//# debugId=
|
|
3348
|
+
//# debugId=5BB1CA8CA8CE871864756E2164756E21
|
|
3108
3349
|
//# sourceMappingURL=index.js.map
|