@lunora/ai 1.0.0-alpha.9 → 1.0.0-alpha.91
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/README.md +3 -1
- package/dist/index.d.mts +88 -27
- package/dist/index.d.ts +88 -27
- package/dist/index.mjs +1 -3
- package/dist/packem_shared/AI_DEFAULT_EMBEDDING_MODEL_ENV-BEAzcoBw.mjs +1 -0
- package/dist/packem_shared/DEFAULT_MODEL_PRICES-Q8uxdiuV.mjs +1 -0
- package/dist/packem_shared/VECTORIZE_CAPABILITIES-CUQDoxis.mjs +1 -0
- package/dist/packem_shared/batchReranker-Bc38FBLH.mjs +1 -0
- package/dist/packem_shared/bm25-9q0Avwi-.mjs +1 -0
- package/dist/packem_shared/bm25LexicalStore-DMUzAL0O.mjs +1 -0
- package/dist/packem_shared/concurrent-C6nqBv41.mjs +1 -0
- package/dist/packem_shared/contentHash-BIn6ECP8.mjs +1 -0
- package/dist/packem_shared/createAi-CHSAfN98.mjs +1 -0
- package/dist/packem_shared/defineRag-DK8Ifpn_.mjs +8 -0
- package/dist/packem_shared/defineRagSource-Q3f3niU8.mjs +1 -0
- package/dist/packem_shared/fixedWindowChunks-C461ahRE.mjs +1 -0
- package/dist/packem_shared/hybridRank-B4skyCLx.mjs +1 -0
- package/dist/packem_shared/markdownChunker-Bcv56GEz.mjs +5 -0
- package/dist/packem_shared/matchesMetadataFilter-BbIOyA5g.mjs +1 -0
- package/dist/packem_shared/ragSyncTriggers-DPqzBNFw.mjs +1 -0
- package/dist/packem_shared/sql-D5aqEMCY.mjs +1 -0
- package/dist/packem_shared/sqlLexicalStore-4C_cIwef.mjs +1 -0
- package/dist/packem_shared/sqliteVectorStore-D32l9lP0.mjs +1 -0
- package/dist/packem_shared/types.d-D3U2budn.d.mts +310 -0
- package/dist/packem_shared/types.d-D3U2budn.d.ts +310 -0
- package/dist/rag/index.d.mts +1323 -0
- package/dist/rag/index.d.ts +1323 -0
- package/dist/rag/index.mjs +1 -0
- package/package.json +12 -6
- package/dist/packem_shared/createAi-Bq_4LMcp.mjs +0 -54
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as o}from"../packem_shared/fixedWindowChunks-C461ahRE.mjs";import{markdownChunker as a,sentenceChunker as f,tokenChunker as n}from"../packem_shared/markdownChunker-Bcv56GEz.mjs";import{default as x}from"../packem_shared/defineRag-DK8Ifpn_.mjs";import{contentHash as p,guessMimeTypeFromExtension as i}from"../packem_shared/contentHash-BIn6ECP8.mjs";import{hybridRank as d}from"../packem_shared/hybridRank-B4skyCLx.mjs";import{default as k}from"../packem_shared/bm25LexicalStore-DMUzAL0O.mjs";import{default as h}from"../packem_shared/matchesMetadataFilter-BbIOyA5g.mjs";import{batchReranker as g,scoreReranker as C}from"../packem_shared/batchReranker-Bc38FBLH.mjs";import{defineRagSource as E}from"../packem_shared/defineRagSource-Q3f3niU8.mjs";import{sqlLexicalStore as T}from"../packem_shared/sqlLexicalStore-4C_cIwef.mjs";import{sqliteVectorStore as y}from"../packem_shared/sqliteVectorStore-D32l9lP0.mjs";import{ragSyncTriggers as q}from"../packem_shared/ragSyncTriggers-DPqzBNFw.mjs";import{VECTORIZE_CAPABILITIES as A,vectorizeStore as F}from"../packem_shared/VECTORIZE_CAPABILITIES-CUQDoxis.mjs";export{A as VECTORIZE_CAPABILITIES,g as batchReranker,k as bm25LexicalStore,p as contentHash,x as defineRag,E as defineRagSource,o as fixedWindowChunks,i as guessMimeTypeFromExtension,d as hybridRank,a as markdownChunker,h as matchesMetadataFilter,q as ragSyncTriggers,C as scoreReranker,f as sentenceChunker,T as sqlLexicalStore,y as sqliteVectorStore,n as tokenChunker,F as vectorizeStore};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/ai",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.91",
|
|
4
4
|
"description": "Workers AI helper for Lunora: provider-agnostic AI SDK access from functions, Workers AI by default",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"inference",
|
|
11
11
|
"llm",
|
|
12
12
|
"lunora",
|
|
13
|
+
"rag",
|
|
14
|
+
"retrieval",
|
|
13
15
|
"workers",
|
|
14
16
|
"workers-ai"
|
|
15
17
|
],
|
|
@@ -41,19 +43,23 @@
|
|
|
41
43
|
"types": "./dist/index.d.ts",
|
|
42
44
|
"import": "./dist/index.mjs"
|
|
43
45
|
},
|
|
46
|
+
"./rag": {
|
|
47
|
+
"types": "./dist/rag/index.d.ts",
|
|
48
|
+
"import": "./dist/rag/index.mjs"
|
|
49
|
+
},
|
|
44
50
|
"./package.json": "./package.json"
|
|
45
51
|
},
|
|
46
52
|
"publishConfig": {
|
|
47
53
|
"access": "public"
|
|
48
54
|
},
|
|
49
55
|
"dependencies": {
|
|
50
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
51
|
-
"ai": "7.0.
|
|
52
|
-
"workers-ai-provider": "
|
|
56
|
+
"@lunora/errors": "1.0.0-alpha.37",
|
|
57
|
+
"ai": "7.0.93",
|
|
58
|
+
"workers-ai-provider": "4.0.0"
|
|
53
59
|
},
|
|
54
60
|
"peerDependencies": {
|
|
55
|
-
"@ai-sdk/anthropic": "4.0.
|
|
56
|
-
"@ai-sdk/openai": "4.0.
|
|
61
|
+
"@ai-sdk/anthropic": "^4.0.0",
|
|
62
|
+
"@ai-sdk/openai": "^4.0.0"
|
|
57
63
|
},
|
|
58
64
|
"peerDependenciesMeta": {
|
|
59
65
|
"@ai-sdk/anthropic": {
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { LunoraError } from '@lunora/errors';
|
|
2
|
-
import { createWorkersAI } from 'workers-ai-provider';
|
|
3
|
-
|
|
4
|
-
const buildProvider = (binding, gateway) => createWorkersAI({ binding, gateway });
|
|
5
|
-
const createAi = (options) => {
|
|
6
|
-
const { binding, defaultModel, gateway, provider } = options;
|
|
7
|
-
if (!provider && !binding) {
|
|
8
|
-
throw new LunoraError("INTERNAL", "@lunora/ai: createAi requires a `binding` (env.AI) or a pre-built `provider`");
|
|
9
|
-
}
|
|
10
|
-
const workersai = provider ?? buildProvider(binding, gateway);
|
|
11
|
-
const model = (input) => {
|
|
12
|
-
if (input === void 0) {
|
|
13
|
-
if (!defaultModel) {
|
|
14
|
-
throw new LunoraError("INTERNAL", "@lunora/ai: no model supplied and no `defaultModel` configured — pass a model id or an AI SDK model");
|
|
15
|
-
}
|
|
16
|
-
return workersai(defaultModel);
|
|
17
|
-
}
|
|
18
|
-
return typeof input === "string" ? workersai(input) : input;
|
|
19
|
-
};
|
|
20
|
-
const resolveEmbeddingModel = (modelId) => {
|
|
21
|
-
const factory = workersai.textEmbeddingModel;
|
|
22
|
-
if (typeof factory !== "function") {
|
|
23
|
-
throw new TypeError(
|
|
24
|
-
"@lunora/ai: the Workers AI provider does not expose `textEmbeddingModel`; pass an AI SDK EmbeddingModel (e.g. from @ai-sdk/openai) to embed()"
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
return factory.call(workersai, modelId);
|
|
28
|
-
};
|
|
29
|
-
const embeddingModel = (input) => {
|
|
30
|
-
if (typeof input === "object") {
|
|
31
|
-
return input;
|
|
32
|
-
}
|
|
33
|
-
const modelId = input ?? defaultModel;
|
|
34
|
-
if (!modelId) {
|
|
35
|
-
throw new LunoraError(
|
|
36
|
-
"INTERNAL",
|
|
37
|
-
"@lunora/ai: no embedding model supplied and no `defaultModel` configured — pass an embedding model id or an AI SDK EmbeddingModel"
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
return resolveEmbeddingModel(modelId);
|
|
41
|
-
};
|
|
42
|
-
const run = async (modelId, inputs, runOptions) => {
|
|
43
|
-
if (!binding) {
|
|
44
|
-
throw new LunoraError(
|
|
45
|
-
"INTERNAL",
|
|
46
|
-
"@lunora/ai: ai.run requires the `binding` (env.AI) — it is unavailable when only a custom `provider` was supplied"
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return binding.run(modelId, inputs, runOptions);
|
|
50
|
-
};
|
|
51
|
-
return { embeddingModel, model, run, workersai };
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export { createAi as default };
|