123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- package llm
- import (
- "encoding/json"
- "eta/eta_api/controllers"
- "eta/eta_api/controllers/llm/llm_http"
- "eta/eta_api/models"
- "eta/eta_api/services/llm/facade"
- "eta/eta_api/utils"
- )
- type PromoteController struct {
- controllers.BaseAuthController
- }
- // PromoteTrainRecordList @Title 获取聊天记录
- // @Description 获取聊天记录
- // @Success 101 {object} response.ListResp
- // @router /promote/train_list [get]
- func (pCtrl *PromoteController) PromoteTrainRecordList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- pCtrl.Data["json"] = br
- pCtrl.ServeJSON()
- }()
- sysUser := pCtrl.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- pageSize, _ := pCtrl.GetInt("PageSize")
- currentIndex, _ := pCtrl.GetInt("CurrentIndex")
- //var total, startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize5
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- //startSize = paging.StartIndex(currentIndex, pageSize)
- //page := paging.GetPaging(currentIndex, pageSize, total)
- //total, err := rag.CountQuestionList()
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- //}
- //list, err := models.GetPptV2List(condition, pars, startSize, pageSize)
- //if err != nil {
- // br.Msg = "获取失败"
- // br.ErrMsg = "获取失败,Err:" + err.Error()
- // return
- //}
- br.Data = nil
- br.Ret = 200
- br.Success = true
- br.Msg = "获取聊天记录成功"
- }
- // GenerateContent @Title 生成问答内容
- // @Description 生成问答内容
- // @Success 101 {object} response.ListResp
- // @router /promote/generate_content [post]
- func (pCtrl *PromoteController) GenerateContent() {
- br := new(models.BaseResponse).Init()
- defer func() {
- pCtrl.Data["json"] = br
- pCtrl.ServeJSON()
- }()
- var gcReq llm_http.GenerateContentReq
- err := json.Unmarshal(pCtrl.Ctx.Input.RequestBody, &gcReq)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- sysUser := pCtrl.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- if gcReq.Promote == "" {
- br.Msg = "提示词不能为空"
- br.ErrMsg = "提示词不能为空"
- return
- }
- if gcReq.WechatArticleId <= 0 {
- br.Msg = "公众号文章编号非法"
- br.ErrMsg = "公众号文章编号非法"
- return
- }
- res, err := facade.AIGCBaseOnPromote(facade.AIGC{
- Promote: gcReq.Promote,
- ArticleId: gcReq.WechatArticleId,
- })
- if err != nil {
- br.Msg = "内容生成失败"
- br.ErrMsg = "内容生成失败,Err:" + err.Error()
- return
- }
- br.Data = res
- br.Ret = 200
- br.Success = true
- br.Msg = "内容生成成功"
- }
|