geoGo/internal/ai_tool/collect.go

121 lines
2.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ai_tool
import "geo/pkg"
type Collect struct {
apikey string
}
func NewCollect(apikey string) *Collect {
return &Collect{apikey: apikey}
}
type PlatForm struct {
Index int `json:"index"`
PlatFormName string `json:"name"`
Icon string `json:"icon"`
}
var PlatFormList = []PlatForm{
{
Index: 1,
PlatFormName: "deepseek",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/deepseek.png",
},
{
Index: 2,
PlatFormName: "豆包",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/doubao.png",
},
{
Index: 3,
PlatFormName: "元宝",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/yuanbao.png",
},
{
Index: 41,
PlatFormName: "千问",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/qianwen.png",
},
{
Index: 5,
PlatFormName: "文心一言",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/wenxin.png",
},
//{
// Index: 6,
// PlatFormName: "纳米",
//},
//{
// Index: 7,
// PlatFormName: "kimi",
//}, {
// Index: 8,
// PlatFormName: "智普",
//},
}
type CreateReq struct {
// apikey
APIKey string `json:"api_key"`
// 品牌词,多个用英文逗号隔开
Keywords string `json:"keywords"`
// 平台1-deepseek2-豆包3-元宝4-千问5-文心一言6-纳米7-kimi8-智普
Platform int64 `json:"platform"`
// 问题
Question string `json:"question"`
// 建议填第三方的用户id。方便查单
ThirdID *string `json:"third_id,omitempty"`
}
type CreateRes struct {
Code int `json:"code"`
Msg string `json:"msg"`
Time string `json:"time"`
Data struct {
RequestId string `json:"request_id"`
} `json:"data"`
}
func (s *Collect) Create(data *CreateReq) (*CreateRes, error) {
url := "http://8.138.187.158:8082/api/geo/add_shoulu"
data.APIKey = s.apikey
mapInfo, err := pkg.StructToMap(data)
if err != nil {
return nil, err
}
var res CreateRes
err = pkg.PostMultipart(url, mapInfo, &res)
return &res, err
}
type CheckTaskRes struct {
Code int `json:"code"`
Msg string `json:"msg"`
Time string `json:"time"`
Data struct {
ShouluDate string `json:"shoulu_date"`
Platform int `json:"platform"`
ScriptTime int `json:"script_time"`
Question string `json:"question"`
HitWord string `json:"hit_word"`
Status int `json:"status"`
ShareUrl string `json:"share_url"`
KeywordRes string `json:"keyword_res"`
ImgUrl string `json:"img_url"`
RequestId string `json:"request_id"`
} `json:"data"`
}
func (s *Collect) CheckTask(requestId string) (*CheckTaskRes, error) {
url := "http://8.138.187.158:8082/api/geo/check_task"
request := map[string]interface{}{
"request_id": requestId,
"api_key": s.apikey,
}
var res CheckTaskRes
err := pkg.PostMultipart(url, request, &res)
return &res, err
}