Skip to content

Commit

Permalink
Merge pull request #1698 from janhq/j/update-engine-api
Browse files Browse the repository at this point in the history
chore: update engine API
  • Loading branch information
namchuai authored Nov 22, 2024
2 parents afe556d + 26761a8 commit 16e7c00
Show file tree
Hide file tree
Showing 12 changed files with 415 additions and 344 deletions.
306 changes: 209 additions & 97 deletions docs/static/openapi/cortex.json
Original file line number Diff line number Diff line change
Expand Up @@ -1234,9 +1234,9 @@
},
"/v1/engines/{name}": {
"get": {
"operationId": "EnginesController_findOne",
"summary": "Get an engine",
"description": "Retrieves an engine instance, providing basic information about the engine.",
"operationId": "EnginesController_listInstalledEngines",
"summary": "List installed engines",
"description": "List installed engines for a particular engine type.",
"parameters": [
{
"name": "name",
Expand Down Expand Up @@ -1292,10 +1292,12 @@
}
},
"tags": ["Engines"]
},
"post": {
"summary": "Install an engine",
"description": "Install an engine of a specific type, with optional version and variant",
}
},
"/v1/engines/{name}/releases": {
"get": {
"summary": "List released engines",
"description": "List released engines of a specific engine type.",
"parameters": [
{
"name": "name",
Expand All @@ -1307,32 +1309,156 @@
"default": "llama-cpp"
},
"description": "The type of engine"
},
}
],
"responses": {
"200": {
"description": "Successful installation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"draft": {
"type": "boolean",
"example": false
},
"name": {
"type": "string",
"example": "v0.1.39-20.11.24"
},
"prerelease": {
"type": "boolean",
"example": true
},
"published_at": {
"type": "string",
"format": "date-time",
"example": "2024-11-20T17:39:40Z"
},
"url": {
"type": "string",
"example": "https://api.github.com/repos/janhq/cortex.llamacpp/releases/186479804"
}
}
}
}
}
}
}
},
"tags": ["Engines"]
}
},
"/v1/engines/{name}/releases/latest": {
"get": {
"summary": "Get latest release",
"description": "Return variants for the latest engine release of a specific engine type.",
"parameters": [
{
"name": "version",
"in": "query",
"required": false,
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string"
"type": "string",
"enum": ["llama-cpp", "onnxruntime", "tensorrt-llm"],
"default": "llama-cpp"
},
"description": "The version of the engine to install (optional)"
},
"description": "The type of engine"
}
],
"responses": {
"200": {
"description": "Successful installation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time",
"example": "2024-11-15T10:39:39Z"
},
"download_count": {
"type": "integer",
"example": 76
},
"name": {
"type": "string",
"example": "0.1.39-linux-amd64-avx-cuda-11-7"
},
"size": {
"type": "integer",
"example": 151215080
}
}
}
}
}
}
}
},
"tags": ["Engines"]
}
},
"/v1/engines/{name}/install": {
"post": {
"summary": "Install an engine",
"description": "Install an engine of a specific type, with optional version and variant. If none are provided, the latest version and most suitable variant will be installed.",
"parameters": [
{
"name": "variant",
"in": "query",
"required": false,
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string"
"type": "string",
"enum": ["llama-cpp", "onnxruntime", "tensorrt-llm"],
"default": "llama-cpp"
},
"description": "The variant of the engine to install (optional)"
"description": "The type of engine"
}
],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"version": {
"type": "string",
"description": "The version of the engine to install (optional)",
"example": "v0.1.39"
},
"variant": {
"type": "string",
"description": "The variant of the engine to install (optional)",
"example": "mac-arm64"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Successful installation",
"content": {
"application/json": {
"schema": {}
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Engine starts installing!"
}
}
}
}
}
}
Expand All @@ -1341,7 +1467,7 @@
},
"delete": {
"summary": "Uninstall an engine",
"description": "Uninstall an engine based on type, version, and variant",
"description": "Uninstall an engine based on engine, version, and variant. If version and variant are not provided, all versions and variants of the engine will be uninstalled.",
"parameters": [
{
"name": "name",
Expand All @@ -1353,26 +1479,30 @@
"default": "llama-cpp"
},
"description": "The type of engine"
},
{
"name": "version",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "The version of the engine to uninstall (optional)"
},
{
"name": "variant",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "The variant of the engine to uninstall (optional)"
}
],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"version": {
"type": "string",
"description": "The version of the engine to uninstall (optional)",
"example": "v0.1.39"
},
"variant": {
"type": "string",
"description": "The variant of the engine to uninstall (optional)",
"example": "mac-arm64"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Successful uninstallation",
Expand All @@ -1381,28 +1511,10 @@
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean",
"description": "Indicates if the uninstallation was successful"
},
"message": {
"type": "string",
"description": "Description of the uninstallation action taken"
},
"uninstalledEngines": {
"type": "array",
"items": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"variant": {
"type": "string"
}
}
},
"description": "List of uninstalled engine versions and variants"
"description": "Engine llama-cpp uninstalled successfully!",
"example": "Engine llama-cpp uninstalled successfully!"
}
}
}
Expand All @@ -1429,6 +1541,44 @@
"tags": ["Engines"]
}
},
"/v1/engines/{name}/update": {
"post": {
"summary": "Update engine",
"description": "Updates the specified engine type using the engine variant currently set as default.",
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string",
"enum": ["llama-cpp", "onnxruntime", "tensorrt-llm"],
"default": "llama-cpp"
},
"description": "The name of the engine to update"
}
],
"responses": {
"200": {
"description": "Engine updated successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Engine updated successfully"
}
}
}
}
}
}
},
"tags": ["Engines"]
}
},
"/v1/engines/{name}/default": {
"get": {
"summary": "Get default engine variant",
Expand Down Expand Up @@ -1603,44 +1753,6 @@
"tags": ["Engines"]
}
},
"/v1/engines/{name}/update": {
"post": {
"summary": "Update engine",
"description": "Updates the specified engine type using the engine variant currently set as default.",
"parameters": [
{
"name": "name",
"in": "path",
"required": true,
"schema": {
"type": "string",
"enum": ["llama-cpp", "onnxruntime", "tensorrt-llm"],
"default": "llama-cpp"
},
"description": "The name of the engine to update"
}
],
"responses": {
"200": {
"description": "Engine updated successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Engine updated successfully"
}
}
}
}
}
}
},
"tags": ["Engines"]
}
},
"/v1/hardware": {
"get": {
"summary": "Get hardware information",
Expand Down
2 changes: 1 addition & 1 deletion engine/cli/commands/engine_get_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <json/reader.h>
#include <json/value.h>
#include <iostream>
#include "common/engine_servicei.h"
#include "server_start_cmd.h"
#include "services/engine_service.h"
#include "utils/curl_utils.h"
#include "utils/logging_utils.h"
#include "utils/url_parser.h"
Expand Down
Loading

0 comments on commit 16e7c00

Please sign in to comment.