Skip to content

Commit 62c55c6

Browse files
committed
feat: added option to select default interferencing runtime to preferences
Signed-off-by: Evzen Gasta <[email protected]>
1 parent debdc05 commit 62c55c6

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

packages/backend/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
"maximum": 65535,
5252
"description": "Port on which the API is listening (requires restart of extension)"
5353
},
54+
"ai-lab.inferenceRuntime": {
55+
"type": "string",
56+
"default": "llama-cpp",
57+
"enum": [
58+
"llama-cpp",
59+
"whisper-cpp",
60+
"none"
61+
],
62+
"description": "Choose the default inferencing runtime for AI Lab"
63+
},
5464
"ai-lab.experimentalTuning": {
5565
"type": "boolean",
5666
"default": false,

packages/backend/src/registries/ConfigurationRegistry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ const CONFIGURATION_SECTIONS: string[] = [
2626
'models.path',
2727
'experimentalGPU',
2828
'apiPort',
29+
'inferenceRuntime',
2930
'experimentalTuning',
3031
'modelUploadDisabled',
3132
'showGPUPromotion',
3233
'appearance',
3334
];
3435

3536
const API_PORT_DEFAULT = 10434;
36-
37+
const INFERENCE_RUNTIME_DEFAULT = 'llama-cpp';
3738
export class ConfigurationRegistry extends Publisher<ExtensionConfiguration> implements Disposable {
3839
#configuration: Configuration;
3940
#configurationPodmanDesktop: Configuration;
@@ -54,6 +55,7 @@ export class ConfigurationRegistry extends Publisher<ExtensionConfiguration> imp
5455
modelsPath: this.getModelsPath(),
5556
experimentalGPU: this.#configuration.get<boolean>('experimentalGPU') ?? false,
5657
apiPort: this.#configuration.get<number>('apiPort') ?? API_PORT_DEFAULT,
58+
inferenceRuntime: this.#configuration.get<string>('inferenceRuntime') ?? INFERENCE_RUNTIME_DEFAULT,
5759
experimentalTuning: this.#configuration.get<boolean>('experimentalTuning') ?? false,
5860
modelUploadDisabled: this.#configuration.get<boolean>('modelUploadDisabled') ?? false,
5961
showGPUPromotion: this.#configuration.get<boolean>('showGPUPromotion') ?? true,

packages/frontend/src/lib/select/ModelSelect.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { faCheckCircle, faDownload } from '@fortawesome/free-solid-svg-icons';
33
import Select from './Select.svelte';
44
import Fa from 'svelte-fa';
55
import type { ModelInfo } from '@shared/models/IModelInfo';
6+
import { onMount } from 'svelte';
7+
import { configuration } from '/@/stores/extensionConfiguration';
68
79
interface Props {
810
disabled?: boolean;
@@ -44,6 +46,13 @@ let selected: (ModelInfo & { label: string; value: string }) | undefined = $deri
4446
function handleOnChange(nValue: (ModelInfo & { label: string; value: string }) | undefined): void {
4547
value = nValue;
4648
}
49+
50+
let defaultRuntime: string = 'llama-cpp';
51+
52+
onMount(() => {
53+
const inferenceRuntime = $configuration?.inferenceRuntime;
54+
if (inferenceRuntime) defaultRuntime = inferenceRuntime;
55+
});
4756
</script>
4857

4958
<Select
@@ -54,6 +63,7 @@ function handleOnChange(nValue: (ModelInfo & { label: string; value: string }) |
5463
onchange={handleOnChange}
5564
placeholder="Select model to use"
5665
items={models
66+
.filter(model => model.backend === defaultRuntime)
5767
.toSorted((a, b) => getModelSortingScore(a) - getModelSortingScore(b))
5868
.map(model => ({ ...model, value: model.id, label: model.name }))}>
5969
<div slot="item" let:item>

packages/shared/src/models/IExtensionConfiguration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface ExtensionConfiguration {
2020
experimentalGPU: boolean;
2121
modelsPath: string;
2222
apiPort: number;
23+
inferenceRuntime: string;
2324
experimentalTuning: boolean;
2425
modelUploadDisabled: boolean;
2526
showGPUPromotion: boolean;

0 commit comments

Comments
 (0)