Skip to content

Commit 44d7eba

Browse files
committed
add vision model path and server secret key settings; update server start handling
1 parent a7cd9f3 commit 44d7eba

5 files changed

Lines changed: 42 additions & 3 deletions

File tree

src/main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,24 @@ function killProcess(child: ChildProcess): Promise<void> {
9595

9696
ipcMain.handle(
9797
"server:start",
98-
async (_event, serverPath: string, modelPath: string, additionalArgs: string): Promise<string> => {
98+
async (_event, serverPath: string, modelPath: string, visionModelPath: string, additionalArgs: string): Promise<string> => {
9999
if (serverProcess) {
100100
return "Server is already running";
101101
}
102102

103103
return new Promise((resolve, reject) => {
104-
const args = ["--model", modelPath, ...additionalArgs.split(" ").filter(Boolean)];
104+
if (!serverPath || !modelPath || serverPath.trim() === "" || modelPath.trim() === "") {
105+
reject("Server path and model path are required");
106+
return;
107+
}
108+
109+
let args = ["--model", modelPath];
110+
111+
if (visionModelPath && visionModelPath.trim() !== "") {
112+
args.push("--mmproj", visionModelPath);
113+
}
114+
115+
args = args.concat(additionalArgs.split(" ").filter(Boolean));
105116

106117
serverProcess = spawn(serverPath, args, {
107118
stdio: ["ignore", "pipe", "pipe"],

src/preload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ contextBridge.exposeInMainWorld("electronBridge", {
1010
startServer: (
1111
serverPath: string,
1212
modelPath: string,
13+
visionModelPath: string,
1314
additionalArgs: string,
1415
): Promise<void> => {
15-
return ipcRenderer.invoke('server:start', serverPath, modelPath, additionalArgs);
16+
return ipcRenderer.invoke('server:start', serverPath, modelPath, visionModelPath, additionalArgs);
1617
},
1718

1819
onServerStdout: (callback: (data: string) => void) => {

src/screens/LLMServerPanel.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ interface ElectronBridge {
5353
startServer: (
5454
serverPath: string,
5555
modelPath: string,
56+
visionModelPath: string,
5657
additionalArgs: string,
5758
) => Promise<void>;
5859
stopServer: () => Promise<void>;
@@ -347,6 +348,7 @@ const LlmServerPanel: React.FC<{ goToSettings: () => void }> = ({
347348

348349
// ── Settings refs ──
349350
const modelPathRef = useRef<string | null>(null);
351+
const visionModelPathRef = useRef<string | null>(null);
350352
const additionalArgsRef = useRef<string | null>(null);
351353
const localServerPathRef = useRef<string | null>(null);
352354
const [serverSecret, setServerSecret] = useState("");
@@ -415,6 +417,8 @@ const LlmServerPanel: React.FC<{ goToSettings: () => void }> = ({
415417
dc.onopen = () => {
416418
addLog("RTC", `DataChannel OPEN (${dc.label})`);
417419
addLog("RTC", "DataChannel connected!");
420+
421+
setStatus("Device connected, ready to stream requests");
418422
};
419423

420424
dc.onclose = () => {
@@ -727,6 +731,7 @@ const LlmServerPanel: React.FC<{ goToSettings: () => void }> = ({
727731
await getElectronBridge().startServer(
728732
localServerPathRef.current,
729733
modelPathRef.current,
734+
visionModelPathRef.current || "",
730735
additionalArgsRef.current || "",
731736
);
732737

@@ -771,16 +776,19 @@ const LlmServerPanel: React.FC<{ goToSettings: () => void }> = ({
771776
UserSettingKey.ADDITIONAL_SERVER_CMD_ARGS,
772777
UserSettingKey.LOCAL_SERVER_PATH,
773778
UserSettingKey.SERVER_SECRET_KEY,
779+
UserSettingKey.VISION_MODEL_PATH,
774780
]);
775781

776782
const mp = settings[UserSettingKey.MODEL_PATH];
777783
const aa = settings[UserSettingKey.ADDITIONAL_SERVER_CMD_ARGS];
778784
const lsp = settings[UserSettingKey.LOCAL_SERVER_PATH];
785+
const vmp = settings[UserSettingKey.VISION_MODEL_PATH];
779786
const ssk = settings[UserSettingKey.SERVER_SECRET_KEY];
780787

781788
setServerSecret(ssk);
782789
serverSecretRef.current = ssk;
783790
modelPathRef.current = mp;
791+
visionModelPathRef.current = vmp;
784792
additionalArgsRef.current = aa;
785793
localServerPathRef.current = lsp;
786794

src/screens/SettingsPage.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ const SETTING_SECTIONS: {
6666
placeholder: "--threads 8 --ctx-size 4096",
6767
tag: "CLI",
6868
},
69+
{
70+
key: UserSettingKey.SERVER_SECRET_KEY,
71+
label: "Server Secret Key",
72+
description:
73+
"Secret key used to authenticate with the server.",
74+
type: "text",
75+
placeholder: "Enter your server secret key",
76+
tag: "SECRET",
77+
},
6978
],
7079
},
7180
{
@@ -79,6 +88,13 @@ const SETTING_SECTIONS: {
7988
type: "file",
8089
tag: "GGUF",
8190
},
91+
{
92+
key: UserSettingKey.VISION_MODEL_PATH,
93+
label: "Vision Model File",
94+
description: "Path to the vision model file on disk.",
95+
type: "file",
96+
tag: "GGUF",
97+
},
8298
],
8399
},
84100
];

src/services/user-settings-service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function generatePassword(length: number = 16): string {
66
export enum UserSettingKey {
77
LOCAL_SERVER_URL = 'local-server-url',
88
MODEL_PATH = 'model-path',
9+
VISION_MODEL_PATH = 'vision-model-path',
910
LOCAL_SERVER_PATH = 'local-server-path',
1011
ADDITIONAL_SERVER_CMD_ARGS = 'additional-server-cmd-args',
1112
SERVER_SECRET_KEY = 'server-secret-key',
@@ -14,6 +15,7 @@ export enum UserSettingKey {
1415
type UserSettingDefaults = {
1516
[UserSettingKey.LOCAL_SERVER_URL]: string;
1617
[UserSettingKey.MODEL_PATH]: string | null;
18+
[UserSettingKey.VISION_MODEL_PATH]: string | null;
1719
[UserSettingKey.LOCAL_SERVER_PATH]: string;
1820
[UserSettingKey.ADDITIONAL_SERVER_CMD_ARGS]: string | null;
1921
[UserSettingKey.SERVER_SECRET_KEY]: string;
@@ -24,6 +26,7 @@ export const USER_SETTING_DEFAULTS: {
2426
} = {
2527
[UserSettingKey.LOCAL_SERVER_URL]: 'http://127.0.0.1:8080/v1/chat/completions',
2628
[UserSettingKey.MODEL_PATH]: null,
29+
[UserSettingKey.VISION_MODEL_PATH]: null,
2730
[UserSettingKey.LOCAL_SERVER_PATH]: './resources/server/llama-server.exe',
2831
[UserSettingKey.ADDITIONAL_SERVER_CMD_ARGS]: null,
2932
[UserSettingKey.SERVER_SECRET_KEY]: generatePassword(),

0 commit comments

Comments
 (0)