@yuktishaalaa/yuktai 5.3.7 → 5.3.8

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 CHANGED
@@ -46,6 +46,44 @@ Six modules ship in a single npm package, for React/Next.js and, since v5.3, for
46
46
 
47
47
  ---
48
48
 
49
+ ## What's new in v5.3.8: Rust RAG for "Ask page" (optional)
50
+
51
+ The page + data search behind **Ask page** (`createContextIndex`, used after `askAboutPage`) can now run in **Rust**. Same passages, same BM25 scores (bit for bit), same answers: only faster. Free, offline, and it works in PWAs: the engine (about 33 KB of WebAssembly) is embedded in the package.
52
+
53
+ ```tsx
54
+ <AgenticPanel engine="rust" /> // React / Next.js: Ask page tab
55
+ ```
56
+
57
+ ```js
58
+ yuktai.mountAgenticPanel("#tools", { engine: "rust" }) // plain HTML
59
+ const index = yuktai.createContextIndex({ rows, columns, engine: "rust" })
60
+ await index.ask("Which office handles leave requests?")
61
+ ```
62
+
63
+ | `engine` | What runs |
64
+ |---|---|
65
+ | `"ts"` (default) | TypeScript, unchanged |
66
+ | `"rust"` | Rust inverted index for every search |
67
+ | `"auto"` | Rust from 1,000 passages |
68
+
69
+ - **How it is faster:** TypeScript scans every word of every passage for each question. Rust builds an inverted index once and jumps straight to the passages that contain the question's words (and their longer/shorter forms, as before).
70
+ - **Same results, tested:** TypeScript still tokenizes (Telugu-aware) and computes `idf` with `Math.log`; Rust does the counting and the BM25 arithmetic in the same order, so scores match bit for bit. Tests compare both engines on English and Telugu documents, grid rows and real page text (1,000+ searches).
71
+ - **Measured** (Node 22, median, per question):
72
+
73
+ | Content | TypeScript | Rust | Speed-up |
74
+ |---|---|---|---|
75
+ | Long page, 500 passages | 2.3 ms | 0.08 ms | 27× |
76
+ | Help docs, 5,000 passages | 18.8 ms | 0.45 ms | 42× |
77
+ | Grid, 1,00,000 rows | 46.2 ms | 3.4 ms | 14× |
78
+
79
+ Rust builds its index once per content change (240 ms for 1 lakh rows); every question after that is fast.
80
+ - **Also faster for everyone (both engines):** asking again on an unchanged page no longer rebuilds the index (6 ms instead of 183 ms for 5,000 passages). The React Ask tab now reuses its index between questions, like the vanilla panel.
81
+ - **PWA:** the demo's service worker cache is now `yuktai-vanilla-v5.3.8`, so installed apps pick up the new engine.
82
+
83
+ Source: [`rust/rag-core`](./rust/rag-core) (no dependencies, `no_std` + `alloc`). Rust tests: `npm run test:rust`.
84
+
85
+ ---
86
+
49
87
  ## What's new in v5.3.5: Rust grid engine (optional)
50
88
 
51
89
  The grid's existing search and number/date sorting can now run in **Rust**, compiled to WebAssembly. Nothing else changes: same rows, same order, same API. The default is still TypeScript, so existing apps behave exactly as before.
package/dist/index.d.mts CHANGED
@@ -1094,6 +1094,12 @@ interface ContextIndexOptions<T = Record<string, unknown>> {
1094
1094
  id: string;
1095
1095
  text: string;
1096
1096
  }>;
1097
+ /**
1098
+ * Search engine: "ts" (default), "rust" (always) or "auto" (Rust from 1,000
1099
+ * passages). Same passages, same scores, same order; Rust is faster on long
1100
+ * pages and big grids. Works offline (the engine is embedded).
1101
+ */
1102
+ engine?: GridEngine;
1097
1103
  }
1098
1104
  declare function createContextIndex<T>(options?: ContextIndexOptions<T>): {
1099
1105
  search: (question: string, k?: number) => ContextHit[];
@@ -1105,6 +1111,10 @@ declare function createContextIndex<T>(options?: ContextIndexOptions<T>): {
1105
1111
  rebuild: () => void;
1106
1112
  update(next: Partial<ContextIndexOptions<T>>): void;
1107
1113
  size: () => number;
1114
+ /** "rust" when the Rust engine answers searches for this index, else "ts". */
1115
+ readonly engine: "rust" | "ts";
1116
+ /** Resolves "rust" or "ts" once the engine is loaded (or not wanted). */
1117
+ whenEngineReady: () => Promise<"ts" | "rust">;
1108
1118
  };
1109
1119
 
1110
1120
  type TaskAction = "filter" | "highlight" | "sort" | "clear" | "count" | "summarize" | "anomalies" | "open" | "select";
@@ -1271,9 +1281,11 @@ interface AgenticPanelProps {
1271
1281
  voiceLang?: string;
1272
1282
  /** Optional model hook for Ask page, e.g. Gemini Nano or your own API. */
1273
1283
  generate?: (question: string, context: string) => Promise<string>;
1284
+ /** Ask page search engine: "ts" (default), "rust" or "auto". Same answers; Rust is faster on long pages. */
1285
+ engine?: GridEngine;
1274
1286
  style?: CSSProperties;
1275
1287
  }
1276
- declare function AgenticPanel({ defaultTab, voiceLang, generate, style }: AgenticPanelProps): react.JSX.Element;
1288
+ declare function AgenticPanel({ defaultTab, voiceLang, generate, engine, style }: AgenticPanelProps): react.JSX.Element;
1277
1289
 
1278
1290
  declare global {
1279
1291
  var __yuktai_runtime__: Runtime | undefined;
package/dist/index.d.ts CHANGED
@@ -1094,6 +1094,12 @@ interface ContextIndexOptions<T = Record<string, unknown>> {
1094
1094
  id: string;
1095
1095
  text: string;
1096
1096
  }>;
1097
+ /**
1098
+ * Search engine: "ts" (default), "rust" (always) or "auto" (Rust from 1,000
1099
+ * passages). Same passages, same scores, same order; Rust is faster on long
1100
+ * pages and big grids. Works offline (the engine is embedded).
1101
+ */
1102
+ engine?: GridEngine;
1097
1103
  }
1098
1104
  declare function createContextIndex<T>(options?: ContextIndexOptions<T>): {
1099
1105
  search: (question: string, k?: number) => ContextHit[];
@@ -1105,6 +1111,10 @@ declare function createContextIndex<T>(options?: ContextIndexOptions<T>): {
1105
1111
  rebuild: () => void;
1106
1112
  update(next: Partial<ContextIndexOptions<T>>): void;
1107
1113
  size: () => number;
1114
+ /** "rust" when the Rust engine answers searches for this index, else "ts". */
1115
+ readonly engine: "rust" | "ts";
1116
+ /** Resolves "rust" or "ts" once the engine is loaded (or not wanted). */
1117
+ whenEngineReady: () => Promise<"ts" | "rust">;
1108
1118
  };
1109
1119
 
1110
1120
  type TaskAction = "filter" | "highlight" | "sort" | "clear" | "count" | "summarize" | "anomalies" | "open" | "select";
@@ -1271,9 +1281,11 @@ interface AgenticPanelProps {
1271
1281
  voiceLang?: string;
1272
1282
  /** Optional model hook for Ask page, e.g. Gemini Nano or your own API. */
1273
1283
  generate?: (question: string, context: string) => Promise<string>;
1284
+ /** Ask page search engine: "ts" (default), "rust" or "auto". Same answers; Rust is faster on long pages. */
1285
+ engine?: GridEngine;
1274
1286
  style?: CSSProperties;
1275
1287
  }
1276
- declare function AgenticPanel({ defaultTab, voiceLang, generate, style }: AgenticPanelProps): react.JSX.Element;
1288
+ declare function AgenticPanel({ defaultTab, voiceLang, generate, engine, style }: AgenticPanelProps): react.JSX.Element;
1277
1289
 
1278
1290
  declare global {
1279
1291
  var __yuktai_runtime__: Runtime | undefined;