Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat(llamacpp): name the engine and its version on the provider settings page

Akarshan Biswasc987fb7ba831
diff --git a/extensions/llamacpp-extension/src/index.ts b/extensions/llamacpp-extension/src/index.ts
index fbc7b64e2..ed0681be0 100644
--- a/extensions/llamacpp-extension/src/index.ts
+++ b/extensions/llamacpp-extension/src/index.ts
@@ -77,6 +77,7 @@ import {
startEngine,
eraseThreadSlotState,
getEngineInfo as pluginGetEngineInfo,
+ getEngineVersion as pluginGetEngineVersion,
reloadEngineModels,
engineDevices,
generateApiKey as pluginGenerateApiKey,
@@ -90,6 +91,7 @@ import {
EmbeddingResponse,
ModelProps,
DeviceList,
+ EngineVersion,
} from '@janhq/tauri-plugin-llamacpp-api'
import { getSystemUsage, getSystemInfo } from '@janhq/tauri-plugin-hardware-api'
@@ -438,6 +440,7 @@ export default class llamacpp_extension extends AIEngine implements EmbeddingEng
private enginePort?: number
private engineApiKey?: string
+ private engineVersion?: EngineVersion
private presetPath?: string
private engineStartLock: Promise<void> | null = null
private userModelsMax: number = 1
@@ -994,6 +997,18 @@ export default class llamacpp_extension extends AIEngine implements EmbeddingEng
return null
}
+ /**
+ * The bundled engine's identity. Cached after the first call: these are
+ * compile-time constants of the plugin, so they cannot change while the app
+ * is running, and the settings screen asks on every mount.
+ */
+ async getEngineVersion(): Promise<EngineVersion> {
+ if (!this.engineVersion) {
+ this.engineVersion = await pluginGetEngineVersion()
+ }
+ return this.engineVersion
+ }
+
/**
* Fetch runtime properties for a loaded model from the router's
* `/props?model=<id>` endpoint. Returns `undefined` if the router isn't
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/build.rs b/src-tauri/plugins/tauri-plugin-llamacpp/build.rs
index 376c9a66e..543bde6d2 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/build.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/build.rs
@@ -33,6 +33,7 @@ const COMMANDS: &[&str] = &[
"start_engine",
"stop_engine",
"get_engine_info",
+ "get_engine_version",
"reload_engine_models",
"engine_devices",
"force_stop_engine",
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/index.ts b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/index.ts
index 5b93cc0d3..44df8bead 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/index.ts
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/index.ts
@@ -5,6 +5,7 @@ import {
UnloadResult,
ReloadReport,
EngineInfo,
+ EngineVersion,
GgufMetadata,
} from './types'
@@ -118,6 +119,17 @@ export async function getEngineInfo(): Promise<EngineInfo | null> {
return await invoke('plugin:llamacpp|get_engine_info')
}
+/**
+ * The bundled engine's identity, from compile-time constants.
+ *
+ * Unlike `getEngineInfo`, this answers whether or not a worker is running --
+ * the engine is linked into the app, so its version is a property of the build
+ * rather than of any process.
+ */
+export async function getEngineVersion(): Promise<EngineVersion> {
+ return await invoke('plugin:llamacpp|get_engine_version')
+}
+
/**
* The devices the shipped engine can offload to.
*
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts
index 27fa5dc2b..e25e3c7d0 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/guest-js/types.ts
@@ -21,6 +21,18 @@ export interface EngineInfo {
models: string[]
}
+/** Mirrors `engine::commands::EngineVersion`. */
+export interface EngineVersion {
+ /** llama.cpp's own version, e.g. "0.4.0". */
+ version: string
+ /** Upstream build tag the source was taken from, e.g. "b10809". */
+ tag: string
+ /** The tag's build number, as a string. */
+ build_number: string
+ /** Full commit sha -- the tag is mutable upstream, this is the real pin. */
+ commit: string
+}
+
/**
* Mirrors `engine::commands::ReloadReport`. Every model in the preset appears
* in exactly one list, so an empty `changed`/`removed` proves the reload left
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/permissions/autogenerated/reference.md b/src-tauri/plugins/tauri-plugin-llamacpp/permissions/autogenerated/reference.md
index a5d7e4e1d..f150ee41e 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/permissions/autogenerated/reference.md
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/permissions/autogenerated/reference.md
@@ -14,6 +14,7 @@ Default permissions for the llamacpp plugin
- `allow-start-engine`
- `allow-stop-engine`
- `allow-get-engine-info`
+- `allow-get-engine-version`
- `allow-reload-engine-models`
- `allow-engine-devices`
- `allow-force-stop-engine`
@@ -295,6 +296,32 @@ Denies the get_engine_info command without any pre-configured scope.
<tr>
<td>
+`llamacpp:allow-get-engine-version`
+
+</td>
+<td>
+
+Enables the get_engine_version command without any pre-configured scope.
+
+</td>
+</tr>
+
+<tr>
+<td>
+
+`llamacpp:deny-get-engine-version`
+
+</td>
+<td>
+
+Denies the get_engine_version command without any pre-configured scope.
+
+</td>
+</tr>
+
+<tr>
+<td>
+
`llamacpp:allow-get-loaded-models`
</td>
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/permissions/default.toml b/src-tauri/plugins/tauri-plugin-llamacpp/permissions/default.toml
index 0585e75d9..68ffcea7a 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/permissions/default.toml
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/permissions/default.toml
@@ -16,6 +16,7 @@ permissions = [
"allow-start-engine",
"allow-stop-engine",
"allow-get-engine-info",
+ "allow-get-engine-version",
"allow-reload-engine-models",
"allow-engine-devices",
"allow-force-stop-engine",
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/permissions/schemas/schema.json b/src-tauri/plugins/tauri-plugin-llamacpp/permissions/schemas/schema.json
index d46852336..6f44e6164 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/permissions/schemas/schema.json
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/permissions/schemas/schema.json
@@ -414,6 +414,18 @@
"const": "deny-get-engine-info",
"markdownDescription": "Denies the get_engine_info command without any pre-configured scope."
},
+ {
+ "description": "Enables the get_engine_version command without any pre-configured scope.",
+ "type": "string",
+ "const": "allow-get-engine-version",
+ "markdownDescription": "Enables the get_engine_version command without any pre-configured scope."
+ },
+ {
+ "description": "Denies the get_engine_version command without any pre-configured scope.",
+ "type": "string",
+ "const": "deny-get-engine-version",
+ "markdownDescription": "Denies the get_engine_version command without any pre-configured scope."
+ },
{
"description": "Enables the get_loaded_models command without any pre-configured scope.",
"type": "string",
@@ -511,10 +523,10 @@
"markdownDescription": "Denies the unload_llama_model command without any pre-configured scope."
},
{
- "description": "Default permissions for the llamacpp plugin\n#### This default permission set includes:\n\n- `allow-cleanup-llama-processes`\n- `allow-load-llama-model`\n- `allow-unload-llama-model`\n- `allow-generate-api-key`\n- `allow-ensure-session-ready`\n- `allow-find-session-by-model`\n- `allow-get-loaded-models`\n- `allow-start-engine`\n- `allow-stop-engine`\n- `allow-get-engine-info`\n- `allow-reload-engine-models`\n- `allow-engine-devices`\n- `allow-force-stop-engine`\n- `allow-engine-slots-idle`\n- `allow-erase-thread-slot-state`\n- `allow-read-gguf-metadata`\n- `allow-find-gguf-tensors`\n- `allow-is-model-supported`",
+ "description": "Default permissions for the llamacpp plugin\n#### This default permission set includes:\n\n- `allow-cleanup-llama-processes`\n- `allow-load-llama-model`\n- `allow-unload-llama-model`\n- `allow-generate-api-key`\n- `allow-ensure-session-ready`\n- `allow-find-session-by-model`\n- `allow-get-loaded-models`\n- `allow-start-engine`\n- `allow-stop-engine`\n- `allow-get-engine-info`\n- `allow-get-engine-version`\n- `allow-reload-engine-models`\n- `allow-engine-devices`\n- `allow-force-stop-engine`\n- `allow-engine-slots-idle`\n- `allow-erase-thread-slot-state`\n- `allow-read-gguf-metadata`\n- `allow-find-gguf-tensors`\n- `allow-is-model-supported`",
"type": "string",
"const": "default",
- "markdownDescription": "Default permissions for the llamacpp plugin\n#### This default permission set includes:\n\n- `allow-cleanup-llama-processes`\n- `allow-load-llama-model`\n- `allow-unload-llama-model`\n- `allow-generate-api-key`\n- `allow-ensure-session-ready`\n- `allow-find-session-by-model`\n- `allow-get-loaded-models`\n- `allow-start-engine`\n- `allow-stop-engine`\n- `allow-get-engine-info`\n- `allow-reload-engine-models`\n- `allow-engine-devices`\n- `allow-force-stop-engine`\n- `allow-engine-slots-idle`\n- `allow-erase-thread-slot-state`\n- `allow-read-gguf-metadata`\n- `allow-find-gguf-tensors`\n- `allow-is-model-supported`"
+ "markdownDescription": "Default permissions for the llamacpp plugin\n#### This default permission set includes:\n\n- `allow-cleanup-llama-processes`\n- `allow-load-llama-model`\n- `allow-unload-llama-model`\n- `allow-generate-api-key`\n- `allow-ensure-session-ready`\n- `allow-find-session-by-model`\n- `allow-get-loaded-models`\n- `allow-start-engine`\n- `allow-stop-engine`\n- `allow-get-engine-info`\n- `allow-get-engine-version`\n- `allow-reload-engine-models`\n- `allow-engine-devices`\n- `allow-force-stop-engine`\n- `allow-engine-slots-idle`\n- `allow-erase-thread-slot-state`\n- `allow-read-gguf-metadata`\n- `allow-find-gguf-tensors`\n- `allow-is-model-supported`"
}
]
}
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/commands.rs b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/commands.rs
index 9c9af5c0b..1c80861ce 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/commands.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/src/engine/commands.rs
@@ -475,10 +475,50 @@ pub async fn get_engine_info(
Ok(guard.as_ref().map(EngineInfo::from))
}
+/// The llama.cpp this build is pinned to. Compile-time constants, so it answers
+/// with the engine's identity whether or not a worker is running -- unlike
+/// `get_engine_info`, which reports `None` while the engine is stopped, and is
+/// therefore no use to a settings screen that wants to name the engine.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct EngineVersion {
+ /// llama.cpp's own version, e.g. `0.4.0`.
+ pub version: String,
+ /// The upstream build tag the source was taken from, e.g. `b10809`.
+ pub tag: String,
+ /// The same tag's build number, which is what the shim reports back over
+ /// the FFI and what a version mismatch is checked against.
+ pub build_number: String,
+ /// Full commit sha. The tag is mutable upstream; this is the real pin.
+ pub commit: String,
+}
+
+#[tauri::command]
+pub fn get_engine_version() -> EngineVersion {
+ EngineVersion {
+ version: super::PINNED_VERSION.to_string(),
+ tag: super::PINNED_TAG.to_string(),
+ build_number: super::PINNED_BUILD_NUMBER.to_string(),
+ commit: super::PINNED_COMMIT.to_string(),
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
+ /// The screen that shows this is the only place a user can check which
+ /// engine they are running, so it has to report the pin rather than a
+ /// hardcoded string that outlives the next bump.
+ #[test]
+ fn the_reported_version_is_the_pin() {
+ let v = get_engine_version();
+ assert_eq!(v.version, super::super::PINNED_VERSION);
+ assert_eq!(v.tag, super::super::PINNED_TAG);
+ assert_eq!(v.build_number, super::super::PINNED_BUILD_NUMBER);
+ assert_eq!(v.commit, super::super::PINNED_COMMIT);
+ assert_eq!(v.commit.len(), 40, "a full sha, not the short form");
+ }
+
#[test]
fn generated_keys_are_long_hex_and_do_not_repeat() {
let a = generate_worker_key();
diff --git a/src-tauri/plugins/tauri-plugin-llamacpp/src/lib.rs b/src-tauri/plugins/tauri-plugin-llamacpp/src/lib.rs
index 8d9fae22c..d1555f018 100644
--- a/src-tauri/plugins/tauri-plugin-llamacpp/src/lib.rs
+++ b/src-tauri/plugins/tauri-plugin-llamacpp/src/lib.rs
@@ -25,6 +25,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
engine::commands::start_engine,
engine::commands::stop_engine,
engine::commands::get_engine_info,
+ engine::commands::get_engine_version,
engine::commands::reload_engine_models,
engine::commands::engine_devices,
engine::commands::force_stop_engine,
diff --git a/web-app/src/containers/LlamacppEngineInfo.tsx b/web-app/src/containers/LlamacppEngineInfo.tsx
new file mode 100644
index 000000000..15505de13
--- /dev/null
+++ b/web-app/src/containers/LlamacppEngineInfo.tsx
@@ -0,0 +1,84 @@
+import { useEffect, useState } from 'react'
+import { IconCpu, IconExternalLink } from '@tabler/icons-react'
+
+import { useServiceHub } from '@/hooks/useServiceHub'
+import { useTranslation } from '@/i18n/react-i18next-compat'
+import type { EngineVersionInfo } from '@/services/models/types'
+
+const UPSTREAM_REPO = 'https://github.com/ggml-org/llama.cpp'
+const SHORT_SHA = 8
+
+function Fact({ label, value }: { label: string; value: string }) {
+ return (
+ <div className="flex items-baseline gap-1.5">
+ <dt className="text-xs text-muted-foreground">{label}</dt>
+ <dd className="font-mono text-xs tabular-nums text-foreground">
+ {value}
+ </dd>
+ </div>
+ )
+}
+
+/**
+ * What engine the app is running, on the provider's own settings page.
+ *
+ * The engine is linked into the app rather than downloaded, so there is no
+ * version picker and nothing to update -- which is exactly why the version
+ * needs stating somewhere: without it a user reporting a load failure has no
+ * way to say which llama.cpp produced it. Renders nothing at all when the
+ * version is unavailable (a build with no engine, or a failed call), since a
+ * panel with blanks in it makes a weaker claim than no panel.
+ */
+export function LlamacppEngineInfo() {
+ const { t } = useTranslation()
+ const serviceHub = useServiceHub()
+ const [engine, setEngine] = useState<EngineVersionInfo | null>(null)
+
+ useEffect(() => {
+ let cancelled = false
+ serviceHub
+ .models()
+ .getEngineVersion()
+ .then((info) => {
+ if (!cancelled) setEngine(info)
+ })
+ return () => {
+ cancelled = true
+ }
+ }, [serviceHub])
+
+ if (!engine) return null
+
+ return (
+ <div className="rounded-lg border border-main-view-fg/10 bg-main-view-fg/5 p-4">
+ <div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-2">
+ <div className="flex items-center gap-2">
+ <IconCpu size={18} className="shrink-0 text-muted-foreground" />
+ <span className="font-medium text-foreground">llama.cpp</span>
+ <span className="rounded border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-xs tabular-nums text-foreground">
+ {engine.version}
+ </span>
+ </div>
+ <a
+ href={`${UPSTREAM_REPO}/releases/tag/${engine.tag}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"
+ >
+ <span>{t('providers:engineReleaseNotes')}</span>
+ <IconExternalLink size={14} />
+ </a>
+ </div>
+ <p className="mt-1.5 text-xs leading-normal text-muted-foreground">
+ {t('providers:engineBundled')}
+ </p>
+ <dl className="mt-3 flex flex-wrap gap-x-6 gap-y-1">
+ <Fact label={t('providers:engineBuild')} value={engine.tag} />
+ <Fact
+ label={t('providers:engineCommit')}
+ value={engine.commit.slice(0, SHORT_SHA)}
+ />
+ </dl>
+ </div>
+ )
+}
diff --git a/web-app/src/containers/__tests__/LlamacppEngineInfo.test.tsx b/web-app/src/containers/__tests__/LlamacppEngineInfo.test.tsx
new file mode 100644
index 000000000..1a0f27bea
--- /dev/null
+++ b/web-app/src/containers/__tests__/LlamacppEngineInfo.test.tsx
@@ -0,0 +1,68 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest'
+import { render, screen, waitFor } from '@testing-library/react'
+
+vi.mock('@/i18n/react-i18next-compat', () => ({
+ useTranslation: () => ({ t: (k: string) => k }),
+}))
+
+const { getEngineVersion } = vi.hoisted(() => ({
+ getEngineVersion: vi.fn(),
+}))
+vi.mock('@/hooks/useServiceHub', () => ({
+ useServiceHub: () => ({ models: () => ({ getEngineVersion }) }),
+}))
+
+import { LlamacppEngineInfo } from '../LlamacppEngineInfo'
+
+const PIN = {
+ version: '0.4.0',
+ tag: 'b10809',
+ buildNumber: '10809',
+ commit: '5266f24da75dc449bd56cbed7addb9c8e4a6a73e',
+}
+
+describe('LlamacppEngineInfo', () => {
+ beforeEach(() => {
+ getEngineVersion.mockReset()
+ })
+
+ it('names the engine and its version', async () => {
+ getEngineVersion.mockResolvedValue(PIN)
+ render(<LlamacppEngineInfo />)
+
+ expect(await screen.findByText('llama.cpp')).toBeInTheDocument()
+ expect(screen.getByText('0.4.0')).toBeInTheDocument()
+ expect(screen.getByText('b10809')).toBeInTheDocument()
+ })
+
+ // A 40-char sha would wrap the row and buys nothing a reader can use; the
+ // link is what gets them to the full commit.
+ it('shortens the commit and links the build to its upstream release', async () => {
+ getEngineVersion.mockResolvedValue(PIN)
+ render(<LlamacppEngineInfo />)
+
+ expect(await screen.findByText('5266f24d')).toBeInTheDocument()
+ expect(screen.queryByText(PIN.commit)).not.toBeInTheDocument()
+ expect(
+ screen.getByRole('link', { name: /engineReleaseNotes/ })
+ ).toHaveAttribute(
+ 'href',
+ 'https://github.com/ggml-org/llama.cpp/releases/tag/b10809'
+ )
+ })
+
+ // A panel with blanks in it makes a weaker claim than no panel: on a build
+ // with no engine there is nothing truthful to show.
+ it('renders nothing when the version is unavailable', async () => {
+ getEngineVersion.mockResolvedValue(null)
+ const { container } = render(<LlamacppEngineInfo />)
+ await waitFor(() => expect(getEngineVersion).toHaveBeenCalled())
+ expect(container).toBeEmptyDOMElement()
+ })
+
+ it('stays hidden while the call is still in flight', () => {
+ getEngineVersion.mockReturnValue(new Promise(() => {}))
+ const { container } = render(<LlamacppEngineInfo />)
+ expect(container).toBeEmptyDOMElement()
+ })
+})
diff --git a/web-app/src/locales/en/providers.json b/web-app/src/locales/en/providers.json
index 8639ef6e4..df956bf48 100644
--- a/web-app/src/locales/en/providers.json
+++ b/web-app/src/locales/en/providers.json
@@ -1,6 +1,10 @@
{
"limitedSupport": "This provider may not be fully supported. Capabilities (tools, vision, audio) are not auto-detected - add models manually and configure capabilities per model.",
"mlxExperimental": "MLX support is experimental. Embeddings are unavailable, the reasoning toggle is not yet wired through, and some newer model architectures may fail to load. Report issues on GitHub so we can prioritize them.",
+ "engineBundled": "The inference engine is built into Jan, so there is nothing to download or update separately. Quote this version when reporting a model that fails to load.",
+ "engineReleaseNotes": "Release notes",
+ "engineBuild": "Build",
+ "engineCommit": "Commit",
"refreshModelsError": "Provider must have base URL and at least one API key configured to fetch models.",
"refreshModelsSuccess": "Added {{count}} new model(s) from {{provider}}.",
"noNewModels": "No new models found. All available models are already added.",
diff --git a/web-app/src/routes/settings/providers/$providerName.tsx b/web-app/src/routes/settings/providers/$providerName.tsx
index 73c24371f..a12153777 100644
--- a/web-app/src/routes/settings/providers/$providerName.tsx
+++ b/web-app/src/routes/settings/providers/$providerName.tsx
@@ -13,6 +13,7 @@ import { DialogEditModel } from '@/containers/dialogs/EditModel'
import { ImportLlamacppModelDialog } from '@/containers/dialogs/ImportLlamacppModelDialog'
import { ImportMlxModelDialog } from '@/containers/dialogs/ImportMlxModelDialog'
import { ModelSetting } from '@/containers/ModelSetting'
+import { LlamacppEngineInfo } from '@/containers/LlamacppEngineInfo'
import { DialogDeleteModel } from '@/containers/dialogs/DeleteModel'
import { DialogDeleteAllModels } from '@/containers/dialogs/DeleteAllModels'
import { FavoriteModelAction } from '@/containers/FavoriteModelAction'
@@ -649,6 +650,8 @@ function ProviderDetail() {
</div>
)}
+ {isLlamacpp && <LlamacppEngineInfo />}
+
{provider?.provider === 'mlx' && (
<div className="flex items-start gap-2 rounded-md border border-main-view-fg/10 bg-main-view-fg/5 px-3 py-2 text-xs text-muted-foreground">
<IconInfoCircle size={16} className="mt-0.5 shrink-0" />
diff --git a/web-app/src/routes/settings/providers/__tests__/$providerName.test.tsx b/web-app/src/routes/settings/providers/__tests__/$providerName.test.tsx
index da5e74dbb..8b81891a0 100644
--- a/web-app/src/routes/settings/providers/__tests__/$providerName.test.tsx
+++ b/web-app/src/routes/settings/providers/__tests__/$providerName.test.tsx
@@ -101,6 +101,9 @@ const h = vi.hoisted(() => {
stopModel: vi.fn().mockResolvedValue(undefined),
stopAllModels: vi.fn().mockResolvedValue(undefined),
checkMmprojExists: vi.fn().mockResolvedValue(false),
+ // Null: the engine panel is the llamacpp page's own concern and has its
+ // own test, so it renders nothing here.
+ getEngineVersion: vi.fn().mockResolvedValue(null),
}
const dialogSvc = {
open: vi.fn().mockResolvedValue(null),
@@ -435,6 +438,19 @@ describe('ProviderDetail route', () => {
renderComponent()
expect(screen.getByTestId('import-vision')).toBeInTheDocument()
})
+
+ // The engine belongs to llamacpp alone: a remote provider runs no engine
+ // of ours, so the panel must not follow the page.
+ it('asks for the engine version only on the llamacpp page', async () => {
+ const asked = h.serviceHub.models().getEngineVersion
+ asked.mockClear()
+ renderComponent()
+ expect(asked).not.toHaveBeenCalled()
+
+ h.params.providerName = 'llamacpp'
+ renderComponent()
+ await waitFor(() => expect(asked).toHaveBeenCalled())
+ })
})
describe('Provider active toggle', () => {
diff --git a/web-app/src/services/models/default.ts b/web-app/src/services/models/default.ts
index 8bdf29951..628373709 100644
--- a/web-app/src/services/models/default.ts
+++ b/web-app/src/services/models/default.ts
@@ -25,6 +25,7 @@ import type {
ModelValidationResult,
EmbeddingModelReport,
GpuOffloadReport,
+ EngineVersionInfo,
} from './types'
import {
extractToolContextFromContent,
@@ -711,6 +712,36 @@ export class DefaultModelsService implements ModelsService {
}
}
+ /**
+ * Null on a build with no llamacpp engine (the web app) or if the call fails.
+ * The caller renders nothing rather than a half-filled panel: an unknown
+ * engine version is worse than no claim about it.
+ */
+ async getEngineVersion(): Promise<EngineVersionInfo | null> {
+ try {
+ const engine = this.getEngine('llamacpp') as AIEngine & {
+ getEngineVersion?: () => Promise<{
+ version: string
+ tag: string
+ build_number: string
+ commit: string
+ }>
+ }
+ if (engine && typeof engine.getEngineVersion === 'function') {
+ const info = await engine.getEngineVersion()
+ return {
+ version: info.version,
+ tag: info.tag,
+ buildNumber: info.build_number,
+ commit: info.commit,
+ }
+ }
+ } catch (error) {
+ console.warn('Failed to read the engine version:', error)
+ }
+ return null
+ }
+
async verifyGpuOffload(): Promise<GpuOffloadReport> {
const unknown: GpuOffloadReport = {
status: 'warning',
diff --git a/web-app/src/services/models/types.ts b/web-app/src/services/models/types.ts
index 795ff8b2e..84b344b50 100644
--- a/web-app/src/services/models/types.ts
+++ b/web-app/src/services/models/types.ts
@@ -189,10 +189,26 @@ export interface ModelsService {
validateGgufFile(filePath: string): Promise<ModelValidationResult>
getTokensCount(modelId: string, messages: ThreadMessage[]): Promise<number>
startEngineSetup(): Promise<void>
+ getEngineVersion(): Promise<EngineVersionInfo | null>
verifyEmbeddingModel(): Promise<EmbeddingModelReport>
verifyGpuOffload(): Promise<GpuOffloadReport>
}
+/**
+ * The bundled llama.cpp's identity. Redeclared here rather than imported from
+ * the plugin package, the same way DeviceList is: the web app talks to the
+ * extension, not to the plugin.
+ */
+export interface EngineVersionInfo {
+ /** llama.cpp's own version, e.g. "0.4.0". */
+ version: string
+ /** Upstream build tag, e.g. "b10809". */
+ tag: string
+ buildNumber: string
+ /** Full commit sha the build is pinned to. */
+ commit: string
+}
+
// Mirrors the llamacpp extension's readiness module across the extension
// boundary, the same way DeviceList is redeclared for the hardware service.
export type EmbeddingVectorProblem =