瀏覽代碼

Merge branch 'feature/deepseek_rag_2.0' into debug

kobe6258 1 周之前
父節點
當前提交
b57497b4bb
共有 3 個文件被更改,包括 24 次插入2 次删除
  1. 12 1
      controllers/llm/promote_controller.go
  2. 5 0
      services/llm/facade/llm_service.go
  3. 7 1
      services/wechat_platform.go

+ 12 - 1
controllers/llm/promote_controller.go

@@ -56,12 +56,23 @@ func (pCtrl *PromoteController) GenerateContent() {
 		Role:     "user",
 		SendTime: userSendTime.Format(utils.FormatDateTime),
 	}
+	article, err := rag.GetArticleById(gcReq.WechatArticleId)
+	if err != nil {
+		br.Msg = "获取公众号内容失败"
+		br.ErrMsg = "获取公众号内容失败,Err:" + err.Error()
+		return
+	}
+	if article.TextContent == "" {
+		br.Msg = "暂不支持纯文本以外的内容生成"
+		br.ErrMsg = "暂不支持纯文本以外的内容生成"
+		return
+	}
 	res, err := facade.AIGCBaseOnPromote(facade.AIGC{
 		Promote:   gcReq.Promote,
 		ArticleId: gcReq.WechatArticleId,
 	})
 	if err != nil {
-		br.Msg = "内容生成失败"
+		br.Msg = err.Error()
 		br.ErrMsg = "内容生成失败,Err:" + err.Error()
 		return
 	}

+ 5 - 0
services/llm/facade/llm_service.go

@@ -65,6 +65,11 @@ func AIGCBaseOnPromote(aigc AIGC) (resp bus_response.AIGCEtaResponse, err error)
 				err = fmt.Errorf("公众号文章不存在")
 				return
 			}
+			if article.TextContent == "" {
+				utils.FileLog.Error("暂不支持纯文本以外的内容生成")
+				err = fmt.Errorf("暂不支持纯文本以外的内容生成")
+				return
+			}
 			// 文章加入到知识库
 			path, fileErr := localService.CreateArticleFile(article)
 			if fileErr != nil {

+ 7 - 1
services/wechat_platform.go

@@ -226,8 +226,14 @@ func BeachAddWechatArticle(item *rag.WechatPlatform, num int) {
 		// 把刚搜索的文章加入到指标库
 		AddWechatArticle(item, articleMenu.Link, articleDetail, &articleMenu)
 
-		time.Sleep(10 * time.Second)
+		//time.Sleep(10 * time.Second)
 
+		// 随机休眠,至少大于10s
+		sleepTimeInt := utils.GetRandInt(10, 20)
+		if sleepTimeInt < 10 {
+			sleepTimeInt = 10
+		}
+		time.Sleep(time.Duration(sleepTimeInt) * time.Second)
 	}
 	return
 }