@absolutejs/absolute 0.19.0-beta.364 → 0.19.0-beta.366
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 +108 -2
- package/dist/ai/index.js.map +7 -6
- package/dist/ai-client/angular/ai/index.js +102 -0
- package/dist/ai-client/react/ai/index.js +176 -0
- package/dist/ai-client/vue/ai/index.js +172 -0
- package/dist/angular/ai/index.js +103 -1
- package/dist/angular/ai/index.js.map +5 -3
- package/dist/angular/browser.js +8 -12
- package/dist/angular/browser.js.map +4 -4
- package/dist/angular/index.js +4420 -4465
- package/dist/angular/index.js.map +8 -8
- package/dist/build.js +578 -23
- package/dist/build.js.map +10 -4
- package/dist/client/index.js +44 -45
- package/dist/client/index.js.map +4 -4
- package/dist/index.js +4340 -4363
- package/dist/index.js.map +15 -14
- package/dist/react/ai/index.js +177 -1
- package/dist/react/ai/index.js.map +7 -3
- package/dist/react/components/browser/index.js +18 -6
- package/dist/react/components/index.js +35 -16
- package/dist/react/components/index.js.map +6 -5
- package/dist/react/index.js +1774 -1803
- package/dist/react/index.js.map +12 -12
- package/dist/react/server.js +574 -3
- package/dist/react/server.js.map +11 -4
- package/dist/src/ai/client/ragClient.d.ts +16 -0
- package/dist/src/ai/index.d.ts +2 -1
- package/dist/src/ai/rag/chat.d.ts +41 -5
- package/dist/src/ai/rag/index.d.ts +1 -1
- package/dist/src/ai/rag/types.d.ts +1 -1
- package/dist/src/angular/ai/index.d.ts +1 -0
- package/dist/src/angular/ai/rag-client.service.d.ts +11 -0
- package/dist/src/core/pageHandlers.d.ts +0 -1
- package/dist/src/react/ai/index.d.ts +3 -0
- package/dist/src/react/ai/useRAGIngest.d.ts +8 -0
- package/dist/src/react/ai/useRAGSearch.d.ts +9 -0
- package/dist/src/react/ai/useRAGStatus.d.ts +9 -0
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/react/streamingSlotCollection.d.ts +9 -0
- package/dist/src/svelte/ai/createRAGIngest.d.ts +7 -0
- package/dist/src/svelte/ai/createRAGSearch.d.ts +7 -0
- package/dist/src/svelte/ai/createRAGStatus.d.ts +8 -0
- package/dist/src/svelte/ai/index.d.ts +3 -0
- package/dist/src/vue/ai/index.d.ts +3 -0
- package/dist/src/vue/ai/useRAGIngest.d.ts +7 -0
- package/dist/src/vue/ai/useRAGSearch.d.ts +21 -0
- package/dist/src/vue/ai/useRAGStatus.d.ts +8 -0
- package/dist/svelte/ai/index.js +171 -1
- package/dist/svelte/ai/index.js.map +8 -4
- package/dist/svelte/index.js +1881 -1926
- package/dist/svelte/index.js.map +8 -8
- package/dist/types/ai.d.ts +11 -0
- package/dist/vue/ai/index.js +173 -1
- package/dist/vue/ai/index.js.map +7 -3
- package/dist/vue/components/index.js +8 -12
- package/dist/vue/components/index.js.map +5 -5
- package/dist/vue/index.js +1929 -1976
- package/dist/vue/index.js.map +8 -8
- package/package.json +1 -1
package/dist/ai/index.js
CHANGED
|
@@ -2409,6 +2409,42 @@ var ragChat = (config) => {
|
|
|
2409
2409
|
await ragStore.upsert({ chunks: chunksValue });
|
|
2410
2410
|
return { count: chunksValue.length, ok: true };
|
|
2411
2411
|
};
|
|
2412
|
+
const handleSearch = async (body) => {
|
|
2413
|
+
if (!body || typeof body !== "object") {
|
|
2414
|
+
return { ok: false, error: "Invalid payload" };
|
|
2415
|
+
}
|
|
2416
|
+
const payload = body;
|
|
2417
|
+
const query = typeof payload.query === "string" ? payload.query.trim() : "";
|
|
2418
|
+
if (!query) {
|
|
2419
|
+
return { ok: false, error: "Expected payload shape: { query: string }" };
|
|
2420
|
+
}
|
|
2421
|
+
const collection = config.collection ?? (ragStore ? createRAGCollection({
|
|
2422
|
+
defaultTopK: topK,
|
|
2423
|
+
store: ragStore
|
|
2424
|
+
}) : null);
|
|
2425
|
+
if (!collection) {
|
|
2426
|
+
return { ok: false, error: "RAG collection is not configured" };
|
|
2427
|
+
}
|
|
2428
|
+
const results = await collection.search({
|
|
2429
|
+
filter: payload.filter,
|
|
2430
|
+
model: payload.model,
|
|
2431
|
+
query,
|
|
2432
|
+
scoreThreshold: payload.scoreThreshold,
|
|
2433
|
+
topK: payload.topK
|
|
2434
|
+
});
|
|
2435
|
+
return { ok: true, results: buildSources(results) };
|
|
2436
|
+
};
|
|
2437
|
+
const handleStatus = () => {
|
|
2438
|
+
const collection = config.collection ?? (ragStore ? createRAGCollection({
|
|
2439
|
+
defaultTopK: topK,
|
|
2440
|
+
store: ragStore
|
|
2441
|
+
}) : null);
|
|
2442
|
+
return {
|
|
2443
|
+
ok: true,
|
|
2444
|
+
status: collection?.getStatus?.(),
|
|
2445
|
+
capabilities: collection?.getCapabilities?.()
|
|
2446
|
+
};
|
|
2447
|
+
};
|
|
2412
2448
|
const htmxRoutes = () => {
|
|
2413
2449
|
if (!config.htmx) {
|
|
2414
2450
|
return new Elysia2;
|
|
@@ -2515,7 +2551,7 @@ var ragChat = (config) => {
|
|
|
2515
2551
|
await handleMessage(ws, msg.content, msg.conversationId, msg.attachments);
|
|
2516
2552
|
}
|
|
2517
2553
|
}
|
|
2518
|
-
}).post(`${path}/ingest`, async ({ body }) => handleIngest(body)).delete(`${path}/index`, async () => {
|
|
2554
|
+
}).post(`${path}/search`, async ({ body }) => handleSearch(body)).get(`${path}/status`, () => handleStatus()).post(`${path}/ingest`, async ({ body }) => handleIngest(body)).delete(`${path}/index`, async () => {
|
|
2519
2555
|
if (!ragStore) {
|
|
2520
2556
|
return { ok: false };
|
|
2521
2557
|
}
|
|
@@ -3315,6 +3351,75 @@ var createConversationManager = () => {
|
|
|
3315
3351
|
remove
|
|
3316
3352
|
};
|
|
3317
3353
|
};
|
|
3354
|
+
// src/ai/client/ragClient.ts
|
|
3355
|
+
var jsonHeaders = {
|
|
3356
|
+
"Content-Type": "application/json"
|
|
3357
|
+
};
|
|
3358
|
+
var normalizeBasePath = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
|
|
3359
|
+
var parseJson = async (response) => {
|
|
3360
|
+
const payload = await response.json();
|
|
3361
|
+
return payload;
|
|
3362
|
+
};
|
|
3363
|
+
var toErrorMessage = async (response) => {
|
|
3364
|
+
try {
|
|
3365
|
+
const payload = await response.json();
|
|
3366
|
+
if (typeof payload.error === "string" && payload.error) {
|
|
3367
|
+
return payload.error;
|
|
3368
|
+
}
|
|
3369
|
+
} catch {}
|
|
3370
|
+
return `Request failed with status ${response.status}`;
|
|
3371
|
+
};
|
|
3372
|
+
var createRAGClient = (options) => {
|
|
3373
|
+
const basePath = normalizeBasePath(options.path);
|
|
3374
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
3375
|
+
return {
|
|
3376
|
+
async ingest(chunks) {
|
|
3377
|
+
const response = await fetchImpl(`${basePath}/ingest`, {
|
|
3378
|
+
body: JSON.stringify({ chunks }),
|
|
3379
|
+
headers: jsonHeaders,
|
|
3380
|
+
method: "POST"
|
|
3381
|
+
});
|
|
3382
|
+
if (!response.ok) {
|
|
3383
|
+
return {
|
|
3384
|
+
ok: false,
|
|
3385
|
+
error: await toErrorMessage(response)
|
|
3386
|
+
};
|
|
3387
|
+
}
|
|
3388
|
+
return parseJson(response);
|
|
3389
|
+
},
|
|
3390
|
+
async search(input) {
|
|
3391
|
+
const response = await fetchImpl(`${basePath}/search`, {
|
|
3392
|
+
body: JSON.stringify(input),
|
|
3393
|
+
headers: jsonHeaders,
|
|
3394
|
+
method: "POST"
|
|
3395
|
+
});
|
|
3396
|
+
if (!response.ok) {
|
|
3397
|
+
throw new Error(await toErrorMessage(response));
|
|
3398
|
+
}
|
|
3399
|
+
const payload = await parseJson(response);
|
|
3400
|
+
if (!payload.ok) {
|
|
3401
|
+
throw new Error(payload.error ?? "RAG search failed");
|
|
3402
|
+
}
|
|
3403
|
+
return payload.results ?? [];
|
|
3404
|
+
},
|
|
3405
|
+
async status() {
|
|
3406
|
+
const response = await fetchImpl(`${basePath}/status`);
|
|
3407
|
+
if (!response.ok) {
|
|
3408
|
+
throw new Error(await toErrorMessage(response));
|
|
3409
|
+
}
|
|
3410
|
+
return parseJson(response);
|
|
3411
|
+
},
|
|
3412
|
+
async clearIndex() {
|
|
3413
|
+
const response = await fetchImpl(`${basePath}/index`, {
|
|
3414
|
+
method: "DELETE"
|
|
3415
|
+
});
|
|
3416
|
+
if (!response.ok) {
|
|
3417
|
+
throw new Error(await toErrorMessage(response));
|
|
3418
|
+
}
|
|
3419
|
+
return parseJson(response);
|
|
3420
|
+
}
|
|
3421
|
+
};
|
|
3422
|
+
};
|
|
3318
3423
|
export {
|
|
3319
3424
|
xai,
|
|
3320
3425
|
streamAI,
|
|
@@ -3338,6 +3443,7 @@ export {
|
|
|
3338
3443
|
createSQLiteRAGStore,
|
|
3339
3444
|
createRAGVector,
|
|
3340
3445
|
createRAGCollection,
|
|
3446
|
+
createRAGClient,
|
|
3341
3447
|
createMemoryStore,
|
|
3342
3448
|
createInMemoryRAGStore,
|
|
3343
3449
|
createConversationManager,
|
|
@@ -3345,5 +3451,5 @@ export {
|
|
|
3345
3451
|
aiChat
|
|
3346
3452
|
};
|
|
3347
3453
|
|
|
3348
|
-
//# debugId=
|
|
3454
|
+
//# debugId=CA562F087EBA565564756E2164756E21
|
|
3349
3455
|
//# sourceMappingURL=index.js.map
|