l_ai_brand/ai.go

25 lines
683 B
Go

package l_ai_brand
import (
"context"
"gitea.cdlsxd.cn/self-tools/l_ai_brand/doubao"
"strings"
)
func GetBrand(ctx context.Context, goodsName, key, model string, brandList []string) (brand string, err error) {
modelObj := doubao.NewDouBao(model, key)
text := []string{
"根据商品名称,获取对应品牌[QUESTION]" + goodsName + "[/QUESTION]",
"-只需要获取一个品牌名称",
"-如果无法获取,则返回`失败`",
}
if brandList != nil {
text = append(text, "-优先从以下品牌选取:"+strings.Join(brandList, "、"))
}
brand, err = modelObj.GetData(ctx, key, func(input string) (string, error) {
return input, nil
}, text...)
return
}