Skip to content

Commit 16e7c00

Browse files
authored
Merge pull request janhq#1698 from janhq/j/update-engine-api
chore: update engine API
2 parents afe556d + 26761a8 commit 16e7c00

File tree

12 files changed

+415
-344
lines changed

12 files changed

+415
-344
lines changed

docs/static/openapi/cortex.json

Lines changed: 209 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,9 @@
12341234
},
12351235
"/v1/engines/{name}": {
12361236
"get": {
1237-
"operationId": "EnginesController_findOne",
1238-
"summary": "Get an engine",
1239-
"description": "Retrieves an engine instance, providing basic information about the engine.",
1237+
"operationId": "EnginesController_listInstalledEngines",
1238+
"summary": "List installed engines",
1239+
"description": "List installed engines for a particular engine type.",
12401240
"parameters": [
12411241
{
12421242
"name": "name",
@@ -1292,10 +1292,12 @@
12921292
}
12931293
},
12941294
"tags": ["Engines"]
1295-
},
1296-
"post": {
1297-
"summary": "Install an engine",
1298-
"description": "Install an engine of a specific type, with optional version and variant",
1295+
}
1296+
},
1297+
"/v1/engines/{name}/releases": {
1298+
"get": {
1299+
"summary": "List released engines",
1300+
"description": "List released engines of a specific engine type.",
12991301
"parameters": [
13001302
{
13011303
"name": "name",
@@ -1307,32 +1309,156 @@
13071309
"default": "llama-cpp"
13081310
},
13091311
"description": "The type of engine"
1310-
},
1312+
}
1313+
],
1314+
"responses": {
1315+
"200": {
1316+
"description": "Successful installation",
1317+
"content": {
1318+
"application/json": {
1319+
"schema": {
1320+
"type": "array",
1321+
"items": {
1322+
"type": "object",
1323+
"properties": {
1324+
"draft": {
1325+
"type": "boolean",
1326+
"example": false
1327+
},
1328+
"name": {
1329+
"type": "string",
1330+
"example": "v0.1.39-20.11.24"
1331+
},
1332+
"prerelease": {
1333+
"type": "boolean",
1334+
"example": true
1335+
},
1336+
"published_at": {
1337+
"type": "string",
1338+
"format": "date-time",
1339+
"example": "2024-11-20T17:39:40Z"
1340+
},
1341+
"url": {
1342+
"type": "string",
1343+
"example": "https://api.github.com/repos/janhq/cortex.llamacpp/releases/186479804"
1344+
}
1345+
}
1346+
}
1347+
}
1348+
}
1349+
}
1350+
}
1351+
},
1352+
"tags": ["Engines"]
1353+
}
1354+
},
1355+
"/v1/engines/{name}/releases/latest": {
1356+
"get": {
1357+
"summary": "Get latest release",
1358+
"description": "Return variants for the latest engine release of a specific engine type.",
1359+
"parameters": [
13111360
{
1312-
"name": "version",
1313-
"in": "query",
1314-
"required": false,
1361+
"name": "name",
1362+
"in": "path",
1363+
"required": true,
13151364
"schema": {
1316-
"type": "string"
1365+
"type": "string",
1366+
"enum": ["llama-cpp", "onnxruntime", "tensorrt-llm"],
1367+
"default": "llama-cpp"
13171368
},
1318-
"description": "The version of the engine to install (optional)"
1319-
},
1369+
"description": "The type of engine"
1370+
}
1371+
],
1372+
"responses": {
1373+
"200": {
1374+
"description": "Successful installation",
1375+
"content": {
1376+
"application/json": {
1377+
"schema": {
1378+
"type": "array",
1379+
"items": {
1380+
"type": "object",
1381+
"properties": {
1382+
"created_at": {
1383+
"type": "string",
1384+
"format": "date-time",
1385+
"example": "2024-11-15T10:39:39Z"
1386+
},
1387+
"download_count": {
1388+
"type": "integer",
1389+
"example": 76
1390+
},
1391+
"name": {
1392+
"type": "string",
1393+
"example": "0.1.39-linux-amd64-avx-cuda-11-7"
1394+
},
1395+
"size": {
1396+
"type": "integer",
1397+
"example": 151215080
1398+
}
1399+
}
1400+
}
1401+
}
1402+
}
1403+
}
1404+
}
1405+
},
1406+
"tags": ["Engines"]
1407+
}
1408+
},
1409+
"/v1/engines/{name}/install": {
1410+
"post": {
1411+
"summary": "Install an engine",
1412+
"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.",
1413+
"parameters": [
13201414
{
1321-
"name": "variant",
1322-
"in": "query",
1323-
"required": false,
1415+
"name": "name",
1416+
"in": "path",
1417+
"required": true,
13241418
"schema": {
1325-
"type": "string"
1419+
"type": "string",
1420+
"enum": ["llama-cpp", "onnxruntime", "tensorrt-llm"],
1421+
"default": "llama-cpp"
13261422
},
1327-
"description": "The variant of the engine to install (optional)"
1423+
"description": "The type of engine"
13281424
}
13291425
],
1426+
"requestBody": {
1427+
"required": false,
1428+
"content": {
1429+
"application/json": {
1430+
"schema": {
1431+
"type": "object",
1432+
"properties": {
1433+
"version": {
1434+
"type": "string",
1435+
"description": "The version of the engine to install (optional)",
1436+
"example": "v0.1.39"
1437+
},
1438+
"variant": {
1439+
"type": "string",
1440+
"description": "The variant of the engine to install (optional)",
1441+
"example": "mac-arm64"
1442+
}
1443+
}
1444+
}
1445+
}
1446+
}
1447+
},
13301448
"responses": {
13311449
"200": {
13321450
"description": "Successful installation",
13331451
"content": {
13341452
"application/json": {
1335-
"schema": {}
1453+
"schema": {
1454+
"type": "object",
1455+
"properties": {
1456+
"message": {
1457+
"type": "string",
1458+
"example": "Engine starts installing!"
1459+
}
1460+
}
1461+
}
13361462
}
13371463
}
13381464
}
@@ -1341,7 +1467,7 @@
13411467
},
13421468
"delete": {
13431469
"summary": "Uninstall an engine",
1344-
"description": "Uninstall an engine based on type, version, and variant",
1470+
"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.",
13451471
"parameters": [
13461472
{
13471473
"name": "name",
@@ -1353,26 +1479,30 @@
13531479
"default": "llama-cpp"
13541480
},
13551481
"description": "The type of engine"
1356-
},
1357-
{
1358-
"name": "version",
1359-
"in": "query",
1360-
"required": false,
1361-
"schema": {
1362-
"type": "string"
1363-
},
1364-
"description": "The version of the engine to uninstall (optional)"
1365-
},
1366-
{
1367-
"name": "variant",
1368-
"in": "query",
1369-
"required": false,
1370-
"schema": {
1371-
"type": "string"
1372-
},
1373-
"description": "The variant of the engine to uninstall (optional)"
13741482
}
13751483
],
1484+
"requestBody": {
1485+
"required": false,
1486+
"content": {
1487+
"application/json": {
1488+
"schema": {
1489+
"type": "object",
1490+
"properties": {
1491+
"version": {
1492+
"type": "string",
1493+
"description": "The version of the engine to uninstall (optional)",
1494+
"example": "v0.1.39"
1495+
},
1496+
"variant": {
1497+
"type": "string",
1498+
"description": "The variant of the engine to uninstall (optional)",
1499+
"example": "mac-arm64"
1500+
}
1501+
}
1502+
}
1503+
}
1504+
}
1505+
},
13761506
"responses": {
13771507
"200": {
13781508
"description": "Successful uninstallation",
@@ -1381,28 +1511,10 @@
13811511
"schema": {
13821512
"type": "object",
13831513
"properties": {
1384-
"success": {
1385-
"type": "boolean",
1386-
"description": "Indicates if the uninstallation was successful"
1387-
},
13881514
"message": {
13891515
"type": "string",
1390-
"description": "Description of the uninstallation action taken"
1391-
},
1392-
"uninstalledEngines": {
1393-
"type": "array",
1394-
"items": {
1395-
"type": "object",
1396-
"properties": {
1397-
"version": {
1398-
"type": "string"
1399-
},
1400-
"variant": {
1401-
"type": "string"
1402-
}
1403-
}
1404-
},
1405-
"description": "List of uninstalled engine versions and variants"
1516+
"description": "Engine llama-cpp uninstalled successfully!",
1517+
"example": "Engine llama-cpp uninstalled successfully!"
14061518
}
14071519
}
14081520
}
@@ -1429,6 +1541,44 @@
14291541
"tags": ["Engines"]
14301542
}
14311543
},
1544+
"/v1/engines/{name}/update": {
1545+
"post": {
1546+
"summary": "Update engine",
1547+
"description": "Updates the specified engine type using the engine variant currently set as default.",
1548+
"parameters": [
1549+
{
1550+
"name": "name",
1551+
"in": "path",
1552+
"required": true,
1553+
"schema": {
1554+
"type": "string",
1555+
"enum": ["llama-cpp", "onnxruntime", "tensorrt-llm"],
1556+
"default": "llama-cpp"
1557+
},
1558+
"description": "The name of the engine to update"
1559+
}
1560+
],
1561+
"responses": {
1562+
"200": {
1563+
"description": "Engine updated successfully",
1564+
"content": {
1565+
"application/json": {
1566+
"schema": {
1567+
"type": "object",
1568+
"properties": {
1569+
"message": {
1570+
"type": "string",
1571+
"example": "Engine updated successfully"
1572+
}
1573+
}
1574+
}
1575+
}
1576+
}
1577+
}
1578+
},
1579+
"tags": ["Engines"]
1580+
}
1581+
},
14321582
"/v1/engines/{name}/default": {
14331583
"get": {
14341584
"summary": "Get default engine variant",
@@ -1603,44 +1753,6 @@
16031753
"tags": ["Engines"]
16041754
}
16051755
},
1606-
"/v1/engines/{name}/update": {
1607-
"post": {
1608-
"summary": "Update engine",
1609-
"description": "Updates the specified engine type using the engine variant currently set as default.",
1610-
"parameters": [
1611-
{
1612-
"name": "name",
1613-
"in": "path",
1614-
"required": true,
1615-
"schema": {
1616-
"type": "string",
1617-
"enum": ["llama-cpp", "onnxruntime", "tensorrt-llm"],
1618-
"default": "llama-cpp"
1619-
},
1620-
"description": "The name of the engine to update"
1621-
}
1622-
],
1623-
"responses": {
1624-
"200": {
1625-
"description": "Engine updated successfully",
1626-
"content": {
1627-
"application/json": {
1628-
"schema": {
1629-
"type": "object",
1630-
"properties": {
1631-
"message": {
1632-
"type": "string",
1633-
"example": "Engine updated successfully"
1634-
}
1635-
}
1636-
}
1637-
}
1638-
}
1639-
}
1640-
},
1641-
"tags": ["Engines"]
1642-
}
1643-
},
16441756
"/v1/hardware": {
16451757
"get": {
16461758
"summary": "Get hardware information",

engine/cli/commands/engine_get_cmd.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include <json/reader.h>
33
#include <json/value.h>
44
#include <iostream>
5+
#include "common/engine_servicei.h"
56
#include "server_start_cmd.h"
6-
#include "services/engine_service.h"
77
#include "utils/curl_utils.h"
88
#include "utils/logging_utils.h"
99
#include "utils/url_parser.h"

0 commit comments

Comments
 (0)