@iblai/web-utils 1.11.3 → 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 +48 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +48 -8
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1101,7 +1101,7 @@ declare const isNode: () => string | false;
|
|
|
1101
1101
|
declare const isExpo: () => any;
|
|
1102
1102
|
declare const isTauri: () => boolean;
|
|
1103
1103
|
declare function isSafariBrowser(): boolean;
|
|
1104
|
-
declare const getPlatform: () => "
|
|
1104
|
+
declare const getPlatform: () => "react-native" | "web" | "node" | "unknown";
|
|
1105
1105
|
declare const safeRequire: (moduleName: string) => any;
|
|
1106
1106
|
declare const getNextNavigation: () => any;
|
|
1107
1107
|
|
package/dist/index.esm.js
CHANGED
|
@@ -947,9 +947,9 @@ const BASE_CONFIG = {
|
|
|
947
947
|
},
|
|
948
948
|
{
|
|
949
949
|
slug: "overall_default_mentor",
|
|
950
|
-
label: "Default
|
|
950
|
+
label: "Default Agent",
|
|
951
951
|
defaultValue: "",
|
|
952
|
-
description: "Default
|
|
952
|
+
description: "Default agent to open on the platform",
|
|
953
953
|
type: "string",
|
|
954
954
|
},
|
|
955
955
|
/* {
|
|
@@ -1087,9 +1087,9 @@ const MENTOR_AI_CONFIG = {
|
|
|
1087
1087
|
},
|
|
1088
1088
|
{
|
|
1089
1089
|
slug: "mentor_include_community_mentors",
|
|
1090
|
-
label: "Community
|
|
1090
|
+
label: "Community Agents",
|
|
1091
1091
|
defaultValue: true,
|
|
1092
|
-
description: "Allow users to access the
|
|
1092
|
+
description: "Allow users to access the agents from the community.",
|
|
1093
1093
|
type: "boolean",
|
|
1094
1094
|
},
|
|
1095
1095
|
{
|
|
@@ -12345,7 +12345,35 @@ const selectEnableChatActionsPopup = (state) => state.chat.enableChatActionsPopu
|
|
|
12345
12345
|
* because browsers block mixed content (HTTPS page -> HTTP localhost).
|
|
12346
12346
|
*/
|
|
12347
12347
|
const OLLAMA_BASE_URL = "http://localhost:11434";
|
|
12348
|
+
/**
|
|
12349
|
+
* Ollama-compatible MCP/tool proxy. Chat for tool-capable models is routed here
|
|
12350
|
+
* (instead of plain Ollama) so the model gets MCP tools. The host (ghost-os)
|
|
12351
|
+
* owns the real routing for the Tauri path; this is the fetch-path equivalent.
|
|
12352
|
+
*/
|
|
12353
|
+
const TOOL_BRIDGE_BASE_URL = "http://localhost:8000";
|
|
12348
12354
|
const OLLAMA_MODEL = "phi3:mini";
|
|
12355
|
+
const LOCAL_LLM_MODEL_KEY = "ibl_local_llm_model";
|
|
12356
|
+
const LOCAL_LLM_TOOL_SUPPORT_KEY = "ibl_local_llm_tool_support";
|
|
12357
|
+
/**
|
|
12358
|
+
* The model the user has chosen to chat with (persisted by the Local Models
|
|
12359
|
+
* settings UI), falling back to the default model.
|
|
12360
|
+
*/
|
|
12361
|
+
function getSelectedModel() {
|
|
12362
|
+
if (typeof window === "undefined")
|
|
12363
|
+
return OLLAMA_MODEL;
|
|
12364
|
+
return localStorage.getItem(LOCAL_LLM_MODEL_KEY) || OLLAMA_MODEL;
|
|
12365
|
+
}
|
|
12366
|
+
/**
|
|
12367
|
+
* Whether the selected model supports tools / function calling, persisted by the
|
|
12368
|
+
* Local Models settings UI (`setLocalLLMToolSupport` in @iblai/web-containers).
|
|
12369
|
+
* Read directly from localStorage to avoid a web-utils → web-containers import
|
|
12370
|
+
* cycle — same approach as {@link getSelectedModel}.
|
|
12371
|
+
*/
|
|
12372
|
+
function getSelectedModelToolSupport() {
|
|
12373
|
+
if (typeof window === "undefined")
|
|
12374
|
+
return false;
|
|
12375
|
+
return localStorage.getItem(LOCAL_LLM_TOOL_SUPPORT_KEY) === "true";
|
|
12376
|
+
}
|
|
12349
12377
|
/**
|
|
12350
12378
|
* Check if running in Tauri
|
|
12351
12379
|
*/
|
|
@@ -12429,11 +12457,17 @@ async function streamOllamaChatViaTauri(messages, callbacks, generationId) {
|
|
|
12429
12457
|
}
|
|
12430
12458
|
});
|
|
12431
12459
|
try {
|
|
12432
|
-
|
|
12460
|
+
const model = getSelectedModel();
|
|
12461
|
+
const toolSupport = getSelectedModelToolSupport();
|
|
12462
|
+
console.log("[LocalLLM] Chatting with model:", model, "toolSupport:", toolSupport);
|
|
12463
|
+
// Call the Tauri command to start streaming. `toolSupport` (→ Rust
|
|
12464
|
+
// `tool_support`) lets the host route to the MCP/tool proxy (:8000) vs
|
|
12465
|
+
// plain Ollama (:11434); the host owns the actual routing decision.
|
|
12433
12466
|
await invoke("ollama_chat_stream", {
|
|
12434
12467
|
messages,
|
|
12435
|
-
model
|
|
12468
|
+
model,
|
|
12436
12469
|
generationId,
|
|
12470
|
+
toolSupport,
|
|
12437
12471
|
});
|
|
12438
12472
|
}
|
|
12439
12473
|
finally {
|
|
@@ -12456,13 +12490,19 @@ async function streamOllamaChatViaFetch(messages, callbacks, generationId, abort
|
|
|
12456
12490
|
try {
|
|
12457
12491
|
// Notify start
|
|
12458
12492
|
callbacks.onStart(generationId);
|
|
12459
|
-
const
|
|
12493
|
+
const model = getSelectedModel();
|
|
12494
|
+
const toolSupport = getSelectedModelToolSupport();
|
|
12495
|
+
// Tool-capable models stream from the MCP/tool proxy (:8000); others from
|
|
12496
|
+
// plain Ollama (:11434).
|
|
12497
|
+
const base = toolSupport ? TOOL_BRIDGE_BASE_URL : OLLAMA_BASE_URL;
|
|
12498
|
+
console.log("[LocalLLM] Chatting with model:", model, "toolSupport:", toolSupport, "via", base);
|
|
12499
|
+
const response = await fetch(`${base}/api/chat`, {
|
|
12460
12500
|
method: "POST",
|
|
12461
12501
|
headers: {
|
|
12462
12502
|
"Content-Type": "application/json",
|
|
12463
12503
|
},
|
|
12464
12504
|
body: JSON.stringify({
|
|
12465
|
-
model
|
|
12505
|
+
model,
|
|
12466
12506
|
messages,
|
|
12467
12507
|
stream: true,
|
|
12468
12508
|
}),
|