-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
420 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package console | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
|
||
"github.com/opentdp/wechat-rest/dbase/llmodel" | ||
) | ||
|
||
type LLModel struct{} | ||
|
||
// @Summary 模型列表 | ||
// @Produce json | ||
// @Tags 中台::大语言模型 | ||
// @Param body body llmodel.FetchAllParam true "获取模型列表参数" | ||
// @Success 200 {object} []tables.LLModel | ||
// @Router /capi/llmodel./list [post] | ||
func (*LLModel) list(c *gin.Context) { | ||
|
||
var rq *llmodel.FetchAllParam | ||
|
||
if err := c.ShouldBind(&rq); err != nil { | ||
c.Set("Error", err) | ||
return | ||
} | ||
|
||
if lst, err := llmodel.FetchAll(rq); err == nil { | ||
c.Set("Payload", lst) | ||
} else { | ||
c.Set("Error", err) | ||
} | ||
|
||
} | ||
|
||
// @Summary 获取模型 | ||
// @Produce json | ||
// @Tags 中台::大语言模型 | ||
// @Param body body llmodel.FetchParam true "获取模型参数" | ||
// @Success 200 {object} tables.LLModel | ||
// @Router /capi/llmodel./detail [post] | ||
func (*LLModel) detail(c *gin.Context) { | ||
|
||
var rq *llmodel.FetchParam | ||
|
||
if err := c.ShouldBind(&rq); err != nil { | ||
c.Set("Error", err) | ||
return | ||
} | ||
|
||
if res, err := llmodel.Fetch(rq); err == nil { | ||
c.Set("Payload", res) | ||
} else { | ||
c.Set("Error", err) | ||
} | ||
|
||
} | ||
|
||
// @Summary 添加模型 | ||
// @Produce json | ||
// @Tags 中台::大语言模型 | ||
// @Param body body llmodel.CreateParam true "添加模型参数" | ||
// @Success 200 | ||
// @Router /capi/llmodel./create [post] | ||
func (*LLModel) create(c *gin.Context) { | ||
|
||
var rq *llmodel.CreateParam | ||
|
||
if err := c.ShouldBind(&rq); err != nil { | ||
c.Set("Error", err) | ||
return | ||
} | ||
|
||
if id, err := llmodel.Create(rq); err == nil { | ||
c.Set("Message", "添加成功") | ||
c.Set("Payload", id) | ||
} else { | ||
c.Set("Error", err) | ||
} | ||
|
||
} | ||
|
||
// @Summary 修改模型 | ||
// @Produce json | ||
// @Tags 中台::大语言模型 | ||
// @Param body body llmodel.UpdateParam true "修改模型参数" | ||
// @Success 200 | ||
// @Router /capi/llmodel./update [post] | ||
func (*LLModel) update(c *gin.Context) { | ||
|
||
var rq *llmodel.UpdateParam | ||
|
||
if err := c.ShouldBind(&rq); err != nil { | ||
c.Set("Error", err) | ||
return | ||
} | ||
|
||
if err := llmodel.Update(rq); err == nil { | ||
c.Set("Message", "更新成功") | ||
} else { | ||
c.Set("Error", err) | ||
} | ||
|
||
} | ||
|
||
// @Summary 删除模型 | ||
// @Produce json | ||
// @Tags 中台::大语言模型 | ||
// @Param body body llmodel.DeleteParam true "删除模型参数" | ||
// @Success 200 | ||
// @Router /capi/llmodel./delete [post] | ||
func (*LLModel) delete(c *gin.Context) { | ||
|
||
var rq *llmodel.DeleteParam | ||
|
||
if err := c.ShouldBind(&rq); err != nil { | ||
c.Set("Error", err) | ||
return | ||
} | ||
|
||
if err := llmodel.Delete(rq); err == nil { | ||
c.Set("Message", "删除成功") | ||
} else { | ||
c.Set("Error", err) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.