1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-01 03:24:14 +08:00

fix: change the AI routing interface (#7887)

This commit is contained in:
ssongliu 2025-02-17 15:33:57 +08:00 committed by GitHub
parent f6ee3dc75b
commit ea044d6c32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 304 additions and 631 deletions

View File

@ -10,14 +10,14 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// @Tags AITools // @Tags AI
// @Summary Create Ollama model // @Summary Create Ollama model
// @Accept json // @Accept json
// @Param request body dto.OllamaModelName true "request" // @Param request body dto.OllamaModelName true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @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]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"添加模型 [name]","formatEN":"add Ollama model [name]"}
func (b *BaseApi) CreateOllamaModel(c *gin.Context) { func (b *BaseApi) CreateOllamaModel(c *gin.Context) {
var req dto.OllamaModelName var req dto.OllamaModelName
@ -32,14 +32,14 @@ func (b *BaseApi) CreateOllamaModel(c *gin.Context) {
helper.SuccessWithData(c, nil) helper.SuccessWithData(c, nil)
} }
// @Tags AITools // @Tags AI
// @Summary Page Ollama models // @Summary Page Ollama models
// @Accept json // @Accept json
// @Param request body dto.SearchWithPage true "request" // @Param request body dto.SearchWithPage true "request"
// @Success 200 {object} dto.PageResult // @Success 200 {object} dto.PageResult
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Security Timestamp
// @Router /aitools/ollama/model/search [post] // @Router /ai/ollama/model/search [post]
func (b *BaseApi) SearchOllamaModel(c *gin.Context) { func (b *BaseApi) SearchOllamaModel(c *gin.Context) {
var req dto.SearchWithPage var req dto.SearchWithPage
if err := helper.CheckBindAndValidate(&req, c); err != nil { 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 // @Summary Page Ollama models
// @Accept json // @Accept json
// @Param request body dto.OllamaModelName true "request" // @Param request body dto.OllamaModelName true "request"
// @Success 200 {string} details // @Success 200 {string} details
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Security Timestamp
// @Router /aitools/ollama/model/load [post] // @Router /ai/ollama/model/load [post]
func (b *BaseApi) LoadOllamaModelDetail(c *gin.Context) { func (b *BaseApi) LoadOllamaModelDetail(c *gin.Context) {
var req dto.OllamaModelName var req dto.OllamaModelName
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@ -81,14 +81,14 @@ func (b *BaseApi) LoadOllamaModelDetail(c *gin.Context) {
helper.SuccessWithData(c, detail) helper.SuccessWithData(c, detail)
} }
// @Tags AITools // @Tags AI
// @Summary Delete Ollama model // @Summary Delete Ollama model
// @Accept json // @Accept json
// @Param request body dto.OllamaModelName true "request" // @Param request body dto.OllamaModelName true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @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]"} // @x-panel-log {"bodyKeys":["name"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除模型 [name]","formatEN":"remove Ollama model [name]"}
func (b *BaseApi) DeleteOllamaModel(c *gin.Context) { func (b *BaseApi) DeleteOllamaModel(c *gin.Context) {
var req dto.OllamaModelName var req dto.OllamaModelName
@ -104,13 +104,13 @@ func (b *BaseApi) DeleteOllamaModel(c *gin.Context) {
helper.SuccessWithOutData(c) helper.SuccessWithOutData(c)
} }
// @Tags AITools // @Tags AI
// @Summary Load gpu / xpu info // @Summary Load gpu / xpu info
// @Accept json // @Accept json
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Security Timestamp
// @Router /aitool/gpu/load [get] // @Router /ai/gpu/load [get]
func (b *BaseApi) LoadGpuInfo(c *gin.Context) { func (b *BaseApi) LoadGpuInfo(c *gin.Context) {
ok, client := gpu.New() ok, client := gpu.New()
if ok { if ok {
@ -135,14 +135,14 @@ func (b *BaseApi) LoadGpuInfo(c *gin.Context) {
helper.SuccessWithData(c, &common.GpuInfo{}) helper.SuccessWithData(c, &common.GpuInfo{})
} }
// @Tags AITools // @Tags AI
// @Summary Bind domain // @Summary Bind domain
// @Accept json // @Accept json
// @Param request body dto.WebsiteConfig true "request" // @Param request body dto.OllamaBindDomain true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Security Timestamp
// @Router /aitool/domain/bind [post] // @Router /ai/domain/bind [post]
func (b *BaseApi) BindDomain(c *gin.Context) { func (b *BaseApi) BindDomain(c *gin.Context) {
var req dto.OllamaBindDomain var req dto.OllamaBindDomain
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@ -155,14 +155,14 @@ func (b *BaseApi) BindDomain(c *gin.Context) {
helper.SuccessWithOutData(c) helper.SuccessWithOutData(c)
} }
// @Tags AITools // @Tags AI
// @Summary Get bind domain // @Summary Get bind domain
// @Accept json // @Accept json
// @Param request body dto.OllamaBindDomainReq true "request" // @Param request body dto.OllamaBindDomainReq true "request"
// @Success 200 {object} dto.OllamaBindDomainRes // @Success 200 {object} dto.OllamaBindDomainRes
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Security Timestamp // @Security Timestamp
// @Router /aitool/domain/get [post] // @Router /ai/domain/get [post]
func (b *BaseApi) GetBindDomain(c *gin.Context) { func (b *BaseApi) GetBindDomain(c *gin.Context) {
var req dto.OllamaBindDomainReq var req dto.OllamaBindDomainReq
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
@ -176,14 +176,14 @@ func (b *BaseApi) GetBindDomain(c *gin.Context) {
helper.SuccessWithData(c, res) helper.SuccessWithData(c, res)
} }
// Tags AITools // Tags AI
// Summary Update bind domain // Summary Update bind domain
// Accept json // Accept json
// Param request body dto.OllamaBindDomain true "request" // Param request body dto.OllamaBindDomain true "request"
// Success 200 // Success 200
// Security ApiKeyAuth // Security ApiKeyAuth
// Security Timestamp // Security Timestamp
// Router /aitool/domain/update [post] // Router /ai/domain/update [post]
func (b *BaseApi) UpdateBindDomain(c *gin.Context) { func (b *BaseApi) UpdateBindDomain(c *gin.Context) {
var req dto.OllamaBindDomain var req dto.OllamaBindDomain
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {

View File

@ -32,6 +32,10 @@ var WebUrlMap = map[string]struct{}{
"/apps/installed": {}, "/apps/installed": {},
"/apps/upgrade": {}, "/apps/upgrade": {},
"/ai": {},
"/ai/model": {},
"/ai/gpu": {},
"/containers": {}, "/containers": {},
"/containers/container": {}, "/containers/container": {},
"/containers/image": {}, "/containers/image": {},

View File

@ -10,7 +10,7 @@ type AIToolsRouter struct {
} }
func (a *AIToolsRouter) InitRouter(Router *gin.RouterGroup) { 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()) aiToolsRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.PasswordExpired())
baseApi := v1.ApiGroupApp.BaseApi baseApi := v1.ApiGroupApp.BaseApi

View File

@ -1,5 +1,4 @@
// Package docs GENERATED BY SWAG; DO NOT EDIT // Package docs Code generated by swaggo/swag. DO NOT EDIT
// This file was generated by swaggo/swag
package docs package docs
import "github.com/swaggo/swag" import "github.com/swaggo/swag"
@ -21,7 +20,7 @@ const docTemplate = `{
"host": "{{.Host}}", "host": "{{.Host}}",
"basePath": "{{.BasePath}}", "basePath": "{{.BasePath}}",
"paths": { "paths": {
"/aitool/domain/bind": { "/ai/domain/bind": {
"post": { "post": {
"security": [ "security": [
{ {
@ -35,7 +34,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"AITools" "AI"
], ],
"summary": "Bind domain", "summary": "Bind domain",
"parameters": [ "parameters": [
@ -45,7 +44,7 @@ const docTemplate = `{
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/dto.WebsiteConfig" "$ref": "#/definitions/dto.OllamaBindDomain"
} }
} }
], ],
@ -56,7 +55,7 @@ const docTemplate = `{
} }
} }
}, },
"/aitool/domain/get": { "/ai/domain/get": {
"post": { "post": {
"security": [ "security": [
{ {
@ -70,7 +69,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"AITools" "AI"
], ],
"summary": "Get bind domain", "summary": "Get bind domain",
"parameters": [ "parameters": [
@ -94,7 +93,7 @@ const docTemplate = `{
} }
} }
}, },
"/aitool/gpu/load": { "/ai/gpu/load": {
"get": { "get": {
"security": [ "security": [
{ {
@ -108,7 +107,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"AITools" "AI"
], ],
"summary": "Load gpu / xpu info", "summary": "Load gpu / xpu info",
"responses": { "responses": {
@ -118,7 +117,7 @@ const docTemplate = `{
} }
} }
}, },
"/aitool/ollama/model/del": { "/ai/ollama/model": {
"post": { "post": {
"security": [ "security": [
{ {
@ -132,51 +131,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "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": []
}
}
},
"/aitools/ollama/model": {
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"Timestamp": []
}
],
"consumes": [
"application/json"
],
"tags": [
"AITools"
], ],
"summary": "Create Ollama model", "summary": "Create Ollama model",
"parameters": [ "parameters": [
@ -206,7 +161,7 @@ const docTemplate = `{
} }
} }
}, },
"/aitools/ollama/model/load": { "/ai/ollama/model/del": {
"post": { "post": {
"security": [ "security": [
{ {
@ -220,7 +175,51 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "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", "summary": "Page Ollama models",
"parameters": [ "parameters": [
@ -244,7 +243,7 @@ const docTemplate = `{
} }
} }
}, },
"/aitools/ollama/model/search": { "/ai/ollama/model/search": {
"post": { "post": {
"security": [ "security": [
{ {
@ -258,7 +257,7 @@ const docTemplate = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"AITools" "AI"
], ],
"summary": "Page Ollama models", "summary": "Page Ollama models",
"parameters": [ "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": { "dto.CaptchaResponse": {
"type": "object", "type": "object",
"properties": { "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": { "dto.CommonRecover": {
"type": "object", "type": "object",
"required": [ "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": { "dto.GroupCreate": {
"type": "object", "type": "object",
"required": [ "required": [
@ -20604,6 +20525,33 @@ const docTemplate = `{
"ProxyCache" "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": { "dto.OllamaBindDomainReq": {
"type": "object", "type": "object",
"required": [ "required": [
@ -22109,14 +22057,6 @@ const docTemplate = `{
} }
} }
}, },
"dto.StateConfig": {
"type": "object",
"properties": {
"state": {
"type": "string"
}
}
},
"dto.SwapHelper": { "dto.SwapHelper": {
"type": "object", "type": "object",
"required": [ "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": { "dto.XPUInfo": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -26715,6 +26589,8 @@ var SwaggerInfo = &swag.Spec{
Description: "Top-Rated Web-based Linux Server Management Tool", Description: "Top-Rated Web-based Linux Server Management Tool",
InfoInstanceName: "swagger", InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate, SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
} }
func init() { func init() {

View File

@ -17,7 +17,7 @@
}, },
"basePath": "/api/v1", "basePath": "/api/v1",
"paths": { "paths": {
"/aitool/domain/bind": { "/ai/domain/bind": {
"post": { "post": {
"security": [ "security": [
{ {
@ -31,7 +31,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"AITools" "AI"
], ],
"summary": "Bind domain", "summary": "Bind domain",
"parameters": [ "parameters": [
@ -41,7 +41,7 @@
"in": "body", "in": "body",
"required": true, "required": true,
"schema": { "schema": {
"$ref": "#/definitions/dto.WebsiteConfig" "$ref": "#/definitions/dto.OllamaBindDomain"
} }
} }
], ],
@ -52,7 +52,7 @@
} }
} }
}, },
"/aitool/domain/get": { "/ai/domain/get": {
"post": { "post": {
"security": [ "security": [
{ {
@ -66,7 +66,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"AITools" "AI"
], ],
"summary": "Get bind domain", "summary": "Get bind domain",
"parameters": [ "parameters": [
@ -90,7 +90,7 @@
} }
} }
}, },
"/aitool/gpu/load": { "/ai/gpu/load": {
"get": { "get": {
"security": [ "security": [
{ {
@ -104,7 +104,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"AITools" "AI"
], ],
"summary": "Load gpu / xpu info", "summary": "Load gpu / xpu info",
"responses": { "responses": {
@ -114,7 +114,7 @@
} }
} }
}, },
"/aitool/ollama/model/del": { "/ai/ollama/model": {
"post": { "post": {
"security": [ "security": [
{ {
@ -128,51 +128,7 @@
"application/json" "application/json"
], ],
"tags": [ "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": []
}
}
},
"/aitools/ollama/model": {
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"Timestamp": []
}
],
"consumes": [
"application/json"
],
"tags": [
"AITools"
], ],
"summary": "Create Ollama model", "summary": "Create Ollama model",
"parameters": [ "parameters": [
@ -202,7 +158,7 @@
} }
} }
}, },
"/aitools/ollama/model/load": { "/ai/ollama/model/del": {
"post": { "post": {
"security": [ "security": [
{ {
@ -216,7 +172,51 @@
"application/json" "application/json"
], ],
"tags": [ "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", "summary": "Page Ollama models",
"parameters": [ "parameters": [
@ -240,7 +240,7 @@
} }
} }
}, },
"/aitools/ollama/model/search": { "/ai/ollama/model/search": {
"post": { "post": {
"security": [ "security": [
{ {
@ -254,7 +254,7 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"AITools" "AI"
], ],
"summary": "Page Ollama models", "summary": "Page Ollama models",
"parameters": [ "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": { "dto.CaptchaResponse": {
"type": "object", "type": "object",
"properties": { "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": { "dto.CommonRecover": {
"type": "object", "type": "object",
"required": [ "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": { "dto.GroupCreate": {
"type": "object", "type": "object",
"required": [ "required": [
@ -20600,6 +20522,33 @@
"ProxyCache" "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": { "dto.OllamaBindDomainReq": {
"type": "object", "type": "object",
"required": [ "required": [
@ -22105,14 +22054,6 @@
} }
} }
}, },
"dto.StateConfig": {
"type": "object",
"properties": {
"state": {
"type": "string"
}
}
},
"dto.SwapHelper": { "dto.SwapHelper": {
"type": "object", "type": "object",
"required": [ "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": { "dto.XPUInfo": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -263,29 +263,6 @@ definitions:
- permission - permission
- username - username
type: object 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: dto.CaptchaResponse:
properties: properties:
captchaID: captchaID:
@ -580,19 +557,6 @@ definitions:
required: required:
- type - type
type: object type: object
dto.CommonConfig:
properties:
action:
type: string
code:
type: integer
res:
type: string
state:
type: string
type:
type: string
type: object
dto.CommonRecover: dto.CommonRecover:
properties: properties:
detailName: detailName:
@ -1740,21 +1704,6 @@ definitions:
required: required:
- encryptionMode - encryptionMode
type: object 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: dto.GroupCreate:
properties: properties:
id: id:
@ -2497,6 +2446,24 @@ definitions:
- CACHE - CACHE
- HttpPer - HttpPer
- ProxyCache - 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: dto.OllamaBindDomainReq:
properties: properties:
appInstallID: appInstallID:
@ -3512,11 +3479,6 @@ definitions:
upload: upload:
type: string type: string
type: object type: object
dto.StateConfig:
properties:
state:
type: string
type: object
dto.SwapHelper: dto.SwapHelper:
properties: properties:
isNew: isNew:
@ -3646,50 +3608,6 @@ definitions:
type: type:
type: string type: string
type: object 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: dto.XPUInfo:
properties: properties:
deviceID: deviceID:
@ -6569,7 +6487,7 @@ info:
title: 1Panel title: 1Panel
version: "1.0" version: "1.0"
paths: paths:
/aitool/domain/bind: /ai/domain/bind:
post: post:
consumes: consumes:
- application/json - application/json
@ -6579,7 +6497,7 @@ paths:
name: request name: request
required: true required: true
schema: schema:
$ref: '#/definitions/dto.WebsiteConfig' $ref: '#/definitions/dto.OllamaBindDomain'
responses: responses:
"200": "200":
description: OK description: OK
@ -6588,8 +6506,8 @@ paths:
- Timestamp: [] - Timestamp: []
summary: Bind domain summary: Bind domain
tags: tags:
- AITools - AI
/aitool/domain/get: /ai/domain/get:
post: post:
consumes: consumes:
- application/json - application/json
@ -6610,8 +6528,8 @@ paths:
- Timestamp: [] - Timestamp: []
summary: Get bind domain summary: Get bind domain
tags: tags:
- AITools - AI
/aitool/gpu/load: /ai/gpu/load:
get: get:
consumes: consumes:
- application/json - application/json
@ -6623,35 +6541,8 @@ paths:
- Timestamp: [] - Timestamp: []
summary: Load gpu / xpu info summary: Load gpu / xpu info
tags: tags:
- AITools - AI
/aitool/ollama/model/del: /ai/ollama/model:
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:
post: post:
consumes: consumes:
- application/json - application/json
@ -6670,7 +6561,7 @@ paths:
- Timestamp: [] - Timestamp: []
summary: Create Ollama model summary: Create Ollama model
tags: tags:
- AITools - AI
x-panel-log: x-panel-log:
BeforeFunctions: [] BeforeFunctions: []
bodyKeys: bodyKeys:
@ -6678,7 +6569,34 @@ paths:
formatEN: add Ollama model [name] formatEN: add Ollama model [name]
formatZH: 添加模型 [name] formatZH: 添加模型 [name]
paramKeys: [] 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: post:
consumes: consumes:
- application/json - application/json
@ -6699,8 +6617,8 @@ paths:
- Timestamp: [] - Timestamp: []
summary: Page Ollama models summary: Page Ollama models
tags: tags:
- AITools - AI
/aitools/ollama/model/search: /ai/ollama/model/search:
post: post:
consumes: consumes:
- application/json - application/json
@ -6721,7 +6639,7 @@ paths:
- Timestamp: [] - Timestamp: []
summary: Page Ollama models summary: Page Ollama models
tags: tags:
- AITools - AI
/apps/{key}: /apps/{key}:
get: get:
consumes: consumes:

View File

@ -1,6 +1,6 @@
import { ReqPage } from '.'; import { ReqPage } from '.';
export namespace AITool { export namespace AI {
export interface OllamaModelInfo { export interface OllamaModelInfo {
name: string; name: string;
size: string; size: string;

View File

@ -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<ResPage<AITool.OllamaModelInfo>>(`/aitools/ollama/model/search`, params);
};
export const loadOllamaModel = (name: string) => {
return http.post<string>(`/aitools/ollama/model/load`, { name: name });
};
export const loadGPUInfo = () => {
return http.get<any>(`/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<AITool.BindDomainRes>(`/aitools/domain/get`, req);
};
export const updateBindDomain = (req: AITool.BindDomain) => {
return http.post(`/aitools/domain/update`, req);
};

View File

@ -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<ResPage<AI.OllamaModelInfo>>(`/ai/ollama/model/search`, params);
};
export const loadOllamaModel = (name: string) => {
return http.post<string>(`/ai/ollama/model/load`, { name: name });
};
export const loadGPUInfo = () => {
return http.get<any>(`/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.BindDomainRes>(`/ai/domain/get`, req);
};
export const updateBindDomain = (req: AI.BindDomain) => {
return http.post(`/ai/domain/update`, req);
};

View File

@ -2,27 +2,27 @@ import { Layout } from '@/routers/constant';
const databaseRouter = { const databaseRouter = {
sort: 4, sort: 4,
path: '/ai-tools', path: '/ai',
component: Layout, component: Layout,
redirect: '/ai-tools/model', redirect: '/ai/model',
meta: { meta: {
icon: 'p-jiqiren2', icon: 'p-jiqiren2',
title: 'menu.ai_tools', title: 'menu.ai_tools',
}, },
children: [ children: [
{ {
path: '/ai-tools/model', path: '/ai/model',
name: 'OllamaModel', name: 'OllamaModel',
component: () => import('@/views/ai-tools/model/index.vue'), component: () => import('@/views/ai/model/index.vue'),
meta: { meta: {
title: 'ai_tools.model.model', title: 'ai_tools.model.model',
requiresAuth: true, requiresAuth: true,
}, },
}, },
{ {
path: '/ai-tools/gpu', path: '/ai/gpu',
name: 'GPU', name: 'GPU',
component: () => import('@/views/ai-tools/gpu/index.vue'), component: () => import('@/views/ai/gpu/index.vue'),
meta: { meta: {
title: 'ai_tools.gpu.gpu', title: 'ai_tools.gpu.gpu',
requiresAuth: true, requiresAuth: true,

View File

@ -261,19 +261,19 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { loadGPUInfo } from '@/api/modules/ai-tool'; import { loadGPUInfo } from '@/api/modules/ai';
import { AITool } from '@/api/interface/ai-tool'; import { AI } from '@/api/interface/ai';
import i18n from '@/lang'; import i18n from '@/lang';
const loading = ref(); const loading = ref();
const activeNames = ref(0); const activeNames = ref(0);
const gpuInfo = ref<AITool.Info>({ const gpuInfo = ref<AI.Info>({
cudaVersion: '', cudaVersion: '',
driverVersion: '', driverVersion: '',
type: 'nvidia', type: 'nvidia',
gpu: [], gpu: [],
}); });
const xpuInfo = ref<AITool.XpuInfo>({ const xpuInfo = ref<AI.XpuInfo>({
driverVersion: '', driverVersion: '',
type: 'xpu', type: 'xpu',
xpu: [], xpu: [],

View File

@ -55,7 +55,7 @@ import i18n from '@/lang';
import { ElForm } from 'element-plus'; import { ElForm } from 'element-plus';
import DrawerHeader from '@/components/drawer-header/index.vue'; import DrawerHeader from '@/components/drawer-header/index.vue';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
import { createOllamaModel } from '@/api/modules/ai-tool'; import { createOllamaModel } from '@/api/modules/ai';
const drawerVisible = ref(false); const drawerVisible = ref(false);
const form = reactive({ const form = reactive({

View File

@ -106,7 +106,7 @@ import { Rules } from '@/global/form-rules';
import { FormInstance, FormRules } from 'element-plus'; import { FormInstance, FormRules } from 'element-plus';
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import { getAccountName } from '@/utils/util'; import { getAccountName } from '@/utils/util';
import { bindDomain, getBindDomain, updateBindDomain } from '@/api/modules/ai-tool'; import { bindDomain, getBindDomain, updateBindDomain } from '@/api/modules/ai';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
import i18n from '@/lang'; import i18n from '@/lang';

View File

@ -127,8 +127,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import AppStatus from '@/components/app-status/index.vue'; import AppStatus from '@/components/app-status/index.vue';
import AddDialog from '@/views/ai-tools/model/add/index.vue'; import AddDialog from '@/views/ai/model/add/index.vue';
import Conn from '@/views/ai-tools/model/conn/index.vue'; import Conn from '@/views/ai/model/conn/index.vue';
import Log from '@/components/log-dialog/index.vue'; import Log from '@/components/log-dialog/index.vue';
import PortJumpDialog from '@/components/port-jump/index.vue'; import PortJumpDialog from '@/components/port-jump/index.vue';
import CodemirrorDialog from '@/components/codemirror-dialog/index.vue'; import CodemirrorDialog from '@/components/codemirror-dialog/index.vue';
@ -136,12 +136,12 @@ import { computed, onMounted, reactive, ref } from 'vue';
import i18n from '@/lang'; import i18n from '@/lang';
import { App } from '@/api/interface/app'; import { App } from '@/api/interface/app';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import { deleteOllamaModel, loadOllamaModel, searchOllamaModel } from '@/api/modules/ai-tool'; import { deleteOllamaModel, loadOllamaModel, searchOllamaModel } from '@/api/modules/ai';
import { AITool } from '@/api/interface/ai-tool'; import { AI } from '@/api/interface/ai';
import { GetAppPort } from '@/api/modules/app'; import { GetAppPort } from '@/api/modules/app';
import router from '@/routers'; import router from '@/routers';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
import BindDomain from '@/views/ai-tools/model/domain/index.vue'; import BindDomain from '@/views/ai/model/domain/index.vue';
const globalStore = GlobalStore(); const globalStore = GlobalStore();
const loading = ref(false); const loading = ref(false);
@ -246,7 +246,7 @@ const checkExist = (data: App.CheckInstalled) => {
} }
}; };
const onDelete = async (row: AITool.OllamaModelInfo) => { const onDelete = async (row: AI.OllamaModelInfo) => {
ElMessageBox.confirm(i18n.global.t('commons.msg.delete'), i18n.global.t('commons.button.delete'), { ElMessageBox.confirm(i18n.global.t('commons.msg.delete'), i18n.global.t('commons.button.delete'), {
confirmButtonText: i18n.global.t('commons.button.confirm'), confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'), cancelButtonText: i18n.global.t('commons.button.cancel'),
@ -272,7 +272,7 @@ const onLoadLog = (name: string) => {
const buttons = [ const buttons = [
{ {
label: i18n.global.t('commons.button.delete'), label: i18n.global.t('commons.button.delete'),
click: (row: AITool.OllamaModelInfo) => { click: (row: AI.OllamaModelInfo) => {
onDelete(row); onDelete(row);
}, },
}, },

2
go.mod
View File

@ -58,6 +58,7 @@ require (
golang.org/x/sys v0.28.0 golang.org/x/sys v0.28.0
golang.org/x/term v0.27.0 golang.org/x/term v0.27.0
golang.org/x/text v0.21.0 golang.org/x/text v0.21.0
google.golang.org/genproto v0.0.0-20241021214115-324edc3d5d38
gopkg.in/ini.v1 v1.67.0 gopkg.in/ini.v1 v1.67.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
gorm.io/gorm v1.25.7 gorm.io/gorm v1.25.7
@ -257,7 +258,6 @@ require (
golang.org/x/sync v0.10.0 // indirect golang.org/x/sync v0.10.0 // indirect
golang.org/x/time v0.8.0 // indirect golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.28.0 // indirect golang.org/x/tools v0.28.0 // indirect
google.golang.org/genproto v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
google.golang.org/grpc v1.67.1 // indirect google.golang.org/grpc v1.67.1 // indirect