Browse Source

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

Roc 1 week ago
parent
commit
90564ad2a5
3 changed files with 43 additions and 1 deletions
  1. 37 0
      cache/llm.go
  2. 4 0
      services/report.go
  3. 2 1
      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
 }
 

+ 2 - 1
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报告入知识库处理
 )
 
 // 商户号
@@ -179,7 +180,7 @@ const (
 const CACHE_EDB_UPDATE_LOG_ID = "eta:edb_update_log:id"
 
 const (
-	CACHE_WECHAT_PLATFORM_ARTICLE = "wechat_platform:article:op" //微信文章处理
+	CACHE_WECHAT_PLATFORM_ARTICLE = "wechat_platform:article:op:" //微信文章处理
 )
 
 // 指标引用对象