@iblai/web-utils 1.11.4 → 1.11.5
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.ts +1 -1
- package/dist/index.esm.js +44 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +44 -4
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12365,7 +12365,35 @@ const selectEnableChatActionsPopup = (state) => state.chat.enableChatActionsPopu
|
|
|
12365
12365
|
* because browsers block mixed content (HTTPS page -> HTTP localhost).
|
|
12366
12366
|
*/
|
|
12367
12367
|
const OLLAMA_BASE_URL = "http://localhost:11434";
|
|
12368
|
+
/**
|
|
12369
|
+
* Ollama-compatible MCP/tool proxy. Chat for tool-capable models is routed here
|
|
12370
|
+
* (instead of plain Ollama) so the model gets MCP tools. The host (ghost-os)
|
|
12371
|
+
* owns the real routing for the Tauri path; this is the fetch-path equivalent.
|
|
12372
|
+
*/
|
|
12373
|
+
const TOOL_BRIDGE_BASE_URL = "http://localhost:8000";
|
|
12368
12374
|
const OLLAMA_MODEL = "phi3:mini";
|
|
12375
|
+
const LOCAL_LLM_MODEL_KEY = "ibl_local_llm_model";
|
|
12376
|
+
const LOCAL_LLM_TOOL_SUPPORT_KEY = "ibl_local_llm_tool_support";
|
|
12377
|
+
/**
|
|
12378
|
+
* The model the user has chosen to chat with (persisted by the Local Models
|
|
12379
|
+
* settings UI), falling back to the default model.
|
|
12380
|
+
*/
|
|
12381
|
+
function getSelectedModel() {
|
|
12382
|
+
if (typeof window === "undefined")
|
|
12383
|
+
return OLLAMA_MODEL;
|
|
12384
|
+
return localStorage.getItem(LOCAL_LLM_MODEL_KEY) || OLLAMA_MODEL;
|
|
12385
|
+
}
|
|
12386
|
+
/**
|
|
12387
|
+
* Whether the selected model supports tools / function calling, persisted by the
|
|
12388
|
+
* Local Models settings UI (`setLocalLLMToolSupport` in @iblai/web-containers).
|
|
12389
|
+
* Read directly from localStorage to avoid a web-utils → web-containers import
|
|
12390
|
+
* cycle — same approach as {@link getSelectedModel}.
|
|
12391
|
+
*/
|
|
12392
|
+
function getSelectedModelToolSupport() {
|
|
12393
|
+
if (typeof window === "undefined")
|
|
12394
|
+
return false;
|
|
12395
|
+
return localStorage.getItem(LOCAL_LLM_TOOL_SUPPORT_KEY) === "true";
|
|
12396
|
+
}
|
|
12369
12397
|
/**
|
|
12370
12398
|
* Check if running in Tauri
|
|
12371
12399
|
*/
|
|
@@ -12449,11 +12477,17 @@ async function streamOllamaChatViaTauri(messages, callbacks, generationId) {
|
|
|
12449
12477
|
}
|
|
12450
12478
|
});
|
|
12451
12479
|
try {
|
|
12452
|
-
|
|
12480
|
+
const model = getSelectedModel();
|
|
12481
|
+
const toolSupport = getSelectedModelToolSupport();
|
|
12482
|
+
console.log("[LocalLLM] Chatting with model:", model, "toolSupport:", toolSupport);
|
|
12483
|
+
// Call the Tauri command to start streaming. `toolSupport` (→ Rust
|
|
12484
|
+
// `tool_support`) lets the host route to the MCP/tool proxy (:8000) vs
|
|
12485
|
+
// plain Ollama (:11434); the host owns the actual routing decision.
|
|
12453
12486
|
await invoke("ollama_chat_stream", {
|
|
12454
12487
|
messages,
|
|
12455
|
-
model
|
|
12488
|
+
model,
|
|
12456
12489
|
generationId,
|
|
12490
|
+
toolSupport,
|
|
12457
12491
|
});
|
|
12458
12492
|
}
|
|
12459
12493
|
finally {
|
|
@@ -12476,13 +12510,19 @@ async function streamOllamaChatViaFetch(messages, callbacks, generationId, abort
|
|
|
12476
12510
|
try {
|
|
12477
12511
|
// Notify start
|
|
12478
12512
|
callbacks.onStart(generationId);
|
|
12479
|
-
const
|
|
12513
|
+
const model = getSelectedModel();
|
|
12514
|
+
const toolSupport = getSelectedModelToolSupport();
|
|
12515
|
+
// Tool-capable models stream from the MCP/tool proxy (:8000); others from
|
|
12516
|
+
// plain Ollama (:11434).
|
|
12517
|
+
const base = toolSupport ? TOOL_BRIDGE_BASE_URL : OLLAMA_BASE_URL;
|
|
12518
|
+
console.log("[LocalLLM] Chatting with model:", model, "toolSupport:", toolSupport, "via", base);
|
|
12519
|
+
const response = await fetch(`${base}/api/chat`, {
|
|
12480
12520
|
method: "POST",
|
|
12481
12521
|
headers: {
|
|
12482
12522
|
"Content-Type": "application/json",
|
|
12483
12523
|
},
|
|
12484
12524
|
body: JSON.stringify({
|
|
12485
|
-
model
|
|
12525
|
+
model,
|
|
12486
12526
|
messages,
|
|
12487
12527
|
stream: true,
|
|
12488
12528
|
}),
|