@appkit/llamacpp-cli 1.12.0 → 1.13.0
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/README.md +294 -168
- package/dist/cli.js +35 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/launch/claude.d.ts +6 -0
- package/dist/commands/launch/claude.d.ts.map +1 -0
- package/dist/commands/launch/claude.js +277 -0
- package/dist/commands/launch/claude.js.map +1 -0
- package/dist/lib/integration-checker.d.ts +26 -0
- package/dist/lib/integration-checker.d.ts.map +1 -0
- package/dist/lib/integration-checker.js +77 -0
- package/dist/lib/integration-checker.js.map +1 -0
- package/dist/lib/router-manager.d.ts +4 -0
- package/dist/lib/router-manager.d.ts.map +1 -1
- package/dist/lib/router-manager.js +10 -0
- package/dist/lib/router-manager.js.map +1 -1
- package/dist/lib/router-server.d.ts +13 -0
- package/dist/lib/router-server.d.ts.map +1 -1
- package/dist/lib/router-server.js +267 -7
- package/dist/lib/router-server.js.map +1 -1
- package/dist/types/integration-config.d.ts +28 -0
- package/dist/types/integration-config.d.ts.map +1 -0
- package/dist/types/integration-config.js +3 -0
- package/dist/types/integration-config.js.map +1 -0
- package/package.json +10 -2
- package/web/dist/assets/index-Bin89Lwr.css +1 -0
- package/web/dist/assets/index-CVmonw3T.js +17 -0
- package/web/{index.html → dist/index.html} +2 -1
- package/.versionrc.json +0 -16
- package/CHANGELOG.md +0 -213
- package/docs/images/.gitkeep +0 -1
- package/docs/images/web-ui-servers.png +0 -0
- package/src/cli.ts +0 -523
- package/src/commands/admin/config.ts +0 -121
- package/src/commands/admin/logs.ts +0 -91
- package/src/commands/admin/restart.ts +0 -26
- package/src/commands/admin/start.ts +0 -27
- package/src/commands/admin/status.ts +0 -84
- package/src/commands/admin/stop.ts +0 -16
- package/src/commands/config-global.ts +0 -38
- package/src/commands/config.ts +0 -323
- package/src/commands/create.ts +0 -183
- package/src/commands/delete.ts +0 -74
- package/src/commands/list.ts +0 -37
- package/src/commands/logs-all.ts +0 -251
- package/src/commands/logs.ts +0 -345
- package/src/commands/monitor.ts +0 -110
- package/src/commands/ps.ts +0 -84
- package/src/commands/pull.ts +0 -44
- package/src/commands/rm.ts +0 -107
- package/src/commands/router/config.ts +0 -116
- package/src/commands/router/logs.ts +0 -256
- package/src/commands/router/restart.ts +0 -36
- package/src/commands/router/start.ts +0 -60
- package/src/commands/router/status.ts +0 -119
- package/src/commands/router/stop.ts +0 -33
- package/src/commands/run.ts +0 -233
- package/src/commands/search.ts +0 -107
- package/src/commands/server-show.ts +0 -161
- package/src/commands/show.ts +0 -207
- package/src/commands/start.ts +0 -101
- package/src/commands/stop.ts +0 -39
- package/src/commands/tui.ts +0 -25
- package/src/lib/admin-manager.ts +0 -435
- package/src/lib/admin-server.ts +0 -1243
- package/src/lib/config-generator.ts +0 -130
- package/src/lib/download-job-manager.ts +0 -213
- package/src/lib/history-manager.ts +0 -172
- package/src/lib/launchctl-manager.ts +0 -225
- package/src/lib/metrics-aggregator.ts +0 -257
- package/src/lib/model-downloader.ts +0 -328
- package/src/lib/model-scanner.ts +0 -157
- package/src/lib/model-search.ts +0 -114
- package/src/lib/models-dir-setup.ts +0 -46
- package/src/lib/port-manager.ts +0 -80
- package/src/lib/router-logger.ts +0 -201
- package/src/lib/router-manager.ts +0 -414
- package/src/lib/router-server.ts +0 -538
- package/src/lib/state-manager.ts +0 -206
- package/src/lib/status-checker.ts +0 -113
- package/src/lib/system-collector.ts +0 -315
- package/src/tui/ConfigApp.ts +0 -1085
- package/src/tui/HistoricalMonitorApp.ts +0 -587
- package/src/tui/ModelsApp.ts +0 -368
- package/src/tui/MonitorApp.ts +0 -386
- package/src/tui/MultiServerMonitorApp.ts +0 -1833
- package/src/tui/RootNavigator.ts +0 -74
- package/src/tui/SearchApp.ts +0 -511
- package/src/tui/SplashScreen.ts +0 -149
- package/src/types/admin-config.ts +0 -25
- package/src/types/global-config.ts +0 -26
- package/src/types/history-types.ts +0 -39
- package/src/types/model-info.ts +0 -8
- package/src/types/monitor-types.ts +0 -162
- package/src/types/router-config.ts +0 -25
- package/src/types/server-config.ts +0 -46
- package/src/utils/downsample-utils.ts +0 -128
- package/src/utils/file-utils.ts +0 -146
- package/src/utils/format-utils.ts +0 -98
- package/src/utils/log-parser.ts +0 -284
- package/src/utils/log-utils.ts +0 -178
- package/src/utils/process-utils.ts +0 -316
- package/src/utils/prompt-utils.ts +0 -47
- package/test-load.sh +0 -100
- package/tsconfig.json +0 -20
- package/web/eslint.config.js +0 -23
- package/web/llamacpp-web-dist.tar.gz +0 -0
- package/web/package-lock.json +0 -4017
- package/web/package.json +0 -38
- package/web/postcss.config.js +0 -6
- package/web/src/App.css +0 -42
- package/web/src/App.tsx +0 -86
- package/web/src/assets/react.svg +0 -1
- package/web/src/components/ApiKeyPrompt.tsx +0 -71
- package/web/src/components/CreateServerModal.tsx +0 -372
- package/web/src/components/DownloadProgress.tsx +0 -123
- package/web/src/components/Nav.tsx +0 -89
- package/web/src/components/RouterConfigModal.tsx +0 -240
- package/web/src/components/SearchModal.tsx +0 -306
- package/web/src/components/ServerConfigModal.tsx +0 -291
- package/web/src/hooks/useApi.ts +0 -259
- package/web/src/index.css +0 -42
- package/web/src/lib/api.ts +0 -226
- package/web/src/main.tsx +0 -10
- package/web/src/pages/Dashboard.tsx +0 -103
- package/web/src/pages/Models.tsx +0 -258
- package/web/src/pages/Router.tsx +0 -270
- package/web/src/pages/RouterLogs.tsx +0 -201
- package/web/src/pages/ServerLogs.tsx +0 -553
- package/web/src/pages/Servers.tsx +0 -358
- package/web/src/types/api.ts +0 -140
- package/web/tailwind.config.js +0 -31
- package/web/tsconfig.app.json +0 -28
- package/web/tsconfig.json +0 -7
- package/web/tsconfig.node.json +0 -26
- package/web/vite.config.ts +0 -25
- /package/web/{public → dist}/vite.svg +0 -0
package/web/package.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "web",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "tsc -b && vite build",
|
|
9
|
-
"lint": "eslint .",
|
|
10
|
-
"preview": "vite preview"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@tailwindcss/postcss": "^4.1.18",
|
|
14
|
-
"@tanstack/react-query": "^5.90.20",
|
|
15
|
-
"lucide-react": "^0.563.0",
|
|
16
|
-
"react": "^19.2.0",
|
|
17
|
-
"react-dom": "^19.2.0",
|
|
18
|
-
"react-router-dom": "^7.13.0",
|
|
19
|
-
"zustand": "^5.0.11"
|
|
20
|
-
},
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@eslint/js": "^9.39.1",
|
|
23
|
-
"@types/node": "^24.10.11",
|
|
24
|
-
"@types/react": "^19.2.5",
|
|
25
|
-
"@types/react-dom": "^19.2.3",
|
|
26
|
-
"@vitejs/plugin-react": "^5.1.3",
|
|
27
|
-
"autoprefixer": "^10.4.24",
|
|
28
|
-
"eslint": "^9.39.1",
|
|
29
|
-
"eslint-plugin-react-hooks": "^7.0.1",
|
|
30
|
-
"eslint-plugin-react-refresh": "^0.4.24",
|
|
31
|
-
"globals": "^16.5.0",
|
|
32
|
-
"postcss": "^8.5.6",
|
|
33
|
-
"tailwindcss": "^4.1.18",
|
|
34
|
-
"typescript": "~5.9.3",
|
|
35
|
-
"typescript-eslint": "^8.46.4",
|
|
36
|
-
"vite": "^7.3.1"
|
|
37
|
-
}
|
|
38
|
-
}
|
package/web/postcss.config.js
DELETED
package/web/src/App.css
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#root {
|
|
2
|
-
max-width: 1280px;
|
|
3
|
-
margin: 0 auto;
|
|
4
|
-
padding: 2rem;
|
|
5
|
-
text-align: center;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.logo {
|
|
9
|
-
height: 6em;
|
|
10
|
-
padding: 1.5em;
|
|
11
|
-
will-change: filter;
|
|
12
|
-
transition: filter 300ms;
|
|
13
|
-
}
|
|
14
|
-
.logo:hover {
|
|
15
|
-
filter: drop-shadow(0 0 2em #646cffaa);
|
|
16
|
-
}
|
|
17
|
-
.logo.react:hover {
|
|
18
|
-
filter: drop-shadow(0 0 2em #61dafbaa);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@keyframes logo-spin {
|
|
22
|
-
from {
|
|
23
|
-
transform: rotate(0deg);
|
|
24
|
-
}
|
|
25
|
-
to {
|
|
26
|
-
transform: rotate(360deg);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
31
|
-
a:nth-of-type(2) .logo {
|
|
32
|
-
animation: logo-spin infinite 20s linear;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.card {
|
|
37
|
-
padding: 2em;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.read-the-docs {
|
|
41
|
-
color: #888;
|
|
42
|
-
}
|
package/web/src/App.tsx
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
|
-
import { BrowserRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom';
|
|
4
|
-
import { Nav } from './components/Nav';
|
|
5
|
-
import { ApiKeyPrompt } from './components/ApiKeyPrompt';
|
|
6
|
-
import { Servers } from './pages/Servers';
|
|
7
|
-
import { ServerLogs } from './pages/ServerLogs';
|
|
8
|
-
import { Models } from './pages/Models';
|
|
9
|
-
import { Router } from './pages/Router';
|
|
10
|
-
import { RouterLogs } from './pages/RouterLogs';
|
|
11
|
-
import { api } from './lib/api';
|
|
12
|
-
|
|
13
|
-
const queryClient = new QueryClient({
|
|
14
|
-
defaultOptions: {
|
|
15
|
-
queries: {
|
|
16
|
-
refetchOnWindowFocus: false,
|
|
17
|
-
retry: 1,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
function AppContent({ onLogout }: { onLogout: () => void }) {
|
|
23
|
-
const [searchQuery, setSearchQuery] = useState('');
|
|
24
|
-
const location = useLocation();
|
|
25
|
-
|
|
26
|
-
// Only show search on models page
|
|
27
|
-
const showSearch = location.pathname === '/models';
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div className="min-h-screen bg-neutral-50">
|
|
31
|
-
<Nav
|
|
32
|
-
onLogout={onLogout}
|
|
33
|
-
searchQuery={showSearch ? searchQuery : undefined}
|
|
34
|
-
onSearchChange={showSearch ? setSearchQuery : undefined}
|
|
35
|
-
/>
|
|
36
|
-
<Routes>
|
|
37
|
-
<Route path="/" element={<Navigate to="/servers" replace />} />
|
|
38
|
-
<Route path="/servers" element={<Servers />} />
|
|
39
|
-
<Route path="/servers/:id/logs" element={<ServerLogs />} />
|
|
40
|
-
<Route path="/models" element={<Models searchQuery={searchQuery} />} />
|
|
41
|
-
<Route path="/router" element={<Router />} />
|
|
42
|
-
<Route path="/router/logs" element={<RouterLogs />} />
|
|
43
|
-
</Routes>
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function App() {
|
|
49
|
-
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null);
|
|
50
|
-
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
const hasKey = !!api.getApiKey();
|
|
53
|
-
if (hasKey) {
|
|
54
|
-
api.getSystemStatus()
|
|
55
|
-
.then(() => setIsAuthenticated(true))
|
|
56
|
-
.catch(() => {
|
|
57
|
-
api.clearApiKey();
|
|
58
|
-
setIsAuthenticated(false);
|
|
59
|
-
});
|
|
60
|
-
} else {
|
|
61
|
-
setIsAuthenticated(false);
|
|
62
|
-
}
|
|
63
|
-
}, []);
|
|
64
|
-
|
|
65
|
-
if (isAuthenticated === null) {
|
|
66
|
-
return (
|
|
67
|
-
<div className="min-h-screen bg-neutral-50 flex items-center justify-center">
|
|
68
|
-
<div className="text-neutral-400">Loading...</div>
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!isAuthenticated) {
|
|
74
|
-
return <ApiKeyPrompt onAuthenticated={() => setIsAuthenticated(true)} />;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<QueryClientProvider client={queryClient}>
|
|
79
|
-
<BrowserRouter>
|
|
80
|
-
<AppContent onLogout={() => setIsAuthenticated(false)} />
|
|
81
|
-
</BrowserRouter>
|
|
82
|
-
</QueryClientProvider>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export default App;
|
package/web/src/assets/react.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { api } from '../lib/api';
|
|
3
|
-
|
|
4
|
-
interface ApiKeyPromptProps {
|
|
5
|
-
onAuthenticated: () => void;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function ApiKeyPrompt({ onAuthenticated }: ApiKeyPromptProps) {
|
|
9
|
-
const [apiKey, setApiKey] = useState('');
|
|
10
|
-
const [error, setError] = useState('');
|
|
11
|
-
const [loading, setLoading] = useState(false);
|
|
12
|
-
|
|
13
|
-
const handleSubmit = async (e: React.FormEvent) => {
|
|
14
|
-
e.preventDefault();
|
|
15
|
-
setError('');
|
|
16
|
-
setLoading(true);
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
api.setApiKey(apiKey);
|
|
20
|
-
await api.getSystemStatus();
|
|
21
|
-
onAuthenticated();
|
|
22
|
-
} catch {
|
|
23
|
-
setError('Invalid API key');
|
|
24
|
-
api.clearApiKey();
|
|
25
|
-
} finally {
|
|
26
|
-
setLoading(false);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="min-h-screen bg-white flex items-center justify-center p-4">
|
|
32
|
-
<div className="w-full max-w-sm">
|
|
33
|
-
<div className="text-center mb-8">
|
|
34
|
-
<svg className="w-12 h-12 mx-auto mb-4" viewBox="0 0 24 24" fill="none">
|
|
35
|
-
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z" fill="currentColor"/>
|
|
36
|
-
</svg>
|
|
37
|
-
<h1 className="text-xl font-medium text-gray-900">llama.cpp Admin</h1>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
<form onSubmit={handleSubmit} className="space-y-4">
|
|
41
|
-
<div>
|
|
42
|
-
<input
|
|
43
|
-
type="password"
|
|
44
|
-
value={apiKey}
|
|
45
|
-
onChange={(e) => setApiKey(e.target.value)}
|
|
46
|
-
placeholder="Enter API key"
|
|
47
|
-
className="w-full px-4 py-2.5 text-sm border border-gray-200 rounded-lg bg-gray-50 focus:bg-white focus:outline-none focus:ring-2 focus:ring-gray-200 focus:border-transparent"
|
|
48
|
-
autoFocus
|
|
49
|
-
/>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
{error && (
|
|
53
|
-
<p className="text-sm text-red-600">{error}</p>
|
|
54
|
-
)}
|
|
55
|
-
|
|
56
|
-
<button
|
|
57
|
-
type="submit"
|
|
58
|
-
disabled={loading || !apiKey}
|
|
59
|
-
className="w-full py-2.5 px-4 bg-gray-900 hover:bg-gray-800 disabled:bg-gray-300 text-white text-sm font-medium rounded-lg transition-colors cursor-pointer disabled:cursor-not-allowed"
|
|
60
|
-
>
|
|
61
|
-
{loading ? 'Connecting...' : 'Connect'}
|
|
62
|
-
</button>
|
|
63
|
-
</form>
|
|
64
|
-
|
|
65
|
-
<p className="mt-6 text-center text-xs text-gray-500">
|
|
66
|
-
Run <code className="bg-gray-100 px-1.5 py-0.5 rounded text-gray-600">llamacpp admin status</code> to get your API key
|
|
67
|
-
</p>
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import { X, Loader2, Plus, HardDrive, AlertCircle } from 'lucide-react';
|
|
3
|
-
import { useCreateServer, useModels } from '../hooks/useApi';
|
|
4
|
-
|
|
5
|
-
interface CreateServerModalProps {
|
|
6
|
-
isOpen: boolean;
|
|
7
|
-
onClose: () => void;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface FormData {
|
|
11
|
-
model: string;
|
|
12
|
-
port: string; // Empty string means auto-assign
|
|
13
|
-
host: string;
|
|
14
|
-
threads: number;
|
|
15
|
-
ctxSize: number;
|
|
16
|
-
gpuLayers: number;
|
|
17
|
-
verbose: boolean;
|
|
18
|
-
customFlags: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Smart defaults based on model size (matching CLI behavior)
|
|
22
|
-
function getSmartDefaults(modelSize: number): { threads: number; ctxSize: number; gpuLayers: number } {
|
|
23
|
-
const cpuCores = navigator.hardwareConcurrency || 8;
|
|
24
|
-
const threads = Math.max(1, Math.floor(cpuCores / 2));
|
|
25
|
-
|
|
26
|
-
let ctxSize: number;
|
|
27
|
-
if (modelSize < 1e9) {
|
|
28
|
-
ctxSize = 2048;
|
|
29
|
-
} else if (modelSize < 3e9) {
|
|
30
|
-
ctxSize = 4096;
|
|
31
|
-
} else if (modelSize < 6e9) {
|
|
32
|
-
ctxSize = 8192;
|
|
33
|
-
} else {
|
|
34
|
-
ctxSize = 16384;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
threads,
|
|
39
|
-
ctxSize,
|
|
40
|
-
gpuLayers: 60, // Metal auto-detects optimal
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function CreateServerModal({ isOpen, onClose }: CreateServerModalProps) {
|
|
45
|
-
const createServer = useCreateServer();
|
|
46
|
-
const { data: modelsData, isLoading: modelsLoading } = useModels();
|
|
47
|
-
|
|
48
|
-
const [formData, setFormData] = useState<FormData>({
|
|
49
|
-
model: '',
|
|
50
|
-
port: '',
|
|
51
|
-
host: '127.0.0.1',
|
|
52
|
-
threads: 4,
|
|
53
|
-
ctxSize: 4096,
|
|
54
|
-
gpuLayers: 60,
|
|
55
|
-
verbose: false,
|
|
56
|
-
customFlags: '',
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const [error, setError] = useState<string | null>(null);
|
|
60
|
-
|
|
61
|
-
const models = modelsData?.models || [];
|
|
62
|
-
|
|
63
|
-
// Reset form when modal opens
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (isOpen) {
|
|
66
|
-
setFormData({
|
|
67
|
-
model: '',
|
|
68
|
-
port: '',
|
|
69
|
-
host: '127.0.0.1',
|
|
70
|
-
threads: 4,
|
|
71
|
-
ctxSize: 4096,
|
|
72
|
-
gpuLayers: 60,
|
|
73
|
-
verbose: false,
|
|
74
|
-
customFlags: '',
|
|
75
|
-
});
|
|
76
|
-
setError(null);
|
|
77
|
-
}
|
|
78
|
-
}, [isOpen]);
|
|
79
|
-
|
|
80
|
-
// Update defaults when model changes
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
if (formData.model) {
|
|
83
|
-
const selectedModel = models.find(m => m.filename === formData.model);
|
|
84
|
-
if (selectedModel) {
|
|
85
|
-
const defaults = getSmartDefaults(selectedModel.size);
|
|
86
|
-
setFormData(prev => ({
|
|
87
|
-
...prev,
|
|
88
|
-
threads: defaults.threads,
|
|
89
|
-
ctxSize: defaults.ctxSize,
|
|
90
|
-
gpuLayers: defaults.gpuLayers,
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}, [formData.model, models]);
|
|
95
|
-
|
|
96
|
-
const handleSubmit = async (e: React.FormEvent) => {
|
|
97
|
-
e.preventDefault();
|
|
98
|
-
if (!formData.model) {
|
|
99
|
-
setError('Please select a model');
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
setError(null);
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
const customFlags = formData.customFlags
|
|
107
|
-
.split(',')
|
|
108
|
-
.map(f => f.trim())
|
|
109
|
-
.filter(f => f.length > 0);
|
|
110
|
-
|
|
111
|
-
await createServer.mutateAsync({
|
|
112
|
-
model: formData.model,
|
|
113
|
-
port: formData.port ? parseInt(formData.port) : undefined,
|
|
114
|
-
host: formData.host,
|
|
115
|
-
threads: formData.threads,
|
|
116
|
-
ctxSize: formData.ctxSize,
|
|
117
|
-
gpuLayers: formData.gpuLayers,
|
|
118
|
-
verbose: formData.verbose,
|
|
119
|
-
customFlags: customFlags.length > 0 ? customFlags : undefined,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
onClose();
|
|
123
|
-
} catch (err) {
|
|
124
|
-
setError((err as Error).message);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const formatSize = (bytes: number) => {
|
|
129
|
-
if (bytes >= 1e9) return `${(bytes / 1e9).toFixed(1)} GB`;
|
|
130
|
-
if (bytes >= 1e6) return `${(bytes / 1e6).toFixed(1)} MB`;
|
|
131
|
-
return `${(bytes / 1e3).toFixed(1)} KB`;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const formatContextSize = (size: number) => {
|
|
135
|
-
if (size >= 1048576) return `${(size / 1048576).toFixed(1)}M tokens`;
|
|
136
|
-
if (size >= 1024) return `${(size / 1024).toFixed(0)}K tokens`;
|
|
137
|
-
return `${size} tokens`;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const selectedModel = models.find(m => m.filename === formData.model);
|
|
141
|
-
|
|
142
|
-
if (!isOpen) return null;
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
|
|
146
|
-
<div className="bg-white rounded-xl shadow-xl w-full max-w-lg mx-4 max-h-[90vh] flex flex-col">
|
|
147
|
-
{/* Header */}
|
|
148
|
-
<div className="flex items-center justify-between px-4 py-3 border-b border-gray-200">
|
|
149
|
-
<h2 className="text-lg font-semibold text-gray-900">Create Server</h2>
|
|
150
|
-
<button
|
|
151
|
-
onClick={onClose}
|
|
152
|
-
className="p-1 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
|
153
|
-
>
|
|
154
|
-
<X className="w-5 h-5" />
|
|
155
|
-
</button>
|
|
156
|
-
</div>
|
|
157
|
-
|
|
158
|
-
{/* Form */}
|
|
159
|
-
<form onSubmit={handleSubmit} className="flex-1 overflow-y-auto p-4 space-y-4">
|
|
160
|
-
{/* Model Selection */}
|
|
161
|
-
<div>
|
|
162
|
-
<label className="block text-sm font-medium text-gray-700 mb-2">
|
|
163
|
-
Model
|
|
164
|
-
</label>
|
|
165
|
-
{modelsLoading ? (
|
|
166
|
-
<div className="flex items-center justify-center py-4">
|
|
167
|
-
<Loader2 className="w-5 h-5 animate-spin text-gray-400" />
|
|
168
|
-
</div>
|
|
169
|
-
) : models.length === 0 ? (
|
|
170
|
-
<div className="text-center py-4 text-sm text-gray-500">
|
|
171
|
-
No models available. Download a model first.
|
|
172
|
-
</div>
|
|
173
|
-
) : (
|
|
174
|
-
<div className="space-y-1 max-h-48 overflow-y-auto border border-gray-200 rounded-lg">
|
|
175
|
-
{models.map((model) => {
|
|
176
|
-
const hasServer = model.serversUsing > 0;
|
|
177
|
-
return (
|
|
178
|
-
<button
|
|
179
|
-
key={model.filename}
|
|
180
|
-
type="button"
|
|
181
|
-
onClick={() => !hasServer && setFormData({ ...formData, model: model.filename })}
|
|
182
|
-
disabled={hasServer}
|
|
183
|
-
className={`w-full text-left px-3 py-2 transition-colors ${
|
|
184
|
-
formData.model === model.filename
|
|
185
|
-
? 'bg-gray-100 cursor-pointer'
|
|
186
|
-
: hasServer
|
|
187
|
-
? 'bg-gray-50 opacity-50 cursor-not-allowed'
|
|
188
|
-
: 'hover:bg-gray-50 cursor-pointer'
|
|
189
|
-
}`}
|
|
190
|
-
>
|
|
191
|
-
<div className="flex items-center justify-between">
|
|
192
|
-
<div className="flex items-center gap-2 flex-1 min-w-0">
|
|
193
|
-
<HardDrive className="w-4 h-4 text-gray-400 flex-shrink-0" />
|
|
194
|
-
<span className="text-sm text-gray-900 truncate">
|
|
195
|
-
{model.filename.replace('.gguf', '')}
|
|
196
|
-
</span>
|
|
197
|
-
</div>
|
|
198
|
-
<div className="flex items-center gap-2 ml-2">
|
|
199
|
-
<span className="text-xs text-gray-500">{formatSize(model.size)}</span>
|
|
200
|
-
{hasServer && (
|
|
201
|
-
<span className="text-xs text-orange-600">in use</span>
|
|
202
|
-
)}
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
</button>
|
|
206
|
-
);
|
|
207
|
-
})}
|
|
208
|
-
</div>
|
|
209
|
-
)}
|
|
210
|
-
{selectedModel && (
|
|
211
|
-
<p className="text-xs text-gray-500 mt-1">
|
|
212
|
-
{formatSize(selectedModel.size)} · Smart defaults applied
|
|
213
|
-
</p>
|
|
214
|
-
)}
|
|
215
|
-
</div>
|
|
216
|
-
|
|
217
|
-
{/* Port */}
|
|
218
|
-
<div>
|
|
219
|
-
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
220
|
-
Port
|
|
221
|
-
</label>
|
|
222
|
-
<input
|
|
223
|
-
type="number"
|
|
224
|
-
value={formData.port}
|
|
225
|
-
onChange={(e) => setFormData({ ...formData, port: e.target.value })}
|
|
226
|
-
placeholder="Auto-assign (9000-9999)"
|
|
227
|
-
min={1024}
|
|
228
|
-
max={65535}
|
|
229
|
-
className="w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-200 focus:border-transparent"
|
|
230
|
-
/>
|
|
231
|
-
<p className="text-xs text-gray-500 mt-1">Leave empty to auto-assign</p>
|
|
232
|
-
</div>
|
|
233
|
-
|
|
234
|
-
{/* Host */}
|
|
235
|
-
<div>
|
|
236
|
-
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
237
|
-
Host
|
|
238
|
-
</label>
|
|
239
|
-
<select
|
|
240
|
-
value={formData.host}
|
|
241
|
-
onChange={(e) => setFormData({ ...formData, host: e.target.value })}
|
|
242
|
-
className="w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-200 focus:border-transparent bg-white"
|
|
243
|
-
>
|
|
244
|
-
<option value="127.0.0.1">127.0.0.1 (localhost only)</option>
|
|
245
|
-
<option value="0.0.0.0">0.0.0.0 (all interfaces)</option>
|
|
246
|
-
</select>
|
|
247
|
-
</div>
|
|
248
|
-
|
|
249
|
-
{/* Threads */}
|
|
250
|
-
<div>
|
|
251
|
-
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
252
|
-
Threads
|
|
253
|
-
</label>
|
|
254
|
-
<input
|
|
255
|
-
type="number"
|
|
256
|
-
value={formData.threads}
|
|
257
|
-
onChange={(e) => setFormData({ ...formData, threads: parseInt(e.target.value) || 1 })}
|
|
258
|
-
min={1}
|
|
259
|
-
max={256}
|
|
260
|
-
className="w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-200 focus:border-transparent"
|
|
261
|
-
/>
|
|
262
|
-
</div>
|
|
263
|
-
|
|
264
|
-
{/* Context Size */}
|
|
265
|
-
<div>
|
|
266
|
-
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
267
|
-
Context Size
|
|
268
|
-
</label>
|
|
269
|
-
<input
|
|
270
|
-
type="number"
|
|
271
|
-
value={formData.ctxSize}
|
|
272
|
-
onChange={(e) => setFormData({ ...formData, ctxSize: parseInt(e.target.value) || 2048 })}
|
|
273
|
-
min={512}
|
|
274
|
-
max={2097152}
|
|
275
|
-
step={512}
|
|
276
|
-
className="w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-200 focus:border-transparent"
|
|
277
|
-
/>
|
|
278
|
-
<p className="text-xs text-gray-500 mt-1">{formatContextSize(formData.ctxSize)}</p>
|
|
279
|
-
</div>
|
|
280
|
-
|
|
281
|
-
{/* GPU Layers */}
|
|
282
|
-
<div>
|
|
283
|
-
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
284
|
-
GPU Layers
|
|
285
|
-
</label>
|
|
286
|
-
<input
|
|
287
|
-
type="number"
|
|
288
|
-
value={formData.gpuLayers}
|
|
289
|
-
onChange={(e) => setFormData({ ...formData, gpuLayers: parseInt(e.target.value) || 0 })}
|
|
290
|
-
min={0}
|
|
291
|
-
max={999}
|
|
292
|
-
className="w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-200 focus:border-transparent"
|
|
293
|
-
/>
|
|
294
|
-
<p className="text-xs text-gray-500 mt-1">Layers to offload to GPU (0 = CPU only)</p>
|
|
295
|
-
</div>
|
|
296
|
-
|
|
297
|
-
{/* Verbose */}
|
|
298
|
-
<div className="flex items-center justify-between">
|
|
299
|
-
<div>
|
|
300
|
-
<label className="text-sm font-medium text-gray-700">Verbose Logging</label>
|
|
301
|
-
<p className="text-xs text-gray-500">Log HTTP requests and responses</p>
|
|
302
|
-
</div>
|
|
303
|
-
<button
|
|
304
|
-
type="button"
|
|
305
|
-
onClick={() => setFormData({ ...formData, verbose: !formData.verbose })}
|
|
306
|
-
className={`relative w-11 h-6 rounded-full transition-colors cursor-pointer ${
|
|
307
|
-
formData.verbose ? 'bg-gray-900' : 'bg-gray-200'
|
|
308
|
-
}`}
|
|
309
|
-
>
|
|
310
|
-
<span
|
|
311
|
-
className={`absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform ${
|
|
312
|
-
formData.verbose ? 'translate-x-5' : ''
|
|
313
|
-
}`}
|
|
314
|
-
/>
|
|
315
|
-
</button>
|
|
316
|
-
</div>
|
|
317
|
-
|
|
318
|
-
{/* Custom Flags */}
|
|
319
|
-
<div>
|
|
320
|
-
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
321
|
-
Custom Flags
|
|
322
|
-
</label>
|
|
323
|
-
<input
|
|
324
|
-
type="text"
|
|
325
|
-
value={formData.customFlags}
|
|
326
|
-
onChange={(e) => setFormData({ ...formData, customFlags: e.target.value })}
|
|
327
|
-
placeholder="--flash-attn, --cont-batching"
|
|
328
|
-
className="w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-200 focus:border-transparent"
|
|
329
|
-
/>
|
|
330
|
-
<p className="text-xs text-gray-500 mt-1">Comma-separated additional flags</p>
|
|
331
|
-
</div>
|
|
332
|
-
|
|
333
|
-
{/* Error */}
|
|
334
|
-
{error && (
|
|
335
|
-
<div className="flex items-start gap-2 p-3 bg-red-50 border border-red-200 rounded-lg">
|
|
336
|
-
<AlertCircle className="w-4 h-4 text-red-500 flex-shrink-0 mt-0.5" />
|
|
337
|
-
<p className="text-sm text-red-700">{error}</p>
|
|
338
|
-
</div>
|
|
339
|
-
)}
|
|
340
|
-
</form>
|
|
341
|
-
|
|
342
|
-
{/* Footer */}
|
|
343
|
-
<div className="flex items-center justify-end gap-2 px-4 py-3 border-t border-gray-200 bg-gray-50 rounded-b-xl">
|
|
344
|
-
<button
|
|
345
|
-
type="button"
|
|
346
|
-
onClick={onClose}
|
|
347
|
-
className="px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 rounded-lg transition-colors cursor-pointer"
|
|
348
|
-
>
|
|
349
|
-
Cancel
|
|
350
|
-
</button>
|
|
351
|
-
<button
|
|
352
|
-
onClick={handleSubmit}
|
|
353
|
-
disabled={createServer.isPending || !formData.model}
|
|
354
|
-
className="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-gray-900 hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed"
|
|
355
|
-
>
|
|
356
|
-
{createServer.isPending ? (
|
|
357
|
-
<>
|
|
358
|
-
<Loader2 className="w-4 h-4 animate-spin" />
|
|
359
|
-
Creating...
|
|
360
|
-
</>
|
|
361
|
-
) : (
|
|
362
|
-
<>
|
|
363
|
-
<Plus className="w-4 h-4" />
|
|
364
|
-
Create Server
|
|
365
|
-
</>
|
|
366
|
-
)}
|
|
367
|
-
</button>
|
|
368
|
-
</div>
|
|
369
|
-
</div>
|
|
370
|
-
</div>
|
|
371
|
-
);
|
|
372
|
-
}
|