From ea044d6c324e0ff9dbc9e30772ea9fd79b96f3e0 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 17 Feb 2025 15:33:57 +0800 Subject: [PATCH] fix: change the AI routing interface (#7887) --- backend/app/api/v1/{ai_tool.go => ai.go} | 34 +- backend/app/dto/{ai_tool.go => ai.go} | 0 backend/app/service/{ai_tool.go => ai.go} | 0 backend/constant/common.go | 4 + backend/router/{ro_aitool.go => ro_ai.go} | 2 +- cmd/server/docs/docs.go | 298 +++++------------- cmd/server/docs/swagger.json | 293 +++++------------ cmd/server/docs/swagger.yaml | 198 ++++-------- .../src/api/interface/{ai-tool.ts => ai.ts} | 2 +- frontend/src/api/modules/ai-tool.ts | 32 -- frontend/src/api/modules/ai.ts | 32 ++ .../src/routers/modules/{ai-tool.ts => ai.ts} | 12 +- .../src/views/{ai-tools => ai}/gpu/index.vue | 8 +- .../{ai-tools => ai}/model/add/index.vue | 2 +- .../{ai-tools => ai}/model/conn/index.vue | 0 .../{ai-tools => ai}/model/domain/index.vue | 2 +- .../views/{ai-tools => ai}/model/index.vue | 14 +- go.mod | 2 +- 18 files changed, 304 insertions(+), 631 deletions(-) rename backend/app/api/v1/{ai_tool.go => ai.go} (90%) rename backend/app/dto/{ai_tool.go => ai.go} (100%) rename backend/app/service/{ai_tool.go => ai.go} (100%) rename backend/router/{ro_aitool.go => ro_ai.go} (95%) rename frontend/src/api/interface/{ai-tool.ts => ai.ts} (98%) delete mode 100644 frontend/src/api/modules/ai-tool.ts create mode 100644 frontend/src/api/modules/ai.ts rename frontend/src/routers/modules/{ai-tool.ts => ai.ts} (67%) rename frontend/src/views/{ai-tools => ai}/gpu/index.vue (99%) rename frontend/src/views/{ai-tools => ai}/model/add/index.vue (98%) rename frontend/src/views/{ai-tools => ai}/model/conn/index.vue (100%) rename frontend/src/views/{ai-tools => ai}/model/domain/index.vue (99%) rename frontend/src/views/{ai-tools => ai}/model/index.vue (96%) diff --git a/backend/app/api/v1/ai_tool.go b/backend/app/api/v1/ai.go similarity index 90% rename from backend/app/api/v1/ai_tool.go rename to backend/app/api/v1/ai.go index 89d6d162f..f96e3f641 100644 --- a/backend/app/api/v1/ai_tool.go +++ b/backend/app/api/v1/ai.go @@ -10,14 +10,14 @@ import ( "github.com/gin-gonic/gin" ) -// @Tags AITools +// @Tags AI // @Summary Create Ollama model // @Accept json // @Param request body dto.OllamaModelName true "request" // @Success 200 // @Security ApiKeyAuth // @Security Timestamp -// @Router /aitools/ollama/model [post] +// @Router /ai/ollama/model [post] // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"添加模型 [name]","formatEN":"add Ollama model [name]"} func (b *BaseApi) CreateOllamaModel(c *gin.Context) { var req dto.OllamaModelName @@ -32,14 +32,14 @@ func (b *BaseApi) CreateOllamaModel(c *gin.Context) { helper.SuccessWithData(c, nil) } -// @Tags AITools +// @Tags AI // @Summary Page Ollama models // @Accept json // @Param request body dto.SearchWithPage true "request" // @Success 200 {object} dto.PageResult // @Security ApiKeyAuth // @Security Timestamp -// @Router /aitools/ollama/model/search [post] +// @Router /ai/ollama/model/search [post] func (b *BaseApi) SearchOllamaModel(c *gin.Context) { var req dto.SearchWithPage if err := helper.CheckBindAndValidate(&req, c); err != nil { @@ -58,14 +58,14 @@ func (b *BaseApi) SearchOllamaModel(c *gin.Context) { }) } -// @Tags AITools +// @Tags AI // @Summary Page Ollama models // @Accept json // @Param request body dto.OllamaModelName true "request" // @Success 200 {string} details // @Security ApiKeyAuth // @Security Timestamp -// @Router /aitools/ollama/model/load [post] +// @Router /ai/ollama/model/load [post] func (b *BaseApi) LoadOllamaModelDetail(c *gin.Context) { var req dto.OllamaModelName if err := helper.CheckBindAndValidate(&req, c); err != nil { @@ -81,14 +81,14 @@ func (b *BaseApi) LoadOllamaModelDetail(c *gin.Context) { helper.SuccessWithData(c, detail) } -// @Tags AITools +// @Tags AI // @Summary Delete Ollama model // @Accept json // @Param request body dto.OllamaModelName true "request" // @Success 200 // @Security ApiKeyAuth // @Security Timestamp -// @Router /aitool/ollama/model/del [post] +// @Router /ai/ollama/model/del [post] // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除模型 [name]","formatEN":"remove Ollama model [name]"} func (b *BaseApi) DeleteOllamaModel(c *gin.Context) { var req dto.OllamaModelName @@ -104,13 +104,13 @@ func (b *BaseApi) DeleteOllamaModel(c *gin.Context) { helper.SuccessWithOutData(c) } -// @Tags AITools +// @Tags AI // @Summary Load gpu / xpu info // @Accept json // @Success 200 // @Security ApiKeyAuth // @Security Timestamp -// @Router /aitool/gpu/load [get] +// @Router /ai/gpu/load [get] func (b *BaseApi) LoadGpuInfo(c *gin.Context) { ok, client := gpu.New() if ok { @@ -135,14 +135,14 @@ func (b *BaseApi) LoadGpuInfo(c *gin.Context) { helper.SuccessWithData(c, &common.GpuInfo{}) } -// @Tags AITools +// @Tags AI // @Summary Bind domain // @Accept json -// @Param request body dto.WebsiteConfig true "request" +// @Param request body dto.OllamaBindDomain true "request" // @Success 200 // @Security ApiKeyAuth // @Security Timestamp -// @Router /aitool/domain/bind [post] +// @Router /ai/domain/bind [post] func (b *BaseApi) BindDomain(c *gin.Context) { var req dto.OllamaBindDomain if err := helper.CheckBindAndValidate(&req, c); err != nil { @@ -155,14 +155,14 @@ func (b *BaseApi) BindDomain(c *gin.Context) { helper.SuccessWithOutData(c) } -// @Tags AITools +// @Tags AI // @Summary Get bind domain // @Accept json // @Param request body dto.OllamaBindDomainReq true "request" // @Success 200 {object} dto.OllamaBindDomainRes // @Security ApiKeyAuth // @Security Timestamp -// @Router /aitool/domain/get [post] +// @Router /ai/domain/get [post] func (b *BaseApi) GetBindDomain(c *gin.Context) { var req dto.OllamaBindDomainReq if err := helper.CheckBindAndValidate(&req, c); err != nil { @@ -176,14 +176,14 @@ func (b *BaseApi) GetBindDomain(c *gin.Context) { helper.SuccessWithData(c, res) } -// Tags AITools +// Tags AI // Summary Update bind domain // Accept json // Param request body dto.OllamaBindDomain true "request" // Success 200 // Security ApiKeyAuth // Security Timestamp -// Router /aitool/domain/update [post] +// Router /ai/domain/update [post] func (b *BaseApi) UpdateBindDomain(c *gin.Context) { var req dto.OllamaBindDomain if err := helper.CheckBindAndValidate(&req, c); err != nil { diff --git a/backend/app/dto/ai_tool.go b/backend/app/dto/ai.go similarity index 100% rename from backend/app/dto/ai_tool.go rename to backend/app/dto/ai.go diff --git a/backend/app/service/ai_tool.go b/backend/app/service/ai.go similarity index 100% rename from backend/app/service/ai_tool.go rename to backend/app/service/ai.go diff --git a/backend/constant/common.go b/backend/constant/common.go index 71f4d541d..5637d5811 100644 --- a/backend/constant/common.go +++ b/backend/constant/common.go @@ -32,6 +32,10 @@ var WebUrlMap = map[string]struct{}{ "/apps/installed": {}, "/apps/upgrade": {}, + "/ai": {}, + "/ai/model": {}, + "/ai/gpu": {}, + "/containers": {}, "/containers/container": {}, "/containers/image": {}, diff --git a/backend/router/ro_aitool.go b/backend/router/ro_ai.go similarity index 95% rename from backend/router/ro_aitool.go rename to backend/router/ro_ai.go index 093ca5e78..734101866 100644 --- a/backend/router/ro_aitool.go +++ b/backend/router/ro_ai.go @@ -10,7 +10,7 @@ type AIToolsRouter struct { } func (a *AIToolsRouter) InitRouter(Router *gin.RouterGroup) { - aiToolsRouter := Router.Group("aitools") + aiToolsRouter := Router.Group("ai") aiToolsRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired()) baseApi := v1.ApiGroupApp.BaseApi diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 213b0e21f..718397f65 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -1,5 +1,4 @@ -// Package docs GENERATED BY SWAG; DO NOT EDIT -// This file was generated by swaggo/swag +// Package docs Code generated by swaggo/swag. DO NOT EDIT package docs import "github.com/swaggo/swag" @@ -21,7 +20,7 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/aitool/domain/bind": { + "/ai/domain/bind": { "post": { "security": [ { @@ -35,7 +34,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "AITools" + "AI" ], "summary": "Bind domain", "parameters": [ @@ -45,7 +44,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.WebsiteConfig" + "$ref": "#/definitions/dto.OllamaBindDomain" } } ], @@ -56,7 +55,7 @@ const docTemplate = `{ } } }, - "/aitool/domain/get": { + "/ai/domain/get": { "post": { "security": [ { @@ -70,7 +69,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "AITools" + "AI" ], "summary": "Get bind domain", "parameters": [ @@ -94,7 +93,7 @@ const docTemplate = `{ } } }, - "/aitool/gpu/load": { + "/ai/gpu/load": { "get": { "security": [ { @@ -108,7 +107,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "AITools" + "AI" ], "summary": "Load gpu / xpu info", "responses": { @@ -118,7 +117,7 @@ const docTemplate = `{ } } }, - "/aitool/ollama/model/del": { + "/ai/ollama/model": { "post": { "security": [ { @@ -132,51 +131,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "AITools" - ], - "summary": "Delete Ollama model", - "parameters": [ - { - "description": "request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dto.OllamaModelName" - } - } - ], - "responses": { - "200": { - "description": "OK" - } - }, - "x-panel-log": { - "BeforeFunctions": [], - "bodyKeys": [ - "name" - ], - "formatEN": "remove Ollama model [name]", - "formatZH": "删除模型 [name]", - "paramKeys": [] - } - } - }, - "/aitools/ollama/model": { - "post": { - "security": [ - { - "ApiKeyAuth": [] - }, - { - "Timestamp": [] - } - ], - "consumes": [ - "application/json" - ], - "tags": [ - "AITools" + "AI" ], "summary": "Create Ollama model", "parameters": [ @@ -206,7 +161,7 @@ const docTemplate = `{ } } }, - "/aitools/ollama/model/load": { + "/ai/ollama/model/del": { "post": { "security": [ { @@ -220,7 +175,51 @@ const docTemplate = `{ "application/json" ], "tags": [ - "AITools" + "AI" + ], + "summary": "Delete Ollama model", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.OllamaModelName" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "x-panel-log": { + "BeforeFunctions": [], + "bodyKeys": [ + "name" + ], + "formatEN": "remove Ollama model [name]", + "formatZH": "删除模型 [name]", + "paramKeys": [] + } + } + }, + "/ai/ollama/model/load": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + }, + { + "Timestamp": [] + } + ], + "consumes": [ + "application/json" + ], + "tags": [ + "AI" ], "summary": "Page Ollama models", "parameters": [ @@ -244,7 +243,7 @@ const docTemplate = `{ } } }, - "/aitools/ollama/model/search": { + "/ai/ollama/model/search": { "post": { "security": [ { @@ -258,7 +257,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "AITools" + "AI" ], "summary": "Page Ollama models", "parameters": [ @@ -17297,41 +17296,6 @@ const docTemplate = `{ } } }, - "dto.CCConfig": { - "type": "object", - "properties": { - "action": { - "type": "string" - }, - "code": { - "type": "integer" - }, - "duration": { - "type": "integer" - }, - "ipBlock": { - "type": "string" - }, - "ipBlockTime": { - "type": "integer" - }, - "mode": { - "type": "string" - }, - "res": { - "type": "string" - }, - "state": { - "type": "string" - }, - "threshold": { - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, "dto.CaptchaResponse": { "type": "object", "properties": { @@ -17776,26 +17740,6 @@ const docTemplate = `{ } } }, - "dto.CommonConfig": { - "type": "object", - "properties": { - "action": { - "type": "string" - }, - "code": { - "type": "integer" - }, - "res": { - "type": "string" - }, - "state": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, "dto.CommonRecover": { "type": "object", "required": [ @@ -19492,29 +19436,6 @@ const docTemplate = `{ } } }, - "dto.GeoRestrict": { - "type": "object", - "properties": { - "action": { - "type": "string" - }, - "res": { - "type": "string" - }, - "rules": { - "type": "array", - "items": { - "type": "string" - } - }, - "state": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, "dto.GroupCreate": { "type": "object", "required": [ @@ -20604,6 +20525,33 @@ const docTemplate = `{ "ProxyCache" ] }, + "dto.OllamaBindDomain": { + "type": "object", + "required": [ + "appInstallID", + "domain" + ], + "properties": { + "allowIPs": { + "type": "array", + "items": { + "type": "string" + } + }, + "appInstallID": { + "type": "integer" + }, + "domain": { + "type": "string" + }, + "sslID": { + "type": "integer" + }, + "websiteID": { + "type": "integer" + } + } + }, "dto.OllamaBindDomainReq": { "type": "object", "required": [ @@ -22109,14 +22057,6 @@ const docTemplate = `{ } } }, - "dto.StateConfig": { - "type": "object", - "properties": { - "state": { - "type": "string" - } - } - }, "dto.SwapHelper": { "type": "object", "required": [ @@ -22315,72 +22255,6 @@ const docTemplate = `{ } } }, - "dto.WafConfig": { - "type": "object", - "required": [ - "mode", - "secret", - "state" - ], - "properties": { - "mode": { - "type": "string" - }, - "secret": { - "type": "string" - }, - "state": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, - "dto.WebsiteConfig": { - "type": "object", - "properties": { - "args": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "cc": { - "$ref": "#/definitions/dto.CCConfig" - }, - "cdn": { - "$ref": "#/definitions/dto.StateConfig" - }, - "cookie": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "defaultUaBlack": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "defaultUrlBlack": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "fileExt": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "geoRestrict": { - "$ref": "#/definitions/dto.GeoRestrict" - }, - "header": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "methodWhite": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "sql": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "waf": { - "$ref": "#/definitions/dto.WafConfig" - }, - "xss": { - "$ref": "#/definitions/dto.CommonConfig" - } - } - }, "dto.XPUInfo": { "type": "object", "properties": { @@ -26715,6 +26589,8 @@ var SwaggerInfo = &swag.Spec{ Description: "Top-Rated Web-based Linux Server Management Tool", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 86965f97f..599a34829 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -17,7 +17,7 @@ }, "basePath": "/api/v1", "paths": { - "/aitool/domain/bind": { + "/ai/domain/bind": { "post": { "security": [ { @@ -31,7 +31,7 @@ "application/json" ], "tags": [ - "AITools" + "AI" ], "summary": "Bind domain", "parameters": [ @@ -41,7 +41,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.WebsiteConfig" + "$ref": "#/definitions/dto.OllamaBindDomain" } } ], @@ -52,7 +52,7 @@ } } }, - "/aitool/domain/get": { + "/ai/domain/get": { "post": { "security": [ { @@ -66,7 +66,7 @@ "application/json" ], "tags": [ - "AITools" + "AI" ], "summary": "Get bind domain", "parameters": [ @@ -90,7 +90,7 @@ } } }, - "/aitool/gpu/load": { + "/ai/gpu/load": { "get": { "security": [ { @@ -104,7 +104,7 @@ "application/json" ], "tags": [ - "AITools" + "AI" ], "summary": "Load gpu / xpu info", "responses": { @@ -114,7 +114,7 @@ } } }, - "/aitool/ollama/model/del": { + "/ai/ollama/model": { "post": { "security": [ { @@ -128,51 +128,7 @@ "application/json" ], "tags": [ - "AITools" - ], - "summary": "Delete Ollama model", - "parameters": [ - { - "description": "request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dto.OllamaModelName" - } - } - ], - "responses": { - "200": { - "description": "OK" - } - }, - "x-panel-log": { - "BeforeFunctions": [], - "bodyKeys": [ - "name" - ], - "formatEN": "remove Ollama model [name]", - "formatZH": "删除模型 [name]", - "paramKeys": [] - } - } - }, - "/aitools/ollama/model": { - "post": { - "security": [ - { - "ApiKeyAuth": [] - }, - { - "Timestamp": [] - } - ], - "consumes": [ - "application/json" - ], - "tags": [ - "AITools" + "AI" ], "summary": "Create Ollama model", "parameters": [ @@ -202,7 +158,7 @@ } } }, - "/aitools/ollama/model/load": { + "/ai/ollama/model/del": { "post": { "security": [ { @@ -216,7 +172,51 @@ "application/json" ], "tags": [ - "AITools" + "AI" + ], + "summary": "Delete Ollama model", + "parameters": [ + { + "description": "request", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.OllamaModelName" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "x-panel-log": { + "BeforeFunctions": [], + "bodyKeys": [ + "name" + ], + "formatEN": "remove Ollama model [name]", + "formatZH": "删除模型 [name]", + "paramKeys": [] + } + } + }, + "/ai/ollama/model/load": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + }, + { + "Timestamp": [] + } + ], + "consumes": [ + "application/json" + ], + "tags": [ + "AI" ], "summary": "Page Ollama models", "parameters": [ @@ -240,7 +240,7 @@ } } }, - "/aitools/ollama/model/search": { + "/ai/ollama/model/search": { "post": { "security": [ { @@ -254,7 +254,7 @@ "application/json" ], "tags": [ - "AITools" + "AI" ], "summary": "Page Ollama models", "parameters": [ @@ -17293,41 +17293,6 @@ } } }, - "dto.CCConfig": { - "type": "object", - "properties": { - "action": { - "type": "string" - }, - "code": { - "type": "integer" - }, - "duration": { - "type": "integer" - }, - "ipBlock": { - "type": "string" - }, - "ipBlockTime": { - "type": "integer" - }, - "mode": { - "type": "string" - }, - "res": { - "type": "string" - }, - "state": { - "type": "string" - }, - "threshold": { - "type": "integer" - }, - "type": { - "type": "string" - } - } - }, "dto.CaptchaResponse": { "type": "object", "properties": { @@ -17772,26 +17737,6 @@ } } }, - "dto.CommonConfig": { - "type": "object", - "properties": { - "action": { - "type": "string" - }, - "code": { - "type": "integer" - }, - "res": { - "type": "string" - }, - "state": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, "dto.CommonRecover": { "type": "object", "required": [ @@ -19488,29 +19433,6 @@ } } }, - "dto.GeoRestrict": { - "type": "object", - "properties": { - "action": { - "type": "string" - }, - "res": { - "type": "string" - }, - "rules": { - "type": "array", - "items": { - "type": "string" - } - }, - "state": { - "type": "string" - }, - "type": { - "type": "string" - } - } - }, "dto.GroupCreate": { "type": "object", "required": [ @@ -20600,6 +20522,33 @@ "ProxyCache" ] }, + "dto.OllamaBindDomain": { + "type": "object", + "required": [ + "appInstallID", + "domain" + ], + "properties": { + "allowIPs": { + "type": "array", + "items": { + "type": "string" + } + }, + "appInstallID": { + "type": "integer" + }, + "domain": { + "type": "string" + }, + "sslID": { + "type": "integer" + }, + "websiteID": { + "type": "integer" + } + } + }, "dto.OllamaBindDomainReq": { "type": "object", "required": [ @@ -22105,14 +22054,6 @@ } } }, - "dto.StateConfig": { - "type": "object", - "properties": { - "state": { - "type": "string" - } - } - }, "dto.SwapHelper": { "type": "object", "required": [ @@ -22311,72 +22252,6 @@ } } }, - "dto.WafConfig": { - "type": "object", - "required": [ - "mode", - "secret", - "state" - ], - "properties": { - "mode": { - "type": "string" - }, - "secret": { - "type": "string" - }, - "state": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, - "dto.WebsiteConfig": { - "type": "object", - "properties": { - "args": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "cc": { - "$ref": "#/definitions/dto.CCConfig" - }, - "cdn": { - "$ref": "#/definitions/dto.StateConfig" - }, - "cookie": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "defaultUaBlack": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "defaultUrlBlack": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "fileExt": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "geoRestrict": { - "$ref": "#/definitions/dto.GeoRestrict" - }, - "header": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "methodWhite": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "sql": { - "$ref": "#/definitions/dto.CommonConfig" - }, - "waf": { - "$ref": "#/definitions/dto.WafConfig" - }, - "xss": { - "$ref": "#/definitions/dto.CommonConfig" - } - } - }, "dto.XPUInfo": { "type": "object", "properties": { diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 57149ad69..3c728e1e5 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -263,29 +263,6 @@ definitions: - permission - username type: object - dto.CCConfig: - properties: - action: - type: string - code: - type: integer - duration: - type: integer - ipBlock: - type: string - ipBlockTime: - type: integer - mode: - type: string - res: - type: string - state: - type: string - threshold: - type: integer - type: - type: string - type: object dto.CaptchaResponse: properties: captchaID: @@ -580,19 +557,6 @@ definitions: required: - type type: object - dto.CommonConfig: - properties: - action: - type: string - code: - type: integer - res: - type: string - state: - type: string - type: - type: string - type: object dto.CommonRecover: properties: detailName: @@ -1740,21 +1704,6 @@ definitions: required: - encryptionMode type: object - dto.GeoRestrict: - properties: - action: - type: string - res: - type: string - rules: - items: - type: string - type: array - state: - type: string - type: - type: string - type: object dto.GroupCreate: properties: id: @@ -2497,6 +2446,24 @@ definitions: - CACHE - HttpPer - ProxyCache + dto.OllamaBindDomain: + properties: + allowIPs: + items: + type: string + type: array + appInstallID: + type: integer + domain: + type: string + sslID: + type: integer + websiteID: + type: integer + required: + - appInstallID + - domain + type: object dto.OllamaBindDomainReq: properties: appInstallID: @@ -3512,11 +3479,6 @@ definitions: upload: type: string type: object - dto.StateConfig: - properties: - state: - type: string - type: object dto.SwapHelper: properties: isNew: @@ -3646,50 +3608,6 @@ definitions: type: type: string type: object - dto.WafConfig: - properties: - mode: - type: string - secret: - type: string - state: - type: string - token: - type: string - required: - - mode - - secret - - state - type: object - dto.WebsiteConfig: - properties: - args: - $ref: '#/definitions/dto.CommonConfig' - cc: - $ref: '#/definitions/dto.CCConfig' - cdn: - $ref: '#/definitions/dto.StateConfig' - cookie: - $ref: '#/definitions/dto.CommonConfig' - defaultUaBlack: - $ref: '#/definitions/dto.CommonConfig' - defaultUrlBlack: - $ref: '#/definitions/dto.CommonConfig' - fileExt: - $ref: '#/definitions/dto.CommonConfig' - geoRestrict: - $ref: '#/definitions/dto.GeoRestrict' - header: - $ref: '#/definitions/dto.CommonConfig' - methodWhite: - $ref: '#/definitions/dto.CommonConfig' - sql: - $ref: '#/definitions/dto.CommonConfig' - waf: - $ref: '#/definitions/dto.WafConfig' - xss: - $ref: '#/definitions/dto.CommonConfig' - type: object dto.XPUInfo: properties: deviceID: @@ -6569,7 +6487,7 @@ info: title: 1Panel version: "1.0" paths: - /aitool/domain/bind: + /ai/domain/bind: post: consumes: - application/json @@ -6579,7 +6497,7 @@ paths: name: request required: true schema: - $ref: '#/definitions/dto.WebsiteConfig' + $ref: '#/definitions/dto.OllamaBindDomain' responses: "200": description: OK @@ -6588,8 +6506,8 @@ paths: - Timestamp: [] summary: Bind domain tags: - - AITools - /aitool/domain/get: + - AI + /ai/domain/get: post: consumes: - application/json @@ -6610,8 +6528,8 @@ paths: - Timestamp: [] summary: Get bind domain tags: - - AITools - /aitool/gpu/load: + - AI + /ai/gpu/load: get: consumes: - application/json @@ -6623,35 +6541,8 @@ paths: - Timestamp: [] summary: Load gpu / xpu info tags: - - AITools - /aitool/ollama/model/del: - post: - consumes: - - application/json - parameters: - - description: request - in: body - name: request - required: true - schema: - $ref: '#/definitions/dto.OllamaModelName' - responses: - "200": - description: OK - security: - - ApiKeyAuth: [] - - Timestamp: [] - summary: Delete Ollama model - tags: - - AITools - x-panel-log: - BeforeFunctions: [] - bodyKeys: - - name - formatEN: remove Ollama model [name] - formatZH: 删除模型 [name] - paramKeys: [] - /aitools/ollama/model: + - AI + /ai/ollama/model: post: consumes: - application/json @@ -6670,7 +6561,7 @@ paths: - Timestamp: [] summary: Create Ollama model tags: - - AITools + - AI x-panel-log: BeforeFunctions: [] bodyKeys: @@ -6678,7 +6569,34 @@ paths: formatEN: add Ollama model [name] formatZH: 添加模型 [name] paramKeys: [] - /aitools/ollama/model/load: + /ai/ollama/model/del: + post: + consumes: + - application/json + parameters: + - description: request + in: body + name: request + required: true + schema: + $ref: '#/definitions/dto.OllamaModelName' + responses: + "200": + description: OK + security: + - ApiKeyAuth: [] + - Timestamp: [] + summary: Delete Ollama model + tags: + - AI + x-panel-log: + BeforeFunctions: [] + bodyKeys: + - name + formatEN: remove Ollama model [name] + formatZH: 删除模型 [name] + paramKeys: [] + /ai/ollama/model/load: post: consumes: - application/json @@ -6699,8 +6617,8 @@ paths: - Timestamp: [] summary: Page Ollama models tags: - - AITools - /aitools/ollama/model/search: + - AI + /ai/ollama/model/search: post: consumes: - application/json @@ -6721,7 +6639,7 @@ paths: - Timestamp: [] summary: Page Ollama models tags: - - AITools + - AI /apps/{key}: get: consumes: diff --git a/frontend/src/api/interface/ai-tool.ts b/frontend/src/api/interface/ai.ts similarity index 98% rename from frontend/src/api/interface/ai-tool.ts rename to frontend/src/api/interface/ai.ts index f26e20f0b..de23ec21b 100644 --- a/frontend/src/api/interface/ai-tool.ts +++ b/frontend/src/api/interface/ai.ts @@ -1,6 +1,6 @@ import { ReqPage } from '.'; -export namespace AITool { +export namespace AI { export interface OllamaModelInfo { name: string; size: string; diff --git a/frontend/src/api/modules/ai-tool.ts b/frontend/src/api/modules/ai-tool.ts deleted file mode 100644 index c9a3d17a3..000000000 --- a/frontend/src/api/modules/ai-tool.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { AITool } from '@/api/interface/ai-tool'; -import http from '@/api'; -import { ResPage } from '../interface'; - -export const createOllamaModel = (name: string) => { - return http.post(`/aitools/ollama/model`, { name: name }); -}; -export const deleteOllamaModel = (name: string) => { - return http.post(`/aitools/ollama/model/del`, { name: name }); -}; -export const searchOllamaModel = (params: AITool.OllamaModelSearch) => { - return http.post>(`/aitools/ollama/model/search`, params); -}; -export const loadOllamaModel = (name: string) => { - return http.post(`/aitools/ollama/model/load`, { name: name }); -}; - -export const loadGPUInfo = () => { - return http.get(`/aitools/gpu/load`); -}; - -export const bindDomain = (req: AITool.BindDomain) => { - return http.post(`/aitools/domain/bind`, req); -}; - -export const getBindDomain = (req: AITool.BindDomainReq) => { - return http.post(`/aitools/domain/get`, req); -}; - -export const updateBindDomain = (req: AITool.BindDomain) => { - return http.post(`/aitools/domain/update`, req); -}; diff --git a/frontend/src/api/modules/ai.ts b/frontend/src/api/modules/ai.ts new file mode 100644 index 000000000..270f15574 --- /dev/null +++ b/frontend/src/api/modules/ai.ts @@ -0,0 +1,32 @@ +import { AI } from '@/api/interface/ai'; +import http from '@/api'; +import { ResPage } from '../interface'; + +export const createOllamaModel = (name: string) => { + return http.post(`/ai/ollama/model`, { name: name }); +}; +export const deleteOllamaModel = (name: string) => { + return http.post(`/ai/ollama/model/del`, { name: name }); +}; +export const searchOllamaModel = (params: AI.OllamaModelSearch) => { + return http.post>(`/ai/ollama/model/search`, params); +}; +export const loadOllamaModel = (name: string) => { + return http.post(`/ai/ollama/model/load`, { name: name }); +}; + +export const loadGPUInfo = () => { + return http.get(`/ai/gpu/load`); +}; + +export const bindDomain = (req: AI.BindDomain) => { + return http.post(`/ai/domain/bind`, req); +}; + +export const getBindDomain = (req: AI.BindDomainReq) => { + return http.post(`/ai/domain/get`, req); +}; + +export const updateBindDomain = (req: AI.BindDomain) => { + return http.post(`/ai/domain/update`, req); +}; diff --git a/frontend/src/routers/modules/ai-tool.ts b/frontend/src/routers/modules/ai.ts similarity index 67% rename from frontend/src/routers/modules/ai-tool.ts rename to frontend/src/routers/modules/ai.ts index 4875402c0..0750f4c37 100644 --- a/frontend/src/routers/modules/ai-tool.ts +++ b/frontend/src/routers/modules/ai.ts @@ -2,27 +2,27 @@ import { Layout } from '@/routers/constant'; const databaseRouter = { sort: 4, - path: '/ai-tools', + path: '/ai', component: Layout, - redirect: '/ai-tools/model', + redirect: '/ai/model', meta: { icon: 'p-jiqiren2', title: 'menu.ai_tools', }, children: [ { - path: '/ai-tools/model', + path: '/ai/model', name: 'OllamaModel', - component: () => import('@/views/ai-tools/model/index.vue'), + component: () => import('@/views/ai/model/index.vue'), meta: { title: 'ai_tools.model.model', requiresAuth: true, }, }, { - path: '/ai-tools/gpu', + path: '/ai/gpu', name: 'GPU', - component: () => import('@/views/ai-tools/gpu/index.vue'), + component: () => import('@/views/ai/gpu/index.vue'), meta: { title: 'ai_tools.gpu.gpu', requiresAuth: true, diff --git a/frontend/src/views/ai-tools/gpu/index.vue b/frontend/src/views/ai/gpu/index.vue similarity index 99% rename from frontend/src/views/ai-tools/gpu/index.vue rename to frontend/src/views/ai/gpu/index.vue index b926da7df..a4d94eb71 100644 --- a/frontend/src/views/ai-tools/gpu/index.vue +++ b/frontend/src/views/ai/gpu/index.vue @@ -261,19 +261,19 @@