Browse Source

Merge remote-tracking branch 'origin/eta/2.6.4' into debug

# Conflicts:
#	utils/constants.go
Roc 3 weeks ago
parent
commit
dd726215ad

+ 10 - 2
controllers/data_manage/ai_predict_model/index.go

@@ -1368,7 +1368,7 @@ func (this *AiPredictModelIndexController) Run() {
 	}
 
 	// 获取列表
-	list, e := indexOb.GetItemsByCondition(cond, pars, []string{`ai_predict_model_index_id`}, "")
+	list, e := indexOb.GetItemsByCondition(cond, pars, []string{`ai_predict_model_index_id,ai_predict_model_index_config_id,script_path`}, "")
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = fmt.Sprintf("获取列表失败, %v", e)
@@ -1377,6 +1377,14 @@ func (this *AiPredictModelIndexController) Run() {
 
 	indexIdList := make([]int, 0)
 	for _, v := range list {
+		// 没有配置python脚本路径
+		if v.ScriptPath == `` {
+			continue
+		}
+		// 没有配置默认参数
+		if v.AiPredictModelIndexConfigId <= 0 {
+			continue
+		}
 		indexIdList = append(indexIdList, v.AiPredictModelIndexId)
 	}
 
@@ -1399,7 +1407,7 @@ func (this *AiPredictModelIndexController) Run() {
 	br.Data = indexIdList
 	br.Ret = 200
 	br.Success = true
-	br.Msg = "获取成功"
+	br.Msg = "运行成功"
 }
 
 // getAllSearchDataSource

+ 1 - 2
controllers/data_manage/ai_predict_model/index_config.go

@@ -330,10 +330,9 @@ func (c *AiPredictModelIndexConfigController) ChartDetail() {
 		return
 	}
 
-	// 查找是否被标的引用为默认模型
 	// 查询标的情况
 	indexOb := new(aiPredictModel.AiPredictModelIndex)
-	indexItem, e := indexOb.GetItemByConfigId(configItem.AiPredictModelIndexConfigId)
+	indexItem, e := indexOb.GetItemById(configItem.AiPredictModelIndexId)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = fmt.Sprintf("获取失败,根据配置ID获取标的信息失败, %v", e)

+ 0 - 8
controllers/llm/abstract.go

@@ -412,11 +412,3 @@ func (c *AbstractController) AddVector() {
 //
 //	fmt.Println("结束")
 //}
-
-//// init
-//// @Description: 修复微信文章摘要的标签
-//// @author: Roc
-//// @datetime 2025-05-08 18:04:50
-//func init() {
-//	services.FixWechatArticleAbstractTag()
-//}

+ 7 - 6
models/ai_predict_model/request/index_config.go

@@ -15,18 +15,19 @@ type TrainReq struct {
 // ConfigParams
 // @Description: 训练参数
 type ConfigParams struct {
+	Seed            int     `json:"seed" description:"随机种子,如:42"`
 	Objective       string  `json:"objective" description:"目标(回归任务),枚举值,squarederror、multi、sofamax;默认值:squarederror" `
+	EvalMetric      string  `json:"eval_metric" description:"评估指标,枚举值,rmse、auc logloss、merror;默认值:rmse"`
+	MaxDeltaStep    int     `json:"max_delta_step" description:"最大步长,如:5;正整数,必须大于0"`
+	TreeMethod      string  `json:"tree_method" description:"树构建方法,枚举值:auto、exact、approx、hist;默认值:auto"`
+	NumBoostRound   int     `json:"num_boost_round" description:"迭代次数;正整数,必须大于0"`
 	LearningRate    float64 `json:"learning_rate" description:"学习率,如:0.0881"`
 	MaxDepth        int     `json:"max_depth" description:"最大深度(控制树的深度,防止过拟合),如:4;正整数,必须大于0"`
-	MinChildWeight  float64 `json:"min_child_weight" description:"最小子节点权重(防止过拟合),如:6.0601"`
+	MinChildWeight  int     `json:"min_child_weight" description:"最小子节点权重(防止过拟合),如:6.0601"`
 	Subsample       float64 `json:"subsample" description:"随机采样(防止过拟合),如:0.9627"`
 	ColsampleBytree float64 `json:"colsample_bytree" description:"特征随机采样(防止过拟合),如:0.7046"`
 	Gamma           float64 `json:"gamma" description:"控制分裂,如:0.4100"`
 	RegAlpha        float64 `json:"reg_alpha" description:"L1正则化系数,如:0.3738"`
 	ReqLambda       float64 `json:"reg_lambda" description:"L2正则化系数,如:1.4775"`
-	EvalMetric      string  `json:"eval_metric" description:"评估指标,枚举值,rmse、auc logloss、merror;默认值:rmse"`
-	Seed            float64 `json:"seed" description:"随机种子,如:42"`
-	MaxDeltaStep    int     `json:"max_delta_step" description:"最大步长,如:5;正整数,必须大于0"`
-	TreeMethod      string  `json:"tree_method" description:"树构建方法,枚举值:auto、exact、approx、hist;默认值:auto"`
-	NumBoostRound   int     `json:"num_boost_round" description:"迭代次数;正整数,必须大于0"`
+	Booster         string  `json:"booster" description:"使用哪种补充包。可以是,或;使用基于树的模型,同时使用线性函数。枚举值:gbtree、gblinear、dart、gbtree、dart、gblinear"`
 }

+ 8 - 8
models/data_manage/index_task.go

@@ -68,32 +68,32 @@ var IndexTaskColumns = struct {
 }
 
 func (m *IndexTask) Create() (err error) {
-	err = global.DbMap[utils.DbNameAI].Create(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Create(&m).Error
 
 	return
 }
 
 func (m *IndexTask) Update(updateCols []string) (err error) {
-	err = global.DbMap[utils.DbNameAI].Select(updateCols).Updates(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Select(updateCols).Updates(&m).Error
 
 	return
 }
 
 func (m *IndexTask) Del() (err error) {
-	err = global.DbMap[utils.DbNameAI].Delete(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Delete(&m).Error
 
 	return
 }
 
 func (m *IndexTask) GetByID(id int) (item *IndexTask, err error) {
-	err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s = ?", IndexTaskColumns.IndexTaskID), id).First(&item).Error
+	err = global.DbMap[utils.DbNameIndex].Where(fmt.Sprintf("%s = ?", IndexTaskColumns.IndexTaskID), id).First(&item).Error
 
 	return
 }
 
 func (m *IndexTask) GetByCondition(condition string, pars []interface{}) (item *IndexTask, err error) {
 	sqlStr := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).First(&item).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).First(&item).Error
 
 	return
 }
@@ -104,7 +104,7 @@ func (m *IndexTask) GetListByCondition(field, condition string, pars []interface
 	}
 	sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s order by index_task_id desc LIMIT ?,?`, field, m.TableName(), condition)
 	pars = append(pars, startSize, pageSize)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Find(&items).Error
 
 	return
 }
@@ -112,7 +112,7 @@ func (m *IndexTask) GetListByCondition(field, condition string, pars []interface
 func (m *IndexTask) GetCountByCondition(condition string, pars []interface{}) (total int, err error) {
 	var intNull sql.NullInt64
 	sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Scan(&intNull).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Scan(&intNull).Error
 	if err == nil && intNull.Valid {
 		total = int(intNull.Int64)
 	}
@@ -128,7 +128,7 @@ func (m *IndexTask) GetCountByCondition(condition string, pars []interface{}) (t
 // @param indexRecordList []*IndexTaskRecord
 // @return err error
 func AddIndexTask(indexTask *IndexTask, indexRecordList []*IndexTaskRecord) (err error) {
-	to := global.DbMap[utils.DbNameAI].Begin()
+	to := global.DbMap[utils.DbNameIndex].Begin()
 	defer func() {
 		if err != nil {
 			_ = to.Rollback()

+ 8 - 8
models/data_manage/index_task_record.go

@@ -44,32 +44,32 @@ var IndexTaskRecordColumns = struct {
 }
 
 func (m *IndexTaskRecord) Create() (err error) {
-	err = global.DbMap[utils.DbNameAI].Create(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Create(&m).Error
 
 	return
 }
 
 func (m *IndexTaskRecord) Update(updateCols []string) (err error) {
-	err = global.DbMap[utils.DbNameAI].Select(updateCols).Updates(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Select(updateCols).Updates(&m).Error
 
 	return
 }
 
 func (m *IndexTaskRecord) Del() (err error) {
-	err = global.DbMap[utils.DbNameAI].Delete(&m).Error
+	err = global.DbMap[utils.DbNameIndex].Delete(&m).Error
 
 	return
 }
 
 func (m *IndexTaskRecord) GetByID(id int) (item *IndexTaskRecord, err error) {
-	err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s = ?", IndexTaskRecordColumns.IndexTaskRecordID), id).First(&item).Error
+	err = global.DbMap[utils.DbNameIndex].Where(fmt.Sprintf("%s = ?", IndexTaskRecordColumns.IndexTaskRecordID), id).First(&item).Error
 
 	return
 }
 
 func (m *IndexTaskRecord) GetByCondition(condition string, pars []interface{}) (item *IndexTaskRecord, err error) {
 	sqlStr := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).First(&item).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).First(&item).Error
 
 	return
 }
@@ -79,7 +79,7 @@ func (m *IndexTaskRecord) GetAllListByCondition(field, condition string, pars []
 		field = "*"
 	}
 	sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s order by index_task_record_id desc `, field, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Find(&items).Error
 
 	return
 }
@@ -90,7 +90,7 @@ func (m *IndexTaskRecord) GetListByCondition(field, condition string, pars []int
 	}
 	sqlStr := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s order by index_task_record_id desc LIMIT ?,?`, field, m.TableName(), condition)
 	pars = append(pars, startSize, pageSize)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Find(&items).Error
 
 	return
 }
@@ -98,7 +98,7 @@ func (m *IndexTaskRecord) GetListByCondition(field, condition string, pars []int
 func (m *IndexTaskRecord) GetCountByCondition(condition string, pars []interface{}) (total int, err error) {
 	var intNull sql.NullInt64
 	sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s WHERE 1=1 %s`, m.TableName(), condition)
-	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Scan(&intNull).Error
+	err = global.DbMap[utils.DbNameIndex].Raw(sqlStr, pars...).Scan(&intNull).Error
 	if err == nil && intNull.Valid {
 		total = int(intNull.Int64)
 	}

+ 4 - 0
services/ai_predict_model_index_config.go

@@ -151,3 +151,7 @@ func addIndexTaskToCache(indexTaskId int, taskType string) {
 		cache.AddIndexTaskRecordOpToCache(item.IndexTaskRecordID, taskType)
 	}
 }
+
+func AddIndexTaskToCache(indexTaskId int, taskType string) {
+	addIndexTaskToCache(indexTaskId, taskType)
+}

+ 1 - 1
services/llm_report.go

@@ -741,7 +741,7 @@ func delRagEtaReportAbstract(list []*rag.RagEtaReportAbstract) (err error) {
 
 	// 删除es数据
 	for _, wechatArticleAbstractId := range newAbstractIdList {
-		go DelEsRagEtaReportAbstract(wechatArticleAbstractId)
+		DelEsRagEtaReportAbstract(wechatArticleAbstractId)
 	}
 
 	return

+ 5 - 59
services/wechat_platform.go

@@ -1267,7 +1267,7 @@ func delWechatArticleAbstract(list []*rag.WechatArticleAbstract) (err error) {
 
 	// 删除es数据
 	for _, wechatArticleAbstractId := range newAbstractIdList {
-		go DelEsWechatArticleAbstract(wechatArticleAbstractId)
+		DelEsWechatArticleAbstract(wechatArticleAbstractId)
 	}
 
 	return
@@ -1375,6 +1375,10 @@ func extractLabels(text string) (tags []string) {
 
 	// 将去重后的标签转换为切片
 	for tag := range tagSet {
+		// 为空串就不处理
+		if tag == `` {
+			continue
+		}
 		tags = append(tags, tag)
 	}
 	return
@@ -1423,61 +1427,3 @@ func GetTagIdByName(tagName string) (tagId int, err error) {
 
 	return
 }
-
-// FixWechatArticleAbstractTag
-// @Description: 修复微信文章摘要的标签
-// @author: Roc
-// @datetime 2025-05-08 18:03:55
-func FixWechatArticleAbstractTag() {
-	obj := rag.WechatArticleAbstract{}
-	list, err := obj.GetListByCondition(` wechat_article_id `, ` AND wechat_platform_id = ? `, []interface{}{1}, 0, 100000)
-	if err != nil {
-		fmt.Println(`获取摘要列表失败,err:`, err)
-		return
-	}
-
-	for _, v := range list {
-		tagNameList := extractLabels(v.Content)
-		if len(tagNameList) <= 0 {
-			continue
-		}
-
-		var tagIdJsonStr string
-		var tagNameJsonStr string
-
-		tagIdList := make([]int, 0)
-		tagIdMap := make(map[int]bool)
-
-		for _, tagName := range tagNameList {
-			tagId, tmpErr := GetTagIdByName(tagName)
-			if tmpErr != nil {
-				utils.FileLog.Info(fmt.Sprintf("获取标签ID失败,标签名称:%s,Err:%s", tagName, tmpErr.Error()))
-			}
-			if _, ok := tagIdMap[tagId]; !ok {
-				tagIdList = append(tagIdList, tagId)
-				tagNameList = append(tagNameList, tagName)
-				tagIdMap[tagId] = true
-			}
-		}
-
-		tagIdJsonByte, tmpErr := json.Marshal(tagIdList)
-		if tmpErr != nil {
-			utils.FileLog.Info(fmt.Sprintf("标签ID序列化失败,Err:%s", tmpErr.Error()))
-		} else {
-			tagIdJsonStr = string(tagIdJsonByte)
-		}
-
-		tagNameJsonStr = strings.Join(tagNameList, `,`)
-
-		v.Tags = tagIdJsonStr
-		v.TagsName = tagNameJsonStr
-		v.ModifyTime = time.Now()
-		err = v.Update([]string{"tags", "tags_name", "modify_time"})
-		if err != nil {
-			fmt.Println(v.WechatArticleAbstractId, ";标签修改失败")
-			continue
-		}
-
-		AddOrEditEsWechatArticleAbstract(v.WechatArticleAbstractId)
-	}
-}

+ 10 - 0
utils/common.go

@@ -2949,6 +2949,16 @@ func GetExcelDate(strDate string) (newDate time.Time, err error) {
 		return
 	}
 
+	newDate, _ = time.ParseInLocation(FormatDate, strDate, time.Local)
+	if !newDate.IsZero() {
+		return
+	}
+
+	newDate, _ = time.ParseInLocation(FormatDateUnSpace, strDate, time.Local)
+	if !newDate.IsZero() {
+		return
+	}
+
 	//可能是excel的日期格式
 	_, tmpErr := strconv.Atoi(strDate)
 	if tmpErr != nil {