This commit is contained in:
parent
d6121f9e0c
commit
775921b344
13
ai.go
13
ai.go
|
@ -42,8 +42,17 @@ func getCategoryWithAi(ctx context.Context, goodsName string, address string) (c
|
|||
return
|
||||
}
|
||||
cateInfo := strings.Split(resMap.Predictions[0].Category, "_")
|
||||
cateId, _ = strconv.Atoi(cateInfo[1])
|
||||
return cateId, cateInfo[0], resMap.Predictions[0].Confidence, nil
|
||||
if len(cateInfo) != 2 {
|
||||
cateName = ""
|
||||
cateId = 0.000000
|
||||
} else {
|
||||
cateName = cateInfo[0]
|
||||
cateId, err = strconv.Atoi(cateInfo[1])
|
||||
if err != nil {
|
||||
}
|
||||
}
|
||||
|
||||
return cateId, cateName, resMap.Predictions[0].Confidence, nil
|
||||
}
|
||||
|
||||
type Category struct {
|
||||
|
|
|
@ -86,7 +86,7 @@ func goodsAll() (data []Goods) {
|
|||
row Goods
|
||||
err error
|
||||
)
|
||||
rows, _ := db.Raw("SELECT id,title FROM `goods` order by id desc limit 1000 offset 3156").Rows() //where brand_category_check=4
|
||||
rows, _ := db.Raw("SELECT id,title FROM `goods` order by id ").Rows() //where brand_category_check=4
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
err = db.ScanRows(rows, &row)
|
||||
|
|
3
go.mod
3
go.mod
|
@ -5,13 +5,14 @@ go 1.22.10
|
|||
toolchain go1.23.7
|
||||
|
||||
require (
|
||||
gitea.cdlsxd.cn/self-tools/l_ai_category v1.9.0
|
||||
gitea.cdlsxd.cn/self-tools/l_request v1.0.8
|
||||
github.com/volcengine/volcengine-go-sdk v1.0.187
|
||||
gorm.io/driver/mysql v1.5.7
|
||||
gorm.io/gorm v1.25.12
|
||||
)
|
||||
|
||||
require (
|
||||
gitea.cdlsxd.cn/self-tools/l_request v1.0.8 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
|
|
Loading…
Reference in New Issue