未验证 提交 ee40ddd8 编写于 作者: P Petrus 提交者: GitHub

add CheckLLMIntegration api (#2894)

Signed-off-by: NPatrick Zhao <zhaoyu@koderover.com>
上级 d05a3438
......@@ -98,6 +98,26 @@ func ListLLMIntegration(c *gin.Context) {
ctx.Resp, ctx.Err = service.ListLLMIntegration(context.TODO())
}
type checkLLMIntegrationResponse struct {
Check bool `json:"check"`
}
// @Summary Check llm integrations
// @Description Check llm integrations
// @Tags system
// @Accept json
// @Produce json
// @Success 200 {object} checkLLMIntegrationResponse
// @Router /api/aslan/system/llm/integration/check [get]
func CheckLLMIntegration(c *gin.Context) {
ctx := internalhandler.NewContext(c)
defer func() { internalhandler.JSONResponse(c, ctx) }()
resp := &checkLLMIntegrationResponse{}
resp.Check, ctx.Err = service.CheckLLMIntegration(context.TODO())
ctx.Resp = resp
}
// @Summary Update a llm integration
// @Description Update a llm integration
// @Tags system
......
......@@ -352,6 +352,7 @@ func (*Router) Inject(router *gin.RouterGroup) {
{
llm.POST("/integration", CreateLLMIntegration)
llm.GET("/integration", ListLLMIntegration)
llm.GET("/integration/check", CheckLLMIntegration)
llm.GET("/integration/:id", GetLLMIntegration)
llm.PUT("/integration/:id", UpdateLLMIntegration)
llm.DELETE("/integration/:id", DeleteLLMIntegration)
......
......@@ -26,6 +26,21 @@ import (
"github.com/koderover/zadig/pkg/tool/log"
)
func CheckLLMIntegration(ctx context.Context) (bool, error) {
count, err := commonrepo.NewLLMIntegrationColl().Count(ctx)
if err != nil {
fmtErr := fmt.Errorf("CheckLLMIntegration err: %w", err)
log.Error(fmtErr)
return false, e.ErrListLLMIntegration.AddErr(fmtErr)
}
if count == 0 {
return false, nil
}
return true, nil
}
func GetLLMIntegration(ctx context.Context, id string) (*commonmodels.LLMIntegration, error) {
llmIntegration, err := commonrepo.NewLLMIntegrationColl().FindByID(ctx, id)
if err != nil {
......
......@@ -2154,6 +2154,29 @@ const docTemplate = `{
}
}
},
"/api/aslan/system/llm/integration/check": {
"get": {
"description": "Check llm integrations",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Check llm integrations",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.checkLLMIntegrationResponse"
}
}
}
}
},
"/api/aslan/system/llm/integration/{id}": {
"get": {
"description": "Get a llm integration",
......@@ -2792,6 +2815,14 @@ const docTemplate = `{
}
}
},
"handler.checkLLMIntegrationResponse": {
"type": "object",
"properties": {
"check": {
"type": "boolean"
}
}
},
"handler.createServiceTemplateRequest": {
"type": "object",
"required": [
......
......@@ -2145,6 +2145,29 @@
}
}
},
"/api/aslan/system/llm/integration/check": {
"get": {
"description": "Check llm integrations",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Check llm integrations",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handler.checkLLMIntegrationResponse"
}
}
}
}
},
"/api/aslan/system/llm/integration/{id}": {
"get": {
"description": "Get a llm integration",
......@@ -2783,6 +2806,14 @@
}
}
},
"handler.checkLLMIntegrationResponse": {
"type": "object",
"properties": {
"check": {
"type": "boolean"
}
}
},
"handler.createServiceTemplateRequest": {
"type": "object",
"required": [
......
......@@ -167,6 +167,11 @@ definitions:
name:
type: string
type: object
handler.checkLLMIntegrationResponse:
properties:
check:
type: boolean
type: object
handler.createServiceTemplateRequest:
properties:
product_name:
......@@ -3416,6 +3421,21 @@ paths:
summary: Update a llm integration
tags:
- system
/api/aslan/system/llm/integration/check:
get:
consumes:
- application/json
description: Check llm integrations
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/handler.checkLLMIntegrationResponse'
summary: Check llm integrations
tags:
- system
/api/aslan/system/webhook/config:
get:
consumes:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册