diff --git a/apidocs/docs.go b/apidocs/docs.go index d5108e1..4b521b1 100644 --- a/apidocs/docs.go +++ b/apidocs/docs.go @@ -19,6 +19,62 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/backends/llama-cpp/devices": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Returns a list of available devices for the llama server", + "tags": [ + "backends" + ], + "summary": "List available devices for llama server", + "responses": { + "200": { + "description": "List of devices", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "string" + } + } + } + } + }, + "/backends/llama-cpp/help": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Returns the help text for the llama server command", + "tags": [ + "backends" + ], + "summary": "Get help for llama server", + "responses": { + "200": { + "description": "Help text", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "string" + } + } + } + } + }, "/backends/llama-cpp/parse-command": { "post": { "security": [ @@ -76,6 +132,34 @@ const docTemplate = `{ } } }, + "/backends/llama-cpp/version": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Returns the version of the llama server command", + "tags": [ + "backends" + ], + "summary": "Get version of llama server", + "responses": { + "200": { + "description": "Version information", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "string" + } + } + } + } + }, "/backends/mlx/parse-command": { "post": { "security": [ @@ -658,90 +742,6 @@ const docTemplate = `{ } } }, - "/server/devices": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Returns a list of available devices for the llama server", - "tags": [ - "server" - ], - "summary": "List available devices for llama server", - "responses": { - "200": { - "description": "List of devices", - "schema": { - "type": "string" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "string" - } - } - } - } - }, - "/server/help": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Returns the help text for the llama server command", - "tags": [ - "server" - ], - "summary": "Get help for llama server", - "responses": { - "200": { - "description": "Help text", - "schema": { - "type": "string" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "string" - } - } - } - } - }, - "/server/version": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Returns the version of the llama server command", - "tags": [ - "server" - ], - "summary": "Get version of llama server", - "responses": { - "200": { - "description": "Version information", - "schema": { - "type": "string" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "string" - } - } - } - } - }, "/v1/": { "post": { "security": [ diff --git a/apidocs/swagger.json b/apidocs/swagger.json index 9648cc0..71471e6 100644 --- a/apidocs/swagger.json +++ b/apidocs/swagger.json @@ -12,6 +12,62 @@ }, "basePath": "/api/v1", "paths": { + "/backends/llama-cpp/devices": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Returns a list of available devices for the llama server", + "tags": [ + "backends" + ], + "summary": "List available devices for llama server", + "responses": { + "200": { + "description": "List of devices", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "string" + } + } + } + } + }, + "/backends/llama-cpp/help": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Returns the help text for the llama server command", + "tags": [ + "backends" + ], + "summary": "Get help for llama server", + "responses": { + "200": { + "description": "Help text", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "string" + } + } + } + } + }, "/backends/llama-cpp/parse-command": { "post": { "security": [ @@ -69,6 +125,34 @@ } } }, + "/backends/llama-cpp/version": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Returns the version of the llama server command", + "tags": [ + "backends" + ], + "summary": "Get version of llama server", + "responses": { + "200": { + "description": "Version information", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "string" + } + } + } + } + }, "/backends/mlx/parse-command": { "post": { "security": [ @@ -651,90 +735,6 @@ } } }, - "/server/devices": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Returns a list of available devices for the llama server", - "tags": [ - "server" - ], - "summary": "List available devices for llama server", - "responses": { - "200": { - "description": "List of devices", - "schema": { - "type": "string" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "string" - } - } - } - } - }, - "/server/help": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Returns the help text for the llama server command", - "tags": [ - "server" - ], - "summary": "Get help for llama server", - "responses": { - "200": { - "description": "Help text", - "schema": { - "type": "string" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "string" - } - } - } - } - }, - "/server/version": { - "get": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Returns the version of the llama server command", - "tags": [ - "server" - ], - "summary": "Get version of llama server", - "responses": { - "200": { - "description": "Version information", - "schema": { - "type": "string" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "type": "string" - } - } - } - } - }, "/v1/": { "post": { "security": [ diff --git a/apidocs/swagger.yaml b/apidocs/swagger.yaml index 4b68861..a5db184 100644 --- a/apidocs/swagger.yaml +++ b/apidocs/swagger.yaml @@ -88,6 +88,40 @@ info: title: llamactl API version: "1.0" paths: + /backends/llama-cpp/devices: + get: + description: Returns a list of available devices for the llama server + responses: + "200": + description: List of devices + schema: + type: string + "500": + description: Internal Server Error + schema: + type: string + security: + - ApiKeyAuth: [] + summary: List available devices for llama server + tags: + - backends + /backends/llama-cpp/help: + get: + description: Returns the help text for the llama server command + responses: + "200": + description: Help text + schema: + type: string + "500": + description: Internal Server Error + schema: + type: string + security: + - ApiKeyAuth: [] + summary: Get help for llama server + tags: + - backends /backends/llama-cpp/parse-command: post: consumes: @@ -124,6 +158,23 @@ paths: summary: Parse llama-server command tags: - backends + /backends/llama-cpp/version: + get: + description: Returns the version of the llama server command + responses: + "200": + description: Version information + schema: + type: string + "500": + description: Internal Server Error + schema: + type: string + security: + - ApiKeyAuth: [] + summary: Get version of llama server + tags: + - backends /backends/mlx/parse-command: post: consumes: @@ -494,57 +545,6 @@ paths: summary: Stop a running instance tags: - instances - /server/devices: - get: - description: Returns a list of available devices for the llama server - responses: - "200": - description: List of devices - schema: - type: string - "500": - description: Internal Server Error - schema: - type: string - security: - - ApiKeyAuth: [] - summary: List available devices for llama server - tags: - - server - /server/help: - get: - description: Returns the help text for the llama server command - responses: - "200": - description: Help text - schema: - type: string - "500": - description: Internal Server Error - schema: - type: string - security: - - ApiKeyAuth: [] - summary: Get help for llama server - tags: - - server - /server/version: - get: - description: Returns the version of the llama server command - responses: - "200": - description: Version information - schema: - type: string - "500": - description: Internal Server Error - schema: - type: string - security: - - ApiKeyAuth: [] - summary: Get version of llama server - tags: - - server /v1/: post: consumes: diff --git a/pkg/server/handlers.go b/pkg/server/handlers.go index d1c4d08..594c273 100644 --- a/pkg/server/handlers.go +++ b/pkg/server/handlers.go @@ -51,12 +51,12 @@ func (h *Handler) VersionHandler() http.HandlerFunc { // LlamaServerHelpHandler godoc // @Summary Get help for llama server // @Description Returns the help text for the llama server command -// @Tags server +// @Tags backends // @Security ApiKeyAuth // @Produces text/plain // @Success 200 {string} string "Help text" // @Failure 500 {string} string "Internal Server Error" -// @Router /server/help [get] +// @Router /backends/llama-cpp/help [get] func (h *Handler) LlamaServerHelpHandler() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { helpCmd := exec.Command("llama-server", "--help") @@ -73,12 +73,12 @@ func (h *Handler) LlamaServerHelpHandler() http.HandlerFunc { // LlamaServerVersionHandler godoc // @Summary Get version of llama server // @Description Returns the version of the llama server command -// @Tags server +// @Tags backends // @Security ApiKeyAuth // @Produces text/plain // @Success 200 {string} string "Version information" // @Failure 500 {string} string "Internal Server Error" -// @Router /server/version [get] +// @Router /backends/llama-cpp/version [get] func (h *Handler) LlamaServerVersionHandler() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { versionCmd := exec.Command("llama-server", "--version") @@ -95,12 +95,12 @@ func (h *Handler) LlamaServerVersionHandler() http.HandlerFunc { // LlamaServerListDevicesHandler godoc // @Summary List available devices for llama server // @Description Returns a list of available devices for the llama server -// @Tags server +// @Tags backends // @Security ApiKeyAuth // @Produces text/plain // @Success 200 {string} string "List of devices" // @Failure 500 {string} string "Internal Server Error" -// @Router /server/devices [get] +// @Router /backends/llama-cpp/devices [get] func (h *Handler) LlamaServerListDevicesHandler() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { listCmd := exec.Command("llama-server", "--list-devices") diff --git a/pkg/server/routes.go b/pkg/server/routes.go index 898b574..6af6a5c 100644 --- a/pkg/server/routes.go +++ b/pkg/server/routes.go @@ -44,15 +44,12 @@ func SetupRouter(handler *Handler) *chi.Mux { r.Get("/version", handler.VersionHandler()) // Get server version - r.Route("/server", func(r chi.Router) { - r.Get("/help", handler.LlamaServerHelpHandler()) - r.Get("/version", handler.LlamaServerVersionHandler()) - r.Get("/devices", handler.LlamaServerListDevicesHandler()) - }) - // Backend-specific endpoints r.Route("/backends", func(r chi.Router) { r.Route("/llama-cpp", func(r chi.Router) { + r.Get("/help", handler.LlamaServerHelpHandler()) + r.Get("/version", handler.LlamaServerVersionHandler()) + r.Get("/devices", handler.LlamaServerListDevicesHandler()) r.Post("/parse-command", handler.ParseLlamaCommand()) }) r.Route("/mlx", func(r chi.Router) { diff --git a/webui/src/components/ParseCommandDialog.tsx b/webui/src/components/ParseCommandDialog.tsx index 5043a57..ba5075d 100644 --- a/webui/src/components/ParseCommandDialog.tsx +++ b/webui/src/components/ParseCommandDialog.tsx @@ -105,9 +105,9 @@ const ParseCommandDialog: React.FC = ({
diff --git a/webui/src/components/SystemInfoDialog.tsx b/webui/src/components/SystemInfoDialog.tsx index 8eb03f5..f39d874 100644 --- a/webui/src/components/SystemInfoDialog.tsx +++ b/webui/src/components/SystemInfoDialog.tsx @@ -8,16 +8,19 @@ import { DialogHeader, DialogTitle, } from '@/components/ui/dialog' -import { - RefreshCw, +import SelectInput from '@/components/form/SelectInput' +import { + RefreshCw, AlertCircle, Loader2, ChevronDown, ChevronRight, Monitor, - HelpCircle + HelpCircle, + Info } from 'lucide-react' import { serverApi } from '@/lib/api' +import { BackendType, type BackendTypeValue } from '@/types/instance' // Helper to get version from environment const getAppVersion = (): string => { @@ -28,166 +31,234 @@ const getAppVersion = (): string => { } } -interface SystemInfoModalProps { +interface SystemInfoDialogProps { open: boolean onOpenChange: (open: boolean) => void } -interface SystemInfo { +interface BackendInfo { version: string devices: string help: string } -const SystemInfoDialog: React.FC = ({ +const BACKEND_OPTIONS = [ + { value: BackendType.LLAMA_CPP, label: 'Llama Server' }, + { value: BackendType.MLX_LM, label: 'MLX LM' }, + { value: BackendType.VLLM, label: 'vLLM' }, +] + +const SystemInfoDialog: React.FC = ({ open, onOpenChange }) => { - const [systemInfo, setSystemInfo] = useState(null) + const [selectedBackend, setSelectedBackend] = useState(BackendType.LLAMA_CPP) + const [backendInfo, setBackendInfo] = useState(null) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const [showHelp, setShowHelp] = useState(false) - // Fetch system info - const fetchSystemInfo = async () => { + // Fetch backend info + const fetchBackendInfo = async (backend: BackendTypeValue) => { + if (backend !== BackendType.LLAMA_CPP) { + setBackendInfo(null) + setError(null) + return + } + setLoading(true) setError(null) - + try { const [version, devices, help] = await Promise.all([ serverApi.getVersion(), serverApi.getDevices(), serverApi.getHelp() ]) - - setSystemInfo({ version, devices, help }) + + setBackendInfo({ version, devices, help }) } catch (err) { - setError(err instanceof Error ? err.message : 'Failed to fetch system info') + setError(err instanceof Error ? err.message : 'Failed to fetch backend info') } finally { setLoading(false) } } - // Load data when dialog opens + // Load data when dialog opens or backend changes useEffect(() => { if (open) { - fetchSystemInfo() + void fetchBackendInfo(selectedBackend) } - }, [open]) + }, [open, selectedBackend]) + + const handleBackendChange = (value: string) => { + setSelectedBackend(value as BackendTypeValue) + setShowHelp(false) // Reset help section when switching backends + } + + const renderBackendSpecificContent = () => { + if (selectedBackend !== BackendType.LLAMA_CPP) { + return ( +
+
+ +
+

Backend Info Not Available

+

+ Information for {BACKEND_OPTIONS.find(b => b.value === selectedBackend)?.label} backend is not yet implemented. +

+
+
+
+ ) + } + + if (loading && !backendInfo) { + return ( +
+ + Loading backend information... +
+ ) + } + + if (error) { + return ( +
+ + {error} +
+ ) + } + + if (!backendInfo) { + return null + } + + return ( +
+ {/* Backend Version Section */} +
+

+ {BACKEND_OPTIONS.find(b => b.value === selectedBackend)?.label} Version +

+ +
+
+ $ llama-server --version +
+
+              {backendInfo.version}
+            
+
+
+ + {/* Devices Section */} +
+
+

Available Devices

+
+ +
+
+ $ llama-server --list-devices +
+
+              {backendInfo.devices}
+            
+
+
+ + {/* Help Section */} +
+ + + {showHelp && ( +
+
+ $ llama-server --help +
+
+                {backendInfo.help}
+              
+
+ )} +
+
+ ) + } return ( - + -
-
- - - System Information - - - Llama.cpp server environment and capabilities - -
- - -
+ + + System Information + + + View system and backend-specific environment and capabilities +
- {loading && !systemInfo ? ( -
- - Loading system information... +
+ {/* Llamactl Version Section - Always shown */} +
+

Llamactl Version

+
+
+                  {getAppVersion()}
+                
+
- ) : error ? ( -
- - {error} -
- ) : systemInfo ? ( -
- {/* Llamactl Version Section */} -
-

Llamactl Version

- -
-
-                    {getAppVersion()}
-                  
-
-
- {/* Llama Server Version Section */} -
-

Llama Server Version

- -
-
- $ llama-server --version -
-
-                    {systemInfo.version}
-                  
+ {/* Backend Selection Section */} +
+

Backend Information

+
+
+ handleBackendChange(value || BackendType.LLAMA_CPP)} + options={BACKEND_OPTIONS} + className="text-sm" + />
-
- - {/* Devices Section */} -
-
-

Available Devices

-
- -
-
- $ llama-server --list-devices -
-
-                    {systemInfo.devices}
-                  
-
-
- - {/* Help Section */} -
- - - {showHelp && ( -
-
- $ llama-server --help -
-
-                      {systemInfo.help}
-                    
-
+ {selectedBackend === BackendType.LLAMA_CPP && ( + )}
- ) : null} + + {/* Backend-specific content */} + {renderBackendSpecificContent()} +
diff --git a/webui/src/components/instance/BackendConfigurationCard.tsx b/webui/src/components/instance/BackendConfigurationCard.tsx index 3e5e43f..5bf7c36 100644 --- a/webui/src/components/instance/BackendConfigurationCard.tsx +++ b/webui/src/components/instance/BackendConfigurationCard.tsx @@ -37,9 +37,9 @@ const BackendConfigurationCard: React.FC = ({ value={formData.backend_type || BackendType.LLAMA_CPP} onChange={(value) => onChange('backend_type', value)} options={[ - { value: BackendType.LLAMA_CPP, label: 'Llama Server (llama_cpp)' }, - { value: BackendType.MLX_LM, label: 'MLX LM (mlx_lm)' }, - { value: BackendType.VLLM, label: 'vLLM (vllm)' } + { value: BackendType.LLAMA_CPP, label: 'Llama Server' }, + { value: BackendType.MLX_LM, label: 'MLX LM' }, + { value: BackendType.VLLM, label: 'vLLM' } ]} description="Select the backend server type" /> diff --git a/webui/src/lib/api.ts b/webui/src/lib/api.ts index a170246..5bd7991 100644 --- a/webui/src/lib/api.ts +++ b/webui/src/lib/api.ts @@ -63,16 +63,16 @@ async function apiCall( } } -// Server API functions +// Server API functions (moved to llama-cpp backend) export const serverApi = { - // GET /server/help - getHelp: () => apiCall("/server/help", {}, "text"), + // GET /backends/llama-cpp/help + getHelp: () => apiCall("/backends/llama-cpp/help", {}, "text"), - // GET /server/version - getVersion: () => apiCall("/server/version", {}, "text"), + // GET /backends/llama-cpp/version + getVersion: () => apiCall("/backends/llama-cpp/version", {}, "text"), - // GET /server/devices - getDevices: () => apiCall("/server/devices", {}, "text"), + // GET /backends/llama-cpp/devices + getDevices: () => apiCall("/backends/llama-cpp/devices", {}, "text"), }; // Backend API functions @@ -156,5 +156,5 @@ export const instancesApi = { }, // GET /instances/{name}/proxy/health - getHealth: (name: string) => apiCall(`/instances/${name}/proxy/health`), + getHealth: (name: string) => apiCall>(`/instances/${name}/proxy/health`), };