@lunora/ai 1.0.0-alpha.64 → 1.0.0-alpha.66
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/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/DEFAULT_MODEL_PRICES-Q8uxdiuV.mjs +1 -0
- package/dist/packem_shared/{defineRag-Dzh-MbCu.mjs → defineRag-CMM17YeT.mjs} +1 -1
- package/dist/packem_shared/sql-CNy5-Oop.mjs +1 -0
- package/dist/packem_shared/{sqlLexicalStore-DcWChCVZ.mjs → sqlLexicalStore-qkTJHHzM.mjs} +1 -1
- package/dist/packem_shared/{sqliteVectorStore-B4HiD_-t.mjs → sqliteVectorStore-DEqrp-Uc.mjs} +1 -1
- package/dist/rag/index.d.mts +0 -12
- package/dist/rag/index.d.ts +0 -12
- package/dist/rag/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/packem_shared/DEFAULT_MODEL_PRICES-DZ3dYVUn.mjs +0 -1
- package/dist/packem_shared/sql-D6W_98IK.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -63,9 +63,14 @@ interface ModelUsage {
|
|
|
63
63
|
* An indicative price table, keyed by model id.
|
|
64
64
|
*
|
|
65
65
|
* Deliberately small: a table that tries to cover every model is a table that
|
|
66
|
-
* is wrong about most of them. It holds the
|
|
67
|
-
*
|
|
68
|
-
* else returns `undefined` rather than a guess.
|
|
66
|
+
* is wrong about most of them. It holds the models Lunora's own defaults and
|
|
67
|
+
* documented examples reference — text generation and embeddings, on Workers AI
|
|
68
|
+
* and OpenAI — and everything else returns `undefined` rather than a guess.
|
|
69
|
+
*
|
|
70
|
+
* Generation models carry an `output` price; embedding models do not (they have
|
|
71
|
+
* no completion). A generation model missing from here is why a chat span would
|
|
72
|
+
* carry no cost at all off an AI Gateway, so the ids the docs teach are the ones
|
|
73
|
+
* that have to be in the table.
|
|
69
74
|
*/
|
|
70
75
|
declare const DEFAULT_MODEL_PRICES: Readonly<Record<string, ModelPrice>>;
|
|
71
76
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -63,9 +63,14 @@ interface ModelUsage {
|
|
|
63
63
|
* An indicative price table, keyed by model id.
|
|
64
64
|
*
|
|
65
65
|
* Deliberately small: a table that tries to cover every model is a table that
|
|
66
|
-
* is wrong about most of them. It holds the
|
|
67
|
-
*
|
|
68
|
-
* else returns `undefined` rather than a guess.
|
|
66
|
+
* is wrong about most of them. It holds the models Lunora's own defaults and
|
|
67
|
+
* documented examples reference — text generation and embeddings, on Workers AI
|
|
68
|
+
* and OpenAI — and everything else returns `undefined` rather than a guess.
|
|
69
|
+
*
|
|
70
|
+
* Generation models carry an `output` price; embedding models do not (they have
|
|
71
|
+
* no completion). A generation model missing from here is why a chat span would
|
|
72
|
+
* carry no cost at all off an AI Gateway, so the ids the docs teach are the ones
|
|
73
|
+
* that have to be in the table.
|
|
69
74
|
*/
|
|
70
75
|
declare const DEFAULT_MODEL_PRICES: Readonly<Record<string, ModelPrice>>;
|
|
71
76
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"./packem_shared/createAi-DIJS_f7H.mjs";import{AI_GATEWAY_ACCOUNT_ID_ENV as r,AI_GATEWAY_ID_ENV as A,AI_GATEWAY_TOKEN_ENV as _,buildAiGatewayMetadataFields as l,resolveAiGateway as m}from"./packem_shared/AI_GATEWAY_ACCOUNT_ID_ENV-9ptmPAYP.mjs";import{DEFAULT_MODEL_PRICES as E,estimateModelCost as T,lookupModelPrice as d}from"./packem_shared/DEFAULT_MODEL_PRICES-
|
|
1
|
+
import{default as o}from"./packem_shared/createAi-DIJS_f7H.mjs";import{AI_GATEWAY_ACCOUNT_ID_ENV as r,AI_GATEWAY_ID_ENV as A,AI_GATEWAY_TOKEN_ENV as _,buildAiGatewayMetadataFields as l,resolveAiGateway as m}from"./packem_shared/AI_GATEWAY_ACCOUNT_ID_ENV-9ptmPAYP.mjs";import{DEFAULT_MODEL_PRICES as E,estimateModelCost as T,lookupModelPrice as d}from"./packem_shared/DEFAULT_MODEL_PRICES-Q8uxdiuV.mjs";import{embed as x,embedMany as I,generateObject as c,generateText as f,hasToolCall as p,jsonSchema as b,streamObject as C,streamText as G,tool as M}from"ai";import{createWorkersAI as O}from"workers-ai-provider";export{r as AI_GATEWAY_ACCOUNT_ID_ENV,A as AI_GATEWAY_ID_ENV,_ as AI_GATEWAY_TOKEN_ENV,E as DEFAULT_MODEL_PRICES,l as buildAiGatewayMetadataFields,o as createAi,O as createWorkersAI,x as embed,I as embedMany,T as estimateModelCost,c as generateObject,f as generateText,p as hasToolCall,b as jsonSchema,d as lookupModelPrice,m as resolveAiGateway,C as streamObject,G as streamText,M as tool};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const p=/^(.*)-\d{4}-\d{2}-\d{2}$/u,a={"@cf/baai/bge-base-en-v1.5":{input:.067},"@cf/baai/bge-large-en-v1.5":{input:.204},"@cf/baai/bge-m3":{input:.012},"@cf/baai/bge-small-en-v1.5":{input:.02},"@cf/meta/llama-3.1-8b-instruct":{input:.28,output:.83},"@cf/meta/llama-3.3-70b-instruct-fp8-fast":{input:.29,output:2.25},"text-embedding-3-large":{input:.13},"text-embedding-3-small":{input:.02},"gpt-4o":{input:2.5,output:10},"gpt-4o-mini":{input:.15,output:.6},"gpt-5":{input:1.25,output:10}},r=n=>{const t=n.trim(),i=t.lastIndexOf("/");return(i!==-1&&!t.startsWith("@")?[t,t.slice(i+1)]:[t]).flatMap(e=>{const o=p.exec(e)?.[1];return o===void 0?[e]:[e,o]})},c=(n,t=a)=>{for(const i of r(n))if(Object.hasOwn(t,i))return t[i]},b=(n,t,i)=>{if(n===void 0||n.length===0)return;const u=c(n,i);if(u===void 0)return;const e=Number.isFinite(t.inputTokens)?Math.max(0,t.inputTokens):0,o=Number.isFinite(t.outputTokens)?Math.max(0,t.outputTokens):0;if(e<=0&&o<=0)return;const s=(e*u.input+o*(u.output??0))/1e6;return Number.isFinite(s)?s:void 0};export{a as DEFAULT_MODEL_PRICES,b as estimateModelCost,c as lookupModelPrice};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{LunoraError as g,isLunoraError as ye}from"@lunora/errors";import{tool as xe,jsonSchema as Ie,embedMany as Se,embed as _e}from"ai";import{estimateModelCost as ke}from"./DEFAULT_MODEL_PRICES-
|
|
1
|
+
import{LunoraError as g,isLunoraError as ye}from"@lunora/errors";import{tool as xe,jsonSchema as Ie,embedMany as Se,embed as _e}from"ai";import{estimateModelCost as ke}from"./DEFAULT_MODEL_PRICES-Q8uxdiuV.mjs";import Te from"./fixedWindowChunks-C461ahRE.mjs";import{c as Ae,I as Ne}from"./concurrent-C6nqBv41.mjs";import{contentHash as Me}from"./contentHash-BIn6ECP8.mjs";import ee from"./hybridRank-DejmVw2I.mjs";import{VECTORIZE_CAPABILITIES as te,vectorizeStore as De}from"./VECTORIZE_CAPABILITIES-CUQDoxis.mjs";const Re=1e3,Ce=200,$e=5,Be=4,ne=te.maxMetadataBytes===!1?Number.POSITIVE_INFINITY:te.maxMetadataBytes,Oe=2*1024,ie="__ragChunk",ce="__ragSource",A="__ragText",Q="__ragHash",V="__ragChunks",B="__ragImportance",de="__ragModel",Ke=new Set([ie,V,Q,B,de,ce,A]),Ue=(e,i,m,w)=>{if(w===!1)return;const E=new TextEncoder().encode(JSON.stringify(e)).length;if(E<=w)return;const R=(typeof e[A]=="string"?new TextEncoder().encode(e[A]).length:0)*2>E?"lower `chunkSize` (it counts characters, not bytes — multibyte text costs up to 3 bytes each), or supply `textStore` to move chunk text out of metadata entirely":"attach less per-source `metadata`";throw new g("BAD_REQUEST",`@lunora/ai/rag: chunk ${String(i)} of "${m}" carries ${String(E)} bytes of metadata, over the store's ${String(w)}-byte per-vector ceiling — ${R}`)},Qe=(e,i,m)=>{if(m===!1)return;const w=new TextEncoder().encode(e).length;if(!(w<=m))throw new g("BAD_REQUEST",`@lunora/ai/rag: chunk id "${e}" for source "${i}" is ${String(w)} bytes, over the store's ${String(m)}-byte per-vector id ceiling — shorten the source id (hash long keys before indexing them) or shorten the \`namespace\`, which is prefixed onto every chunk id`)},Ve=/^[\w.-]{1,40}$/,ue=e=>e===void 0?"":`${encodeURIComponent(e)}#`,T=(e,i,m)=>`${ue(e)}${i}#${String(m)}`,re=(e,i)=>{const m=ue(i),w=m!==""&&e.startsWith(m)?e.slice(m.length):e,E=w.lastIndexOf("#"),S=E===-1?Number.NaN:Number(w.slice(E+1));return E===-1||!Number.isInteger(S)||S<0?{chunkIndex:0,sourceId:w}:{chunkIndex:S,sourceId:w.slice(0,E)}},Fe=async e=>Me(new TextEncoder().encode(e)),ze=(e,i)=>e.filter(m=>m.score>=i),oe=e=>{if(!e)return;const i=Object.entries(e).filter(([m])=>!Ke.has(m));return i.length>0?Object.fromEntries(i):void 0},se=new Set,Le=e=>{se.has(e)||(se.add(e),console.warn(`[@lunora/ai/rag] index "${e}" is used without a namespace — in a multi-tenant/sharded
|
|
2
2
|
app this shares one tenant's chunks (text included) with every other tenant, since
|
|
3
3
|
Vectorize indexes are account-global. Pass \`namespace\` (the shard/tenant key) on both
|
|
4
4
|
index() and retrieve(). Single-tenant apps suppress this via { allowSharedNamespace: true }.`))},Pe=e=>e.map(i=>`[source:${i.sourceId}#${String(i.chunkIndex)}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l=t=>/^[A-Z_]\w*$/i.test(t),h=t=>Array.from({length:t}).fill("?").join(", "),f=64,d=(t,e=64)=>{const n=Math.max(1,Math.floor(e)),s=[];for(let r=0;r<t.length;r+=n)s.push(t.slice(r,r+n));return s},g=(t,e)=>{if(!l(t))throw new TypeError(`@lunora/ai/rag: ${e} must be a bare SQL identifier (letters, digits, underscore; not starting with a digit) — got "${t}"`);return t},u=(t,e)=>{if(t.length!==e.length||t.length===0)return 0;let n=0,s=0,r=0;for(const[c,i]of t.entries()){const o=e[c];n+=i*o,s+=i*i,r+=o*o}const a=Math.sqrt(s)*Math.sqrt(r);return a===0?0:n/a},p=t=>{if(t!=null){if(typeof t=="string")try{return JSON.parse(t)}catch{return}return t}};export{f as I,g as a,u as c,d as i,h as p,p as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as x,c as U,b,a as F}from"./bm25-BT0cd0lY.mjs";import M from"./matchesMetadataFilter-BbIOyA5g.mjs";import{a as q,i as p,p as L,r as C,I as D}from"./sql-
|
|
1
|
+
import{t as x,c as U,b,a as F}from"./bm25-BT0cd0lY.mjs";import M from"./matchesMetadataFilter-BbIOyA5g.mjs";import{a as q,i as p,p as L,r as C,I as D}from"./sql-CNy5-Oop.mjs";const X="lunora_rag_lexical",_=null,I=m=>m??"",S=m=>{const s=typeof m=="number"?m:Number(m);return Number.isFinite(s)?s:0},K=m=>{if(typeof m.exec!="function")throw new TypeError("@lunora/ai/rag: sqlLexicalStore requires an `exec` function");const s=q(m.table??X,"sqlLexicalStore `table`"),f=`${s}_terms`,{exec:r}=m;let w;const h=async()=>{w??=(async()=>{await r(`CREATE TABLE IF NOT EXISTS ${s} (id TEXT NOT NULL, namespace TEXT NOT NULL DEFAULT '', text TEXT NOT NULL, length INTEGER NOT NULL, metadata TEXT, PRIMARY KEY (namespace, id))`,[]),await r(`CREATE TABLE IF NOT EXISTS ${f} (term TEXT NOT NULL, id TEXT NOT NULL, namespace TEXT NOT NULL DEFAULT '', frequency INTEGER NOT NULL, PRIMARY KEY (namespace, term, id))`,[]),await r(`CREATE INDEX IF NOT EXISTS ${f}_lookup ON ${f} (namespace, term)`,[]),await r(`CREATE INDEX IF NOT EXISTS ${s}_namespace ON ${s} (namespace)`,[])})().catch(c=>{throw w=void 0,c}),await w},A=async(c,n)=>{for(const o of p(c)){const i=L(o.length);await r(`DELETE FROM ${f} WHERE namespace = ? AND id IN (${i})`,[n,...o]),await r(`DELETE FROM ${s} WHERE namespace = ? AND id IN (${i})`,[n,...o])}},R=async(c,n,o)=>{const i=`(${L(n)})`;for(const E of p(o,D/n))await r(`${c} VALUES ${Array.from({length:E.length}).fill(i).join(", ")}`,E.flatMap(e=>[...e]))};return{index:async(c,n)=>{await h();const o=I(n.namespace);await A(c.map(e=>e.id),o);const i=[],E=[];for(const e of c){const N=F(e.text);if(N.length===0)continue;const d=new Map;for(const T of N)d.set(T,(d.get(T)??0)+1);i.push([e.id,o,e.text,N.length,e.metadata===void 0?_:JSON.stringify(e.metadata)]);for(const[T,l]of d)E.push([T,e.id,o,l])}await R(`INSERT INTO ${f} (term, id, namespace, frequency)`,4,E),await R(`INSERT INTO ${s} (id, namespace, text, length, metadata)`,5,i)},remove:async(c,n)=>{await h(),await A(c,I(n.namespace))},search:async(c,n)=>{await h();const o=I(n.namespace),i=x(c);if(i.length===0)return[];const[E]=await r(`SELECT COUNT(*) AS document_count, COALESCE(SUM(length), 0) AS total_length FROM ${s} WHERE namespace = ?`,[o]),e=S(E?.document_count);if(e===0)return[];const N=S(E?.total_length)/e,d=[];for(const t of p(i)){const a=await r(`SELECT t.term AS term, t.id AS id, t.frequency AS frequency, d.length AS length, d.metadata AS metadata FROM ${f} t JOIN ${s} d ON d.id = t.id AND d.namespace = t.namespace WHERE t.namespace = ? AND t.term IN (${L(t.length)})`,[o,...t]);d.push(...a)}const T=new Map;for(const t of d){const a=String(t.term);T.set(a,(T.get(a)??0)+1)}const l=new Map;for(const t of d){const a=C(t.metadata);if(!M(a,n.filter))continue;const u=String(t.id),y=U(e,T.get(String(t.term))??1),$=b(y,S(t.frequency),S(t.length),N);l.set(u,(l.get(u)??0)+$)}const g=[...l.entries()].toSorted(([,t],[,a])=>a-t).slice(0,n.topK);if(g.length===0)return[];const O=new Map;for(const t of p(g.map(([a])=>a))){const a=await r(`SELECT id, text FROM ${s} WHERE namespace = ? AND id IN (${L(t.length)})`,[o,...t]);for(const u of a)O.set(String(u.id),String(u.text))}return g.map(([t,a])=>({id:t,score:a,text:O.get(t)??""}))}}};export{K as sqlLexicalStore};
|
package/dist/packem_shared/{sqliteVectorStore-B4HiD_-t.mjs → sqliteVectorStore-DEqrp-Uc.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import g from"./matchesMetadataFilter-BbIOyA5g.mjs";import{a as v,p as f,r as h,c as L,i as S}from"./sql-
|
|
1
|
+
import g from"./matchesMetadataFilter-BbIOyA5g.mjs";import{a as v,p as f,r as h,c as L,i as S}from"./sql-CNy5-Oop.mjs";const N="lunora_rag_vectors",p=5e4,w=100,I=null,d=s=>s??"",R=s=>{if(typeof s.exec!="function")throw new TypeError("@lunora/ai/rag: sqliteVectorStore requires an `exec` function");const n=v(s.table??N,"sqliteVectorStore `table`"),E=s.maxScan??p,{exec:c}=s,y={maxDimensions:s.maxDimensions??!1,maxIdBytes:!1,maxMetadataBytes:!1,maxTopK:w,maxTopKWithMetadata:w};let T;const m=async()=>{T??=(async()=>{await c(`CREATE TABLE IF NOT EXISTS ${n} (id TEXT NOT NULL, namespace TEXT NOT NULL DEFAULT '', vector TEXT NOT NULL, metadata TEXT, PRIMARY KEY (namespace, id))`,[]),await c(`CREATE INDEX IF NOT EXISTS ${n}_namespace ON ${n} (namespace)`,[])})().catch(e=>{throw T=void 0,e}),await T};return{capabilities:y,deleteByIds:async(e,t)=>{if(await m(),e.length!==0)for(const a of S(e))await c(`DELETE FROM ${n} WHERE namespace = ? AND id IN (${f(a.length)})`,[d(t),...a])},getByIds:async(e,t)=>{if(await m(),e.length===0)return[];const a=[];for(const i of S(e)){const l=await c(`SELECT id, metadata FROM ${n} WHERE namespace = ? AND id IN (${f(i.length)})`,[d(t),...i]);for(const r of l){const o=h(r.metadata);a.push({id:String(r.id),...o===void 0?{}:{metadata:o}})}}return a},query:async e=>{await m();let t;if(e.embed&&e.input!==void 0)t=await e.embed(e.input);else throw new TypeError("@lunora/ai/rag: sqliteVectorStore query requires both `input` and `embed`");const a=await c(`SELECT id, vector, metadata FROM ${n} WHERE namespace = ? LIMIT ?`,[d(e.namespace),E+1]);if(a.length>E)throw new RangeError(`@lunora/ai/rag: sqliteVectorStore scanned ${String(a.length)} vectors in namespace "${d(e.namespace)}", over the ${String(E)} limit — search here is brute force and linear, so this namespace has outgrown it. Shard it further, or move this index to Vectorize or a pgvector backend`);const i=[];for(const r of a){const o=h(r.metadata);if(!g(o,e.filter))continue;const u=h(r.vector);u!==void 0&&i.push({id:String(r.id),score:L(t,u),...e.returnMetadata==="none"||o===void 0?{}:{metadata:o}})}const l=i.toSorted((r,o)=>o.score-r.score).slice(0,e.topK??10);return{count:l.length,matches:l}},upsert:async e=>{if(await m(),!e.embed)throw new TypeError("@lunora/ai/rag: sqliteVectorStore requires an `embed` function on upsert");const t=await e.embed(e.input);await c(`INSERT INTO ${n} (id, namespace, vector, metadata) VALUES (${f(4)}) ON CONFLICT(namespace, id) DO UPDATE SET vector = excluded.vector, metadata = excluded.metadata`,[e.id,d(e.namespace),JSON.stringify([...t]),e.metadata===void 0?I:JSON.stringify(e.metadata)])}}};export{R as sqliteVectorStore};
|
package/dist/rag/index.d.mts
CHANGED
|
@@ -1026,18 +1026,6 @@ interface RagSourceSync {
|
|
|
1026
1026
|
* @experimental
|
|
1027
1027
|
*/
|
|
1028
1028
|
declare const defineRagSource: (rag: Rag, options?: RagSourceOptions) => RagSourceSync;
|
|
1029
|
-
/**
|
|
1030
|
-
* The injected SQL seam the durable RAG stores share.
|
|
1031
|
-
*
|
|
1032
|
-
* `@lunora/ai` depends on no database. A store is handed an executor instead,
|
|
1033
|
-
* so the same adapter runs on a Durable Object's SQLite, D1, `node:sqlite`, or
|
|
1034
|
-
* Postgres over Hyperdrive — and this package stays free of every one of them.
|
|
1035
|
-
*
|
|
1036
|
-
* The statements the stores emit are SQLite-shaped (`ON CONFLICT … DO UPDATE`,
|
|
1037
|
-
* `CREATE INDEX IF NOT EXISTS`, `?` placeholders), so the executor must front a
|
|
1038
|
-
* SQLite engine — a Durable Object, D1, or `node:sqlite`.
|
|
1039
|
-
* @experimental
|
|
1040
|
-
*/
|
|
1041
1029
|
/**
|
|
1042
1030
|
* Run one statement and return its rows.
|
|
1043
1031
|
*
|
package/dist/rag/index.d.ts
CHANGED
|
@@ -1026,18 +1026,6 @@ interface RagSourceSync {
|
|
|
1026
1026
|
* @experimental
|
|
1027
1027
|
*/
|
|
1028
1028
|
declare const defineRagSource: (rag: Rag, options?: RagSourceOptions) => RagSourceSync;
|
|
1029
|
-
/**
|
|
1030
|
-
* The injected SQL seam the durable RAG stores share.
|
|
1031
|
-
*
|
|
1032
|
-
* `@lunora/ai` depends on no database. A store is handed an executor instead,
|
|
1033
|
-
* so the same adapter runs on a Durable Object's SQLite, D1, `node:sqlite`, or
|
|
1034
|
-
* Postgres over Hyperdrive — and this package stays free of every one of them.
|
|
1035
|
-
*
|
|
1036
|
-
* The statements the stores emit are SQLite-shaped (`ON CONFLICT … DO UPDATE`,
|
|
1037
|
-
* `CREATE INDEX IF NOT EXISTS`, `?` placeholders), so the executor must front a
|
|
1038
|
-
* SQLite engine — a Durable Object, D1, or `node:sqlite`.
|
|
1039
|
-
* @experimental
|
|
1040
|
-
*/
|
|
1041
1029
|
/**
|
|
1042
1030
|
* Run one statement and return its rows.
|
|
1043
1031
|
*
|
package/dist/rag/index.mjs
CHANGED
|
@@ -1 +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-CDME5gEs.mjs";import{default as x}from"../packem_shared/defineRag-
|
|
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-CDME5gEs.mjs";import{default as x}from"../packem_shared/defineRag-CMM17YeT.mjs";import{contentHash as p,guessMimeTypeFromExtension as i}from"../packem_shared/contentHash-BIn6ECP8.mjs";import{default as c}from"../packem_shared/hybridRank-DejmVw2I.mjs";import{default as l}from"../packem_shared/bm25LexicalStore-CALA7Lhm.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-qkTJHHzM.mjs";import{sqliteVectorStore as y}from"../packem_shared/sqliteVectorStore-DEqrp-Uc.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,l as bm25LexicalStore,p as contentHash,x as defineRag,E as defineRagSource,o as fixedWindowChunks,i as guessMimeTypeFromExtension,c 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 +0,0 @@
|
|
|
1
|
-
const r=/^(.*)-\d{4}-\d{2}-\d{2}$/u,a={"@cf/baai/bge-base-en-v1.5":{input:.067},"@cf/baai/bge-large-en-v1.5":{input:.204},"@cf/baai/bge-m3":{input:.012},"@cf/baai/bge-small-en-v1.5":{input:.02},"text-embedding-3-large":{input:.13},"text-embedding-3-small":{input:.02}},c=n=>{const t=n.trim(),e=t.lastIndexOf("/");return(e!==-1&&!t.startsWith("@")?[t,t.slice(e+1)]:[t]).flatMap(i=>{const o=r.exec(i)?.[1];return o===void 0?[i]:[i,o]})},b=(n,t=a)=>{for(const e of c(n))if(Object.hasOwn(t,e))return t[e]},d=(n,t,e)=>{if(n===void 0||n.length===0)return;const s=b(n,e);if(s===void 0)return;const i=Number.isFinite(t.inputTokens)?Math.max(0,t.inputTokens):0,o=Number.isFinite(t.outputTokens)?Math.max(0,t.outputTokens):0;if(i<=0&&o<=0)return;const u=(i*s.input+o*(s.output??0))/1e6;return Number.isFinite(u)?u:void 0};export{a as DEFAULT_MODEL_PRICES,d as estimateModelCost,b as lookupModelPrice};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const h=t=>Array.from({length:t}).fill("?").join(", "),f=64,d=(t,e=64)=>{const n=Math.max(1,Math.floor(e)),s=[];for(let r=0;r<t.length;r+=n)s.push(t.slice(r,r+n));return s},l=/^[A-Z_]\w*$/i,g=(t,e)=>{if(!l.test(t))throw new TypeError(`@lunora/ai/rag: ${e} must be a bare SQL identifier (letters, digits, underscore; not starting with a digit) — got "${t}"`);return t},u=(t,e)=>{if(t.length!==e.length||t.length===0)return 0;let n=0,s=0,r=0;for(const[c,o]of t.entries()){const i=e[c];n+=o*i,s+=o*o,r+=i*i}const a=Math.sqrt(s)*Math.sqrt(r);return a===0?0:n/a},I=t=>{if(t!=null){if(typeof t=="string")try{return JSON.parse(t)}catch{return}return t}};export{f as I,g as a,u as c,d as i,h as p,I as r};
|