NakliTechie commited on
Commit
ce97c67
Β·
1 Parent(s): c29e90f

Sync from GitHub 2026-10-29T03:26:15Z

Browse files
Files changed (1) hide show
  1. index.html +36 -5
index.html CHANGED
@@ -2845,7 +2845,7 @@
2845
  Ask before running custom and MCP tools <span style="font-weight:400;color:var(--gray-500)">(they send the model's arguments to another server; also asks before weather and Wikipedia lookups)</span>
2846
  </label>
2847
  <label class="toggle-row" id="keylessWebRow">
2848
- <input type="checkbox" id="keylessWebToggle">
2849
  Keyless web tools: weather and Wikipedia <span style="font-weight:400;color:var(--gray-500)">(agent-capable models; sends the place name to open-meteo.com or the topic to wikipedia.org, no key or account)</span>
2850
  </label>
2851
  <label class="toggle-row" id="pageProxyRow">
@@ -9080,6 +9080,7 @@ self.addEventListener('message', async (e) => {
9080
  },
9081
  'lfm3-1.7b': {
9082
  id: 'LiquidAI/LFM3-1.7B-ONNX',
 
9083
  label: 'LFM3 1.7B',
9084
  dtype: 'q4f16',
9085
  size: '~1.4 GB',
@@ -10309,7 +10310,9 @@ self.addEventListener('message', async (e) => {
10309
  // Keyless web tools send the place name or query to a public API, so they stay off until the user turns them on
10310
  // (Settings β†’ Tools), and each still asks on its first use per session through the approval card.
10311
  const KEYLESS_WEB_KEY = 'lm_keyless_web';
10312
- function keylessWebOn() { try { return localStorage.getItem(KEYLESS_WEB_KEY) === 'on'; } catch { return false; } }
 
 
10313
  async function fetchToolJson(url) {
10314
  const res = await fetch(url, { signal: AbortSignal.timeout(15000) });
10315
  if (!res.ok) throw new Error('HTTP ' + res.status + ' from ' + new URL(url).host);
@@ -10453,6 +10456,19 @@ self.addEventListener('message', async (e) => {
10453
  // tools array from TOOL_REGISTRY. Stays outside the adapter β€” the
10454
  // adapter receives an explicit tools[] array per call and never
10455
  // sees TOOL_REGISTRY directly.
 
 
 
 
 
 
 
 
 
 
 
 
 
10456
  function buildToolsForRuntime() {
10457
  const webConfigured = isSearchConfigured();
10458
  const caps = LocalMind.runtime.capabilities();
@@ -16728,6 +16744,12 @@ self.addEventListener('message', async (e) => {
16728
  // template renders as <tool_response>. Endpoints (incl. a router escalation) keep the JSON prompt.
16729
  const nativeXmlTools = !!(activeModel && activeModel.toolFormat === 'qwen3-xml')
16730
  && !(LocalMind.runtime.isEndpoint && LocalMind.runtime.isEndpoint());
 
 
 
 
 
 
16731
 
16732
  const iter = makeAsyncIterator();
16733
  let completionTokens = 0;
@@ -16801,7 +16823,7 @@ self.addEventListener('message', async (e) => {
16801
  content = String(content == null ? '' : content);
16802
  }
16803
  if (m.role === 'tool') {
16804
- if (nativeXmlTools) return { role: 'tool', name: m.name || 'tool', content };
16805
  const toolPayload = (() => {
16806
  try { return JSON.parse(content); } catch { return content; }
16807
  })();
@@ -16824,8 +16846,15 @@ self.addEventListener('message', async (e) => {
16824
  userSysContent = typeof c === 'string' ? c : '';
16825
  chatMessages = chatMessages.slice(1);
16826
  }
16827
- const toolSys = nativeXmlTools ? _adapterBuildQwenXmlToolPrompt(tools, userSysContent) : _adapterBuildToolPrompt(tools, userSysContent);
16828
- chatMessages = [{ role: 'system', content: toolSys }].concat(chatMessages);
 
 
 
 
 
 
 
16829
  }
16830
  } catch (e) {
16831
  const err = e instanceof Error ? e : new Error(String(e));
@@ -18379,6 +18408,7 @@ async function generateCausal(chatMessages, id, genConfig, enableThinking) {
18379
  add_generation_prompt: true,
18380
  return_dict: true,
18381
  enable_thinking: thinking,
 
18382
  });
18383
  } catch (tplErr) {
18384
  // The pinned transformers.js jinja can't parse some real templates β€” e.g.
@@ -18402,6 +18432,7 @@ async function generateCausal(chatMessages, id, genConfig, enableThinking) {
18402
  add_generation_prompt: true,
18403
  return_dict: true,
18404
  enable_thinking: thinking,
 
18405
  chat_template: raw,
18406
  });
18407
  salvaged = true;
 
2845
  Ask before running custom and MCP tools <span style="font-weight:400;color:var(--gray-500)">(they send the model's arguments to another server; also asks before weather and Wikipedia lookups)</span>
2846
  </label>
2847
  <label class="toggle-row" id="keylessWebRow">
2848
+ <input type="checkbox" id="keylessWebToggle" checked>
2849
  Keyless web tools: weather and Wikipedia <span style="font-weight:400;color:var(--gray-500)">(agent-capable models; sends the place name to open-meteo.com or the topic to wikipedia.org, no key or account)</span>
2850
  </label>
2851
  <label class="toggle-row" id="pageProxyRow">
 
9080
  },
9081
  'lfm3-1.7b': {
9082
  id: 'LiquidAI/LFM3-1.7B-ONNX',
9083
+ toolFormat: 'template',
9084
  label: 'LFM3 1.7B',
9085
  dtype: 'q4f16',
9086
  size: '~1.4 GB',
 
10310
  // Keyless web tools send the place name or query to a public API, so they stay off until the user turns them on
10311
  // (Settings β†’ Tools), and each still asks on its first use per session through the approval card.
10312
  const KEYLESS_WEB_KEY = 'lm_keyless_web';
10313
+ // On by default (Chirag, 2026-10-29: "keyless web tools should be on by default"); each lookup still asks first
10314
+ // through the approval card (approvalHost), and switching the setting off hides both tools.
10315
+ function keylessWebOn() { try { return localStorage.getItem(KEYLESS_WEB_KEY) !== 'off'; } catch { return true; } }
10316
  async function fetchToolJson(url) {
10317
  const res = await fetch(url, { signal: AbortSignal.timeout(15000) });
10318
  if (!res.ok) throw new Error('HTTP ' + res.status + ' from ' + new URL(url).host);
 
10456
  // tools array from TOOL_REGISTRY. Stays outside the adapter β€” the
10457
  // adapter receives an explicit tools[] array per call and never
10458
  // sees TOOL_REGISTRY directly.
10459
+ // A built-in tool the user has switched off is missing from the tool list, so a model told nothing says it "has
10460
+ // no access to weather" (MiniCPM-V 4.7 and LFM3, 2026-10-28). Name the switched-off tools and the setting, so the
10461
+ // reply points at it. Only when the list holds the app's own tools and lacks the switched-off ones.
10462
+ function toolsSwitchedOffHint(tools) {
10463
+ if (keylessWebOn()) return '';
10464
+ const names = new Set((tools || []).map((t) => t && t.name));
10465
+ if (![...names].some((n) => TOOL_REGISTRY[n])) return '';
10466
+ // Plain words, no tool names: a small model given a name tends to call it, and the parser drops unknown names.
10467
+ const off = Object.entries(TOOL_REGISTRY).some(([n, t]) => t.requiresKeylessWeb && !names.has(n));
10468
+ if (!off) return '';
10469
+ return 'Live weather and Wikipedia lookups are switched off in Settings β†’ Tools β†’ Keyless web tools. If the user asks ' +
10470
+ 'for weather or a Wikipedia lookup, tell them they can turn that setting on. Still use your tools for the rest of the request.';
10471
+ }
10472
  function buildToolsForRuntime() {
10473
  const webConfigured = isSearchConfigured();
10474
  const caps = LocalMind.runtime.capabilities();
 
16744
  // template renders as <tool_response>. Endpoints (incl. a router escalation) keep the JSON prompt.
16745
  const nativeXmlTools = !!(activeModel && activeModel.toolFormat === 'qwen3-xml')
16746
  && !(LocalMind.runtime.isEndpoint && LocalMind.runtime.isEndpoint());
16747
+ // Tools through the model's own chat template (model entry toolFormat 'template', Transformers.js worker only:
16748
+ // LFM3): the worker passes them to apply_chat_template, so the model sees the tool block it was trained on;
16749
+ // tool results stay role 'tool'. On LocalMind's JSON prompt LFM3 1.7B offered get_current_time instead of
16750
+ // calling it (Chirag, 2026-10-28).
16751
+ const templateTools = !!(activeModel && activeModel.toolFormat === 'template')
16752
+ && !(LocalMind.runtime.isEndpoint && LocalMind.runtime.isEndpoint());
16753
 
16754
  const iter = makeAsyncIterator();
16755
  let completionTokens = 0;
 
16823
  content = String(content == null ? '' : content);
16824
  }
16825
  if (m.role === 'tool') {
16826
+ if (nativeXmlTools || templateTools) return { role: 'tool', name: m.name || 'tool', content };
16827
  const toolPayload = (() => {
16828
  try { return JSON.parse(content); } catch { return content; }
16829
  })();
 
16846
  userSysContent = typeof c === 'string' ? c : '';
16847
  chatMessages = chatMessages.slice(1);
16848
  }
16849
+ const hint = toolsSwitchedOffHint(tools);
16850
+ if (hint) userSysContent = userSysContent ? userSysContent + '\n\n' + hint : hint;
16851
+ if (templateTools) {
16852
+ genConfig.tools = tools.map((t) => ({ type: 'function', function: { name: t.name, description: t.description, parameters: t.parameters } }));
16853
+ if (userSysContent) chatMessages = [{ role: 'system', content: userSysContent }].concat(chatMessages);
16854
+ } else {
16855
+ const toolSys = nativeXmlTools ? _adapterBuildQwenXmlToolPrompt(tools, userSysContent) : _adapterBuildToolPrompt(tools, userSysContent);
16856
+ chatMessages = [{ role: 'system', content: toolSys }].concat(chatMessages);
16857
+ }
16858
  }
16859
  } catch (e) {
16860
  const err = e instanceof Error ? e : new Error(String(e));
 
18408
  add_generation_prompt: true,
18409
  return_dict: true,
18410
  enable_thinking: thinking,
18411
+ ...(Array.isArray(genConfig && genConfig.tools) ? { tools: genConfig.tools } : {}),
18412
  });
18413
  } catch (tplErr) {
18414
  // The pinned transformers.js jinja can't parse some real templates β€” e.g.
 
18432
  add_generation_prompt: true,
18433
  return_dict: true,
18434
  enable_thinking: thinking,
18435
+ ...(Array.isArray(genConfig && genConfig.tools) ? { tools: genConfig.tools } : {}),
18436
  chat_template: raw,
18437
  });
18438
  salvaged = true;