murmur-rag 1.1.0 → 1.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.
Files changed (29) hide show
  1. package/README.md +17 -17
  2. package/dist/cdn/{anthropic-dc7h9prc.js → anthropic-ynz7717b.js} +2 -2
  3. package/dist/cdn/{embed-acjpjh6t.js → embed-0m8xctqy.js} +1 -1
  4. package/dist/cdn/{embed-ssqsb38w.js → embed-7pk91zq8.js} +2 -2
  5. package/dist/cdn/embed-dbkjhg16.js +83 -0
  6. package/dist/cdn/{embed-z32y952f.js → embed-n5nzhrf2.js} +3 -3
  7. package/dist/cdn/{embed-6gef7ym5.js → embed-rp9gb1qq.js} +2 -2
  8. package/dist/cdn/{embed-fd96s8qk.js → embed-xtkxyrpe.js} +9 -9
  9. package/dist/cdn/{google-yywkqdph.js → google-k5kwa54v.js} +8 -8
  10. package/dist/cdn/{index-jt6n0d28.js → index-db4ne93m.js} +1 -1
  11. package/dist/cdn/{index-nesgnf2n.js → index-qc8kgsdt.js} +1 -1
  12. package/dist/cdn/{index-bq0x71h1.js → index-t0qn2m4r.js} +1 -1
  13. package/dist/cdn/index-y0faj89r.js +1 -0
  14. package/dist/cdn/mistral-p2qcnn42.js +3 -0
  15. package/dist/cdn/{murmur-j1ky5vmr.js → murmur-d6t6cjc7.js} +2 -2
  16. package/dist/cdn/murmur.js +6 -6
  17. package/dist/cdn/{openai-compatible-zhaj1r43.js → openai-compatible-psnkrpxy.js} +6 -6
  18. package/dist/cdn/{openai-g1685z9v.js → openai-d3q1d6cz.js} +10 -10
  19. package/dist/cdn/retriever-6qvn2maq.js +1 -0
  20. package/dist/cdn/{transformers.web-3kmbvcbt.js → transformers.web-xn16v7pz.js} +5 -5
  21. package/dist/lib/chunks/{index-92w507gk.js → index-y3v46yjp.js} +44 -34
  22. package/dist/lib/embed.js +4 -4
  23. package/dist/lib/widget/index.js +2 -2
  24. package/dist/types/widget/session.d.ts +16 -4
  25. package/package.json +1 -1
  26. package/dist/cdn/embed-jdraznwg.js +0 -83
  27. package/dist/cdn/index-wgzgvzaf.js +0 -1
  28. package/dist/cdn/mistral-0mg4kk7s.js +0 -3
  29. package/dist/cdn/retriever-dqxzjaqk.js +0 -1
@@ -394,9 +394,22 @@ class ChatSession {
394
394
  get mode() {
395
395
  if (this.options.model)
396
396
  return "custom";
397
- if (this.options.local || this.visitorChoseLocal)
398
- return "local";
399
- return this.options.llm?.endpoint ? "proxy" : "visitor";
397
+ if (this.options.llm?.endpoint)
398
+ return "proxy";
399
+ if (!this.localAllowed)
400
+ return "visitor";
401
+ return readLocal(`${this.key}-local`) === "0" ? "visitor" : "local";
402
+ }
403
+ get localAllowed() {
404
+ return !this.options.model && !this.options.llm?.endpoint && this.options.local !== false;
405
+ }
406
+ async settleChoice() {
407
+ if (!this.localAllowed || readLocal(`${this.key}-local`) !== null)
408
+ return;
409
+ const [{ isConfigured }, store] = await Promise.all([(__preload("vb9smwta"), import("../llm/index.js")), this.store()]);
410
+ const saved = await store.load();
411
+ if (saved && isConfigured(saved))
412
+ writeLocal(`${this.key}-local`, "0");
400
413
  }
401
414
  async localSpec() {
402
415
  const { local } = this.options;
@@ -404,11 +417,8 @@ class ChatSession {
404
417
  return local;
405
418
  return (await (__preload("nb4hdy2t"), import("../local/index.js"))).DEFAULT_LOCAL_MODEL;
406
419
  }
407
- get visitorChoseLocal() {
408
- return readLocal(`${this.key}-local`) === "1";
409
- }
410
420
  useLocal(on) {
411
- writeLocal(`${this.key}-local`, on ? "1" : null);
421
+ writeLocal(`${this.key}-local`, on ? "1" : "0");
412
422
  this.engine = null;
413
423
  }
414
424
  get needsDownloadConsent() {
@@ -918,7 +928,7 @@ class MurmurChat2 extends Base {
918
928
  this.input.focus();
919
929
  });
920
930
  this.settingsBtn = iconButton(doc, "settings", this.t.settings);
921
- this.settingsBtn.hidden = !!o.model || !!o.llm?.endpoint || !!o.local;
931
+ this.settingsBtn.hidden = !!o.model || !!o.llm?.endpoint;
922
932
  this.settingsBtn.addEventListener("click", () => void this.showSetup());
923
933
  const closeBtn = iconButton(doc, "close", this.t.close);
924
934
  closeBtn.hidden = this.hasAttribute("inline");
@@ -1086,6 +1096,7 @@ class MurmurChat2 extends Base {
1086
1096
  const question = this.input.value.trim();
1087
1097
  if (!question || this.controller || !this.session)
1088
1098
  return;
1099
+ await this.session.settleChoice();
1089
1100
  if (this.session.needsDownloadConsent) {
1090
1101
  await this.showConsent(question);
1091
1102
  return;
@@ -1156,7 +1167,6 @@ class MurmurChat2 extends Base {
1156
1167
  const spec = await session.localSpec();
1157
1168
  const card = el(doc, "div", { class: "msg bot consent" });
1158
1169
  const row = el(doc, "div", { class: "row" });
1159
- const ownerLocal = !!this.options.local;
1160
1170
  const useKey = () => {
1161
1171
  card.remove();
1162
1172
  session.useLocal(false);
@@ -1164,12 +1174,10 @@ class MurmurChat2 extends Base {
1164
1174
  };
1165
1175
  if (!await session.canRunLocally()) {
1166
1176
  card.append(text(doc, "p", t.localNoWebGPU));
1167
- if (!ownerLocal) {
1168
- const key = el(doc, "button", { class: "text-btn", type: "button" });
1169
- key.textContent = t.useKey;
1170
- key.addEventListener("click", useKey);
1171
- row.append(key);
1172
- }
1177
+ const key = el(doc, "button", { class: "primary", type: "button" });
1178
+ key.textContent = t.useKey;
1179
+ key.addEventListener("click", useKey);
1180
+ row.append(key);
1173
1181
  } else {
1174
1182
  card.append(text(doc, "p", t.localConsent.replace("{name}", spec.name).replace("{size}", size(spec.sizeMB, this.uiLang, t))));
1175
1183
  const go = el(doc, "button", { class: "primary", type: "button" });
@@ -1181,12 +1189,10 @@ class MurmurChat2 extends Base {
1181
1189
  this.submit();
1182
1190
  });
1183
1191
  row.append(go);
1184
- if (!ownerLocal) {
1185
- const key = el(doc, "button", { class: "link-btn", type: "button" });
1186
- key.textContent = t.useKey;
1187
- key.addEventListener("click", useKey);
1188
- row.append(key);
1189
- }
1192
+ const key = el(doc, "button", { class: "link-btn", type: "button" });
1193
+ key.textContent = t.useKey;
1194
+ key.addEventListener("click", useKey);
1195
+ row.append(key);
1190
1196
  }
1191
1197
  card.append(row);
1192
1198
  this.log.append(card);
@@ -1224,25 +1230,29 @@ class MurmurChat2 extends Base {
1224
1230
  this.submit();
1225
1231
  }
1226
1232
  });
1227
- session.canRunLocally().then((ok) => {
1228
- localBtn.disabled = !ok;
1229
- if (!ok)
1230
- localHint.textContent = t.localNoWebGPU;
1233
+ const switchToKey = el(doc, "button", { class: "link-btn", type: "button" });
1234
+ switchToKey.textContent = t.useKey;
1235
+ switchToKey.addEventListener("click", () => {
1236
+ session.useLocal(false);
1237
+ localBtn.textContent = t.localOption;
1238
+ localBtn.disabled = false;
1239
+ switchToKey.remove();
1231
1240
  });
1232
1241
  if (session.mode === "local") {
1233
1242
  localBtn.textContent = t.localActive;
1234
1243
  localBtn.disabled = true;
1235
- const back = el(doc, "button", { class: "link-btn", type: "button" });
1236
- back.textContent = t.useKey;
1237
- back.addEventListener("click", () => {
1238
- session.useLocal(false);
1239
- localBtn.textContent = t.localOption;
1240
- localBtn.disabled = false;
1241
- back.remove();
1242
- });
1243
- inBrowser.append(back);
1244
+ inBrowser.append(switchToKey);
1244
1245
  }
1246
+ session.canRunLocally().then((ok) => {
1247
+ if (ok)
1248
+ return;
1249
+ localBtn.textContent = t.localOption;
1250
+ localBtn.disabled = true;
1251
+ localHint.textContent = t.localNoWebGPU;
1252
+ switchToKey.remove();
1253
+ });
1245
1254
  const or = text(doc, "p", t.orKey, "or");
1255
+ inBrowser.hidden = or.hidden = !session.localAllowed;
1246
1256
  const local = checkbox(doc, t.local);
1247
1257
  const providerField = field(doc, t.provider, el(doc, "select"));
1248
1258
  const providerSelect = providerField.control;
package/dist/lib/embed.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  __chunks,
3
3
  mountMurmur2
4
- } from "./chunks/index-92w507gk.js";
5
- __chunks(import.meta.url,["rv6357f7","92w507gk","t36hd4vt","wxshtnm0","dj4321kh","vb9smwta","nb4hdy2t","kaeec41p","b77xqap3","8h9c8ekq","p86sy3y4","1zk822m5"],[["./embed.js",1],["./chunks/index-92w507gk.js",8],["./chunks/murmur-t36hd4vt.js",9,10],["./chunks/retriever-wxshtnm0.js",10],["./indexer/index.js",11],["./llm/index.js"],["./local/index.js"],["./chunks/chunk-kaeec41p.js",11],["./chunks/index-b77xqap3.js"],["./chunks/index-8h9c8ekq.js",10,8],["./chunks/index-p86sy3y4.js",8],["./chunks/index-1zk822m5.js"]],0);
4
+ } from "./chunks/index-y3v46yjp.js";
5
+ __chunks(import.meta.url,["jc4f9310","y3v46yjp","t36hd4vt","wxshtnm0","dj4321kh","vb9smwta","nb4hdy2t","kaeec41p","b77xqap3","8h9c8ekq","p86sy3y4","1zk822m5"],[["./embed.js",1],["./chunks/index-y3v46yjp.js",8],["./chunks/murmur-t36hd4vt.js",9,10],["./chunks/retriever-wxshtnm0.js",10],["./indexer/index.js",11],["./llm/index.js"],["./local/index.js"],["./chunks/chunk-kaeec41p.js",11],["./chunks/index-b77xqap3.js"],["./chunks/index-8h9c8ekq.js",10,8],["./chunks/index-p86sy3y4.js",8],["./chunks/index-1zk822m5.js"]],0);
6
6
 
7
7
  // src/embed.ts
8
8
  function optionsFromDataset(data, base) {
@@ -45,8 +45,8 @@ function optionsFromDataset(data, base) {
45
45
  o.storageKey = data.storageKey;
46
46
  if (data.open === "true")
47
47
  o.open = true;
48
- if (data.local === "true")
49
- o.local = true;
48
+ if (data.local === "false")
49
+ o.local = false;
50
50
  return o;
51
51
  }
52
52
  function start() {
@@ -8,8 +8,8 @@ import {
8
8
  MurmurChat2,
9
9
  defineMurmurChat2,
10
10
  mountMurmur2
11
- } from "../chunks/index-92w507gk.js";
12
- __chunks(import.meta.url,["f9340r29","92w507gk","t36hd4vt","wxshtnm0","dj4321kh","vb9smwta","nb4hdy2t","kaeec41p","b77xqap3","8h9c8ekq","p86sy3y4","1zk822m5"],[["./index.js",1],["../chunks/index-92w507gk.js",8],["../chunks/murmur-t36hd4vt.js",9,10],["../chunks/retriever-wxshtnm0.js",10],["../indexer/index.js",11],["../llm/index.js"],["../local/index.js"],["../chunks/chunk-kaeec41p.js",11],["../chunks/index-b77xqap3.js"],["../chunks/index-8h9c8ekq.js",10,8],["../chunks/index-p86sy3y4.js",8],["../chunks/index-1zk822m5.js"]],0);
11
+ } from "../chunks/index-y3v46yjp.js";
12
+ __chunks(import.meta.url,["jzqx319b","y3v46yjp","t36hd4vt","wxshtnm0","dj4321kh","vb9smwta","nb4hdy2t","kaeec41p","b77xqap3","8h9c8ekq","p86sy3y4","1zk822m5"],[["./index.js",1],["../chunks/index-y3v46yjp.js",8],["../chunks/murmur-t36hd4vt.js",9,10],["../chunks/retriever-wxshtnm0.js",10],["../indexer/index.js",11],["../llm/index.js"],["../local/index.js"],["../chunks/chunk-kaeec41p.js",11],["../chunks/index-b77xqap3.js"],["../chunks/index-8h9c8ekq.js",10,8],["../chunks/index-p86sy3y4.js",8],["../chunks/index-1zk822m5.js"]],0);
13
13
  export {
14
14
  MESSAGES2 as MESSAGES,
15
15
  MurmurChat2 as MurmurChat,
@@ -31,8 +31,10 @@ export interface WidgetOptions {
31
31
  /** Open the panel on load. */
32
32
  open?: boolean;
33
33
  /**
34
- * Answer with a model that runs in the visitor's browser on WebGPU: `true` for the default
35
- * (LFM3 1.7B, about 1.1 GB, downloaded once after the visitor agrees), or your own spec.
34
+ * The model that runs in the visitor's browser on WebGPU, the default way to answer when there
35
+ * is no proxy: LFM3 1.7B, about 1.1 GB downloaded once after the visitor agrees. Visitors can
36
+ * still connect their own key in the AI settings. Pass your own spec to run another model, or
37
+ * `false` to offer only the visitor's key.
36
38
  */
37
39
  local?: boolean | LocalModelSpec;
38
40
  }
@@ -53,11 +55,21 @@ export declare class ChatSession {
53
55
  /** Called while the in-browser model downloads. */
54
56
  onProgress: ((progress: LoadProgress) => void) | null;
55
57
  constructor(options: WidgetOptions);
58
+ /**
59
+ * How this session answers: your own model, then the owner's proxy, then the visitor's own
60
+ * key if they chose one, else the model in the browser.
61
+ */
56
62
  get mode(): Mode;
63
+ /** Whether the in-browser model is offered: not with your own model or a proxy, nor `local: false`. */
64
+ get localAllowed(): boolean;
65
+ /**
66
+ * Before a question: a visitor who saved a key before the in-browser model became the default,
67
+ * and never chose between the two, keeps their key.
68
+ */
69
+ settleChoice(): Promise<void>;
57
70
  /** The in-browser model this session would run. */
58
71
  localSpec(): Promise<LocalModelSpec>;
59
- private get visitorChoseLocal();
60
- /** The visitor picks the in-browser model (or goes back to a key). */
72
+ /** The visitor picks the in-browser model, or their own key. */
61
73
  useLocal(on: boolean): void;
62
74
  /** Whether the visitor must still agree to download the in-browser model. */
63
75
  get needsDownloadConsent(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "murmur-rag",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Embeddable AI chat for static sites: one script tag, a mini RAG over your own pages, any LLM through llm-connect (your proxy or the visitor's own key). No backend.",
5
5
  "author": "maxgfr",
6
6
  "license": "MIT",