瀏覽代碼

Merge remote-tracking branch 'origin/rag/3.1' into debug

Roc 1 周之前
父節點
當前提交
efdf5eed9a
共有 4 個文件被更改,包括 54 次插入14 次删除
  1. 37 0
      cache/llm.go
  2. 4 0
      services/report.go
  3. 12 14
      services/wechat_platform.go
  4. 1 0
      utils/constants.go

+ 37 - 0
cache/llm.go

@@ -0,0 +1,37 @@
+package cache
+
+import (
+	"eta/eta_task/utils"
+	"fmt"
+)
+
+type RagEtaReportOpOp struct {
+	Source          string
+	ReportId        int
+	ReportChapterId int
+}
+
+// RagEtaReportOpToCache
+// @Description: 将eta报告入知识库操作加入缓存
+// @author: Roc
+// @datetime 2025-04-07 15:05:22
+// @param reportId int
+// @param reportChapterId int
+// @param source string
+// @return bool
+func RagEtaReportOpToCache(reportId, reportChapterId int, source string) bool {
+	record := new(RagEtaReportOpOp)
+	record.Source = source
+	record.ReportId = reportId
+	record.ReportChapterId = reportChapterId
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CACHE_ETA_REPORT_KNOWLEDGE, record)
+
+		utils.FileLog.Info(fmt.Sprintf("将eta报告入知识库操作加入缓存 加入缓存 RagEtaReportOpToCache LPush: 操作类型:%s,报告id:%d,章节id:%d", source, reportId, reportChapterId))
+		if err != nil {
+			fmt.Println("RagEtaReportOpToCache LPush Err:" + err.Error())
+		}
+		return true
+	}
+	return false
+}

+ 4 - 0
services/report.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"errors"
+	"eta/eta_task/cache"
 	"eta/eta_task/models"
 	"eta/eta_task/models/report"
 	"eta/eta_task/services/alarm_msg"
@@ -273,6 +274,9 @@ func handleByPublishReport(item *models.Report) {
 		}
 	}
 
+	// 报告发布成功后,需要将相关信息入知识库
+	go cache.RagEtaReportOpToCache(item.Id, 0, `publish`)
+
 	return
 }
 

+ 12 - 14
services/wechat_platform.go

@@ -2,10 +2,8 @@ package services
 
 import (
 	"context"
-	"eta/eta_task/models/rag"
 	"eta/eta_task/utils"
 	"fmt"
-	"time"
 )
 
 type WechatArticleOp struct {
@@ -41,18 +39,18 @@ func AddWechatArticleOpToCache(wechatPlatformId int, source string) bool {
 // @param cont context.Context
 // @return err error
 func RefreshWechatPlatform(cont context.Context) (err error) {
-	utils.FileLog.Debug("RefreshWechatPlatform:", time.Now().Format(utils.FormatDateTime))
-	obj := new(rag.WechatPlatform)
-	platformList, tmpErr := obj.GetListByCondition(` AND enabled = 1 `, []interface{}{}, 0, 100000)
-	if tmpErr != nil {
-		err = tmpErr
-		return
-	}
-
-	for _, v := range platformList {
-		AddWechatArticleOpToCache(v.WechatPlatformId, "refresh")
-		time.Sleep(1 * time.Minute)
-	}
+	//utils.FileLog.Debug("RefreshWechatPlatform:", time.Now().Format(utils.FormatDateTime))
+	//obj := new(rag.WechatPlatform)
+	//platformList, tmpErr := obj.GetListByCondition(` AND enabled = 1 `, []interface{}{}, 0, 100000)
+	//if tmpErr != nil {
+	//	err = tmpErr
+	//	return
+	//}
+	//
+	//for _, v := range platformList {
+	//	AddWechatArticleOpToCache(v.WechatPlatformId, "refresh")
+	//	time.Sleep(1 * time.Minute)
+	//}
 
 	return
 }

+ 1 - 0
utils/constants.go

@@ -157,6 +157,7 @@ const (
 // 缓存key
 const (
 	CACHE_CREATE_REPORT_IMGPDF_QUEUE = "eta_report:report_img_pdf_queue" // 生成报告长图PDF队列
+	CACHE_ETA_REPORT_KNOWLEDGE       = "eta:report:knowledge:op:"        //eta报告入知识库处理
 )
 
 // 商户号