Parcourir la source

添加 AI 模型辅助分类

wcc il y a 1 an
Parent
commit
083230e991
3 fichiers modifiés avec 52 ajouts et 20 suppressions
  1. 1 0
      src/config.json
  2. 2 0
      src/main.go
  3. 49 20
      src/task/task.go

+ 1 - 0
src/config.json

@@ -19,6 +19,7 @@
         "api": "http://172.17.145.179:19281/_send/_mail"
     },
     "udpport": "1781",
+    "aiurl": "http://172.17.162.35:24401",
     "noautorun": 1,
     "fields":"detail,projectscope,title,buyer,channel",
     "controltaskrun": false,

+ 2 - 0
src/main.go

@@ -6,6 +6,7 @@ import (
 	"net/http"
 	"task"
 	"time"
+	"tools"
 	"udptask"
 	"web"
 
@@ -27,6 +28,7 @@ func main() {
 	go udptask.LastUdpJob()
 	//go task.RunTask() //定时任务o_projectinfo分类
 	go udptask.RunningHangyeClass() //根据内存中的行业分类udps执行分类任务
+	log.Println("aiurl", tools.Config["aiurl"])
 	b := make(chan bool)
 	<-b
 }

+ 49 - 20
src/task/task.go

@@ -768,32 +768,61 @@ func NewTaskRunAll(tt *TTask, budp bool, mapInfo map[string]interface{}) int {
 						//res["projectinfo"] = tmp["projectinfo"]
 					} else { //常规任务
 						SMap = NewClassificationRun(tt, tmp)
-						//一级分类时,符合结果中成交规则时
-						if SMap.Map["toptype"] == "招标" && SMap.Map["subtype"] != "单一" {
-							if _, ok := tmp["detail"]; ok {
-								if u.ChargeDetailResult(util.ObjToString(tmp["detail"])) {
-									SMap.Map["toptype"] = "结果"
-									resa := ReSub(tt, tmp, "结果")
-									subtype := resa.Map["subtype"]
-									delete(SMap.Map, "subtype")
-									SMap.Map["subtype"] = subtype
+						//1.针对招标分类的特殊处理
+						if tt.ID == "57982b4436b82b073c000001" && tt.S_name == "招标分类" {
+							//1.一级分类时,符合结果中成交规则时
+							//todo  如果没有打上分类,调用ai 模型分类
+							if _, ok := SMap.Map["toptype"]; !ok {
+								if util.ObjToString(tools.Config["aiurl"]) != "" {
+									now := time.Now()
+									data := map[string]interface{}{
+										"title":  tmp["title"],
+										"detail": tmp["detail"],
+									}
+									reqData := map[string]interface{}{
+										"texts": []interface{}{data},
+									}
+									rai := SendAi(reqData, util.ObjToString(tools.Config["aiurl"]))
+									log.Println("ai 分类时长", time.Since(now).Seconds())
+									if len(rai) > 0 {
+										resa := rai["result"]
+										if dataa, ok := resa.([]interface{}); ok {
+											da := dataa[0]
+											if len(util.ObjToString(da)) > 0 {
+												cs := strings.Split(util.ObjToString(da), "-")
+												SMap.Map["toptype"] = cs[0]
+												SMap.Map["subtype"] = cs[1]
+											}
+										}
+									}
 								}
 							}
-						}
-						//一级分类是预告,但是标题含有招标计划,同时含有 预公告|预公示,变为 采购意向
-						if SMap.Map["toptype"] == "预告" {
-							if u.DealYuce(tmp["title"].(string)) {
+							if SMap.Map["toptype"] == "招标" && SMap.Map["subtype"] != "单一" {
+								if _, ok := tmp["detail"]; ok {
+									if u.ChargeDetailResult(util.ObjToString(tmp["detail"])) {
+										SMap.Map["toptype"] = "结果"
+										resa := ReSub(tt, tmp, "结果")
+										subtype := resa.Map["subtype"]
+										delete(SMap.Map, "subtype")
+										SMap.Map["subtype"] = subtype
+									}
+								}
+							}
+							//2.一级分类是预告,但是标题含有招标计划,同时含有 预公告|预公示,变为 采购意向
+							if SMap.Map["toptype"] == "预告" {
+								if u.DealYuce(tmp["title"].(string)) {
+									SMap.Map["toptype"] = "采购意向"
+									SMap.Map["subtype"] = "采购意向"
+								}
+							}
+							//3.针对 项目登记 相关数据处理,符合条件的归类为‘采购意向’
+							if u.IsPurchasingIntent(tmp) {
 								SMap.Map["toptype"] = "采购意向"
 								SMap.Map["subtype"] = "采购意向"
 							}
 						}
-						//针对 项目登记 相关数据处理,符合条件的归类为‘采购意向’
-						if u.IsPurchasingIntent(tmp) {
-							SMap.Map["toptype"] = "采购意向"
-							SMap.Map["subtype"] = "采购意向"
-						}
 					}
-					// 针对用户行业分类,单独处理数据
+					//2.针对用户行业分类,单独处理数据
 					if mapInfo["stype"] == "yonghuhangye" || strings.TrimSpace(tt.S_name) == "用户行业分类" {
 						subs := SMap.Map["subscope_dy"]
 						delete(SMap.Map, "topscope_dy")
@@ -1671,7 +1700,7 @@ func UdpRunProjectForecast(sid, eid string) {
 	tools.Udpclient.WriteUdp(by, mu.OP_TYPE_DATA, addr)
 }
 
-// SendAi 调用大模型招标分类
+// SendAi 调用大模型招标分类;map[result:[结果-中标] status:200]
 func SendAi(data map[string]interface{}, url string) (res map[string]interface{}) {
 	// 设置 2 秒的超时
 	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)