@absolutejs/rag 0.1.2 → 0.2.0

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.
@@ -1,6 +1,7 @@
1
1
  export { ragChat, ragChat as ragPlugin } from "./chat/chat";
2
2
  export { createRAGHTMXConfig, createRAGHTMXWorkflowRenderConfig, } from "./presentation/htmxConfig";
3
3
  export { createRAGEmbeddingProvider, resolveRAGEmbeddingProvider, validateRAGEmbeddingDimensions, } from "./retrieval/embedding";
4
+ export { embeddingCacheKey, isEmbeddingQuotaError, withEmbeddingBudget, type RAGBudgetedEmbedding, type RAGEmbeddingCache, type RAGEmbeddingHealth, type WithEmbeddingBudgetOptions, } from "./retrieval/embeddingBudget";
4
5
  export { applyRAGReranking, createHeuristicRAGReranker, createRAGReranker, resolveRAGReranker, } from "./retrieval/reranking";
5
6
  export { createCohereRAGReranker, createJinaRAGReranker, createVoyageRAGReranker, } from "./providers/rerankerProviders";
6
7
  export { applyRAGQueryTransform, createHeuristicRAGQueryTransform, createRAGQueryTransform, resolveRAGQueryTransform, } from "./retrieval/queryTransforms";
@@ -0,0 +1,36 @@
1
+ import type { RAGEmbeddingFunction, RAGEmbeddingProvider } from "../../types/engine";
2
+ /** Persistence for embedding reuse. The host owns storage (Postgres, Redis,
3
+ * an LRU) — this package only decides WHAT to remember and when to skip. */
4
+ export type RAGEmbeddingCache = {
5
+ /** Previously embedded vector for this exact text, if any. */
6
+ get: (key: string) => Promise<number[] | null> | number[] | null;
7
+ set: (key: string, embedding: number[]) => Promise<void> | void;
8
+ };
9
+ /** Stable cache key for a piece of text under one model + input type. A
10
+ * passage and a query embed differently, so they must not share an entry. */
11
+ export declare const embeddingCacheKey: (text: string, model?: string, kind?: string) => Promise<string>;
12
+ /** Whether a provider error means "you are out of embedding allowance",
13
+ * as opposed to a transient failure worth retrying. */
14
+ export declare const isEmbeddingQuotaError: (error: unknown) => boolean;
15
+ export type RAGEmbeddingHealth = {
16
+ /** Last error message seen, cleared by the next success. */
17
+ lastError: string | null;
18
+ /** When the provider last said the allowance is spent. */
19
+ quotaExhaustedAt: Date | null;
20
+ /** Embeddings served from cache since process start. */
21
+ reused: number;
22
+ /** Embeddings actually paid for since process start. */
23
+ embedded: number;
24
+ };
25
+ export type RAGBudgetedEmbedding = RAGEmbeddingProvider & {
26
+ health: () => RAGEmbeddingHealth;
27
+ };
28
+ export type WithEmbeddingBudgetOptions = {
29
+ cache?: RAGEmbeddingCache;
30
+ /** Notified the first time the allowance is reported spent — wire this to
31
+ * an alert, because a degraded index is otherwise invisible. */
32
+ onQuotaExhausted?: (error: unknown) => void;
33
+ };
34
+ /** Wrap an embedding function so repeated text is not re-embedded and quota
35
+ * exhaustion is observable instead of silent. */
36
+ export declare const withEmbeddingBudget: (provider: RAGEmbeddingProvider | RAGEmbeddingFunction, options?: WithEmbeddingBudgetOptions) => RAGBudgetedEmbedding;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/rag",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "homepage": "https://github.com/absolutejs/rag",
5
5
  "bugs": {
6
6
  "url": "https://github.com/absolutejs/rag/issues"
@@ -197,7 +197,7 @@
197
197
  "lint": "eslint . --max-warnings 0",
198
198
  "format": "prettier --write .",
199
199
  "test": "bun test",
200
- "release": "bun publish --access public"
200
+ "release": "bun run build && bun publish --access public"
201
201
  },
202
202
  "publishConfig": {
203
203
  "access": "public"