mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Refactor API endpoints to use /backends/llama-cpp path and update related documentation
This commit is contained in:
168
apidocs/docs.go
168
apidocs/docs.go
@@ -19,6 +19,62 @@ const docTemplate = `{
|
|||||||
"host": "{{.Host}}",
|
"host": "{{.Host}}",
|
||||||
"basePath": "{{.BasePath}}",
|
"basePath": "{{.BasePath}}",
|
||||||
"paths": {
|
"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": {
|
"/backends/llama-cpp/parse-command": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"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": {
|
"/backends/mlx/parse-command": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"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/": {
|
"/v1/": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|||||||
@@ -12,6 +12,62 @@
|
|||||||
},
|
},
|
||||||
"basePath": "/api/v1",
|
"basePath": "/api/v1",
|
||||||
"paths": {
|
"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": {
|
"/backends/llama-cpp/parse-command": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"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": {
|
"/backends/mlx/parse-command": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"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/": {
|
"/v1/": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
|
|||||||
@@ -88,6 +88,40 @@ info:
|
|||||||
title: llamactl API
|
title: llamactl API
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
paths:
|
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:
|
/backends/llama-cpp/parse-command:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@@ -124,6 +158,23 @@ paths:
|
|||||||
summary: Parse llama-server command
|
summary: Parse llama-server command
|
||||||
tags:
|
tags:
|
||||||
- backends
|
- 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:
|
/backends/mlx/parse-command:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@@ -494,57 +545,6 @@ paths:
|
|||||||
summary: Stop a running instance
|
summary: Stop a running instance
|
||||||
tags:
|
tags:
|
||||||
- instances
|
- 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/:
|
/v1/:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ func (h *Handler) VersionHandler() http.HandlerFunc {
|
|||||||
// LlamaServerHelpHandler godoc
|
// LlamaServerHelpHandler godoc
|
||||||
// @Summary Get help for llama server
|
// @Summary Get help for llama server
|
||||||
// @Description Returns the help text for the llama server command
|
// @Description Returns the help text for the llama server command
|
||||||
// @Tags server
|
// @Tags backends
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Produces text/plain
|
// @Produces text/plain
|
||||||
// @Success 200 {string} string "Help text"
|
// @Success 200 {string} string "Help text"
|
||||||
// @Failure 500 {string} string "Internal Server Error"
|
// @Failure 500 {string} string "Internal Server Error"
|
||||||
// @Router /server/help [get]
|
// @Router /backends/llama-cpp/help [get]
|
||||||
func (h *Handler) LlamaServerHelpHandler() http.HandlerFunc {
|
func (h *Handler) LlamaServerHelpHandler() http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
helpCmd := exec.Command("llama-server", "--help")
|
helpCmd := exec.Command("llama-server", "--help")
|
||||||
@@ -73,12 +73,12 @@ func (h *Handler) LlamaServerHelpHandler() http.HandlerFunc {
|
|||||||
// LlamaServerVersionHandler godoc
|
// LlamaServerVersionHandler godoc
|
||||||
// @Summary Get version of llama server
|
// @Summary Get version of llama server
|
||||||
// @Description Returns the version of the llama server command
|
// @Description Returns the version of the llama server command
|
||||||
// @Tags server
|
// @Tags backends
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Produces text/plain
|
// @Produces text/plain
|
||||||
// @Success 200 {string} string "Version information"
|
// @Success 200 {string} string "Version information"
|
||||||
// @Failure 500 {string} string "Internal Server Error"
|
// @Failure 500 {string} string "Internal Server Error"
|
||||||
// @Router /server/version [get]
|
// @Router /backends/llama-cpp/version [get]
|
||||||
func (h *Handler) LlamaServerVersionHandler() http.HandlerFunc {
|
func (h *Handler) LlamaServerVersionHandler() http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
versionCmd := exec.Command("llama-server", "--version")
|
versionCmd := exec.Command("llama-server", "--version")
|
||||||
@@ -95,12 +95,12 @@ func (h *Handler) LlamaServerVersionHandler() http.HandlerFunc {
|
|||||||
// LlamaServerListDevicesHandler godoc
|
// LlamaServerListDevicesHandler godoc
|
||||||
// @Summary List available devices for llama server
|
// @Summary List available devices for llama server
|
||||||
// @Description Returns a list of available devices for the llama server
|
// @Description Returns a list of available devices for the llama server
|
||||||
// @Tags server
|
// @Tags backends
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Produces text/plain
|
// @Produces text/plain
|
||||||
// @Success 200 {string} string "List of devices"
|
// @Success 200 {string} string "List of devices"
|
||||||
// @Failure 500 {string} string "Internal Server Error"
|
// @Failure 500 {string} string "Internal Server Error"
|
||||||
// @Router /server/devices [get]
|
// @Router /backends/llama-cpp/devices [get]
|
||||||
func (h *Handler) LlamaServerListDevicesHandler() http.HandlerFunc {
|
func (h *Handler) LlamaServerListDevicesHandler() http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
listCmd := exec.Command("llama-server", "--list-devices")
|
listCmd := exec.Command("llama-server", "--list-devices")
|
||||||
|
|||||||
@@ -44,15 +44,12 @@ func SetupRouter(handler *Handler) *chi.Mux {
|
|||||||
|
|
||||||
r.Get("/version", handler.VersionHandler()) // Get server version
|
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
|
// Backend-specific endpoints
|
||||||
r.Route("/backends", func(r chi.Router) {
|
r.Route("/backends", func(r chi.Router) {
|
||||||
r.Route("/llama-cpp", 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.Post("/parse-command", handler.ParseLlamaCommand())
|
||||||
})
|
})
|
||||||
r.Route("/mlx", func(r chi.Router) {
|
r.Route("/mlx", func(r chi.Router) {
|
||||||
|
|||||||
Reference in New Issue
Block a user