geoGo/internal/collect/interface.go

78 lines
2.1 KiB
Go

package collect
import (
"context"
"geo/internal/config"
"github.com/go-rod/rod"
"github.com/gofiber/fiber/v2/log"
)
// CollectorInterface AI平台收集器接口
type CollectorInterface interface {
// AskQuestion 提问并获取答案
AskQuestion(question string) (*CollectResult, error)
// Close 关闭页面(释放资源)
Close()
}
// CollectResult 收集结果
type CollectResult struct {
Answer string `json:"answer"` // AI回答内容
ShareLink string `json:"share_link"` // 分享链接\
IsExposure bool `json:"is_exposure"` // 是否曝光
}
// NewCollector 创建收集器的工厂函数类型
type NewCollector func(
ctx context.Context,
param *CollectParams,
cfg *config.Config,
logger log.AllLogger,
browser *rod.Browser,
page *rod.Page) CollectorInterface
// CollectorValue 收集器配置信息
type CollectorValue struct {
Name string // 平台名称
InitMethod NewCollector // 初始化方法
Platform string // 平台标识: wenxin, deepseek, doubao, qianwen
Icon string
}
// CollectParams 收集任务参数
type CollectParams struct {
Headless bool // 是否无头模式
RequestID string // 请求ID
Platform string
KeyWords []string
}
// CollectorMap 收集器注册表
var CollectorMap = map[string]*CollectorValue{
"wenxin": {
Name: "文心一言",
InitMethod: NewWenxinCollector,
Platform: "wenxin",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/wenxin.png",
},
"deepseek": {
Name: "DeepSeek",
InitMethod: NewDeepseekCollector,
Platform: "deepseek",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/deepseek.png",
},
"doubao": {
Name: "豆包",
InitMethod: NewDoubaoCollector,
Platform: "doubao",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/doubao.png",
},
"qianwen": {
Name: "通义千问",
InitMethod: NewQianwenCollector,
Platform: "qianwen",
Icon: "https://attachment-public.oss-cn-hangzhou.aliyuncs.com/geo/platform/qianwen.png",
},
}