瀏覽代碼

Merge remote-tracking branch 'origin/feature/deepseek_rag_2.0' into debug

Roc 6 天之前
父節點
當前提交
85cd31b947

+ 27 - 0
controllers/llm/wechat_platform.go

@@ -573,6 +573,33 @@ func (c *WechatPlatformController) ArticleList() {
 		}
 	}
 
+	// 标签处理
+	{
+		wechatPlateIdList := make([]int, 0)
+		for _, v := range viewList {
+			wechatPlateIdList = append(wechatPlateIdList, v.WechatPlatformId)
+		}
+		obj := rag.WechatPlatformTagMapping{}
+		mappingList, err := obj.GetWechatPlatformTagListByWechatPlatformIdList(wechatPlateIdList)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		wechatPlatformIdMap := make(map[int]*rag.WechatPlatformTagItem)
+		for _, v := range mappingList {
+			wechatPlatformIdMap[v.WechatPlatformId] = v
+		}
+		for k, v := range viewList {
+			item, ok := wechatPlatformIdMap[v.WechatPlatformId]
+			if !ok {
+				continue
+			}
+			viewList[k].TagName = item.TagName
+			viewList[k].TagId = item.TagId
+		}
+	}
+
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := response.WechatArticleListListResp{
 		List:   viewList,

+ 2 - 0
models/rag/wechat_article.go

@@ -93,6 +93,8 @@ type WechatArticleView struct {
 	CreateTime                 string `gorm:"column:create_time;type:datetime;comment:入库时间;default:NULL;" description:"入库时间"`
 	WechatPlatformName         string `gorm:"column:title;type:varchar(255);comment:标题;" description:"微信公众号名称"`
 	WechatPlatformRoundHeadImg string `gorm:"column:round_head_img;type:varchar(255);comment:头像;" description:"微信公众号头像"`
+	TagName                    string `gorm:"column:tag_name;type:varchar(255);comment:标签名称;" description:"标签名称"`
+	TagId                      int    `gorm:"column:tag_id;type:varchar(255);comment:标签id;" description:"标签id"`
 }
 
 func (m *WechatArticle) ToView() WechatArticleView {

+ 18 - 0
models/rag/wechat_platform_tag_mapping.go

@@ -80,3 +80,21 @@ func (m *WechatPlatformTagMapping) GetPageListByCondition(condition string, pars
 
 	return
 }
+
+type WechatPlatformTagItem struct {
+	TagId            int    `json:"tag_id"`
+	TagName          string `json:"tag_name"`
+	WechatPlatformId int    `json:"tag_article"`
+}
+
+func (m *WechatPlatformTagMapping) GetWechatPlatformTagListByWechatPlatformIdList(wechatPlatformIdList []int) (items []*WechatPlatformTagItem, err error) {
+	num := len(wechatPlatformIdList)
+	if num <= 0 {
+		return
+	}
+	sqlStr := `SELECT a.wechat_platform_id,b.tag_id,b.tag_name FROM wechat_platform_tag_mapping AS a 
+    JOIN tag AS b on a.tag_id = b.tag_id  WHERE a.wechat_platform_id IN (?) GROUP BY a.wechat_platform_id `
+	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, wechatPlatformIdList).Find(&items).Error
+
+	return
+}

+ 1 - 1
utils/llm/eta_llm/eta_llm_client.go

@@ -161,7 +161,7 @@ func (ds *ETALLMClient) FileChat(query string, KnowledgeId string, history []jso
 		TopK:           20,
 		ScoreThreshold: 2,
 		Stream:         false,
-		Temperature:    0.3,
+		Temperature:    0.01,
 		MaxTokens:      0,
 		PromptName:     DEFALUT_PROMPT_NAME,
 	}