baiduai

package
v0.0.0-...-115e584 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2021 License: Apache-2.0, GPL-3.0, GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAi

func GetAi() *ai

Types

type AiAnalyzeRet

type AiAnalyzeRet struct {
	Tags    []string
	Summary string
}

type AiCategories

type AiCategories struct {
	LogID     int64          `json:"log_id"`
	Item      AiCategoryItem `json:"item"`
	ErrorMSG  string         `json:"error_msg"`
	ErrorCode int            `json:"error_code"`
}

type AiCategoryItem

type AiCategoryItem struct {
	TopCategory    []AiTag `json:"lv1_tag_list"`
	SecondCatrgory []AiTag `json:"lv2_tag_list"`
}

type AiData

type AiData struct {
	Title string
	Desc  string
}

AiData 要获取描述的数据

type AiTag

type AiTag struct {
	Score float64 `json:"score"`
	Tag   string  `json:"tag"`
}

type AiTagParam

type AiTagParam struct {
	Title   string `json:"title"`
	Content string `json:"content"`
}

type AiTags

type AiTags struct {
	LogID     int64   `json:"log_id"`
	Items     []AiTag `json:"items"`
	ErrorMSG  string  `json:"error_msg"`
	ErrorCode int     `json:"error_code"`
}

type AuthResponse

type AuthResponse struct {
	AccessToken      string `json:"access_token"`  // 要获取的Access Token
	ExpireIn         string `json:"expire_in"`     // Access Token的有效期(秒为单位,一般为1个月);
	RefreshToken     string `json:"refresh_token"` // 以下参数忽略,暂时不用
	Scope            string `json:"scope"`
	SessionKey       string `json:"session_key"`
	SessionSecret    string `json:"session_secret"`
	ERROR            string `json:"error"`             // 错误码;关于错误码的详细信息请参考鉴权认证错误码(http://ai.baidu.com/docs#/Auth/top)
	ErrorDescription string `json:"error_description"` // 错误描述信息,帮助理解和解决发生的错误。
}

type Authorizer

type Authorizer interface {
	Authorize(*Client) error
}

Authorizer 用于设置access_token 可以通过RESTFul api的方式从百度方获取 有效期为一个月,可以存至数据库中然后从数据库中获取

type Client

type Client struct {
	ClientID     string
	ClientSecret string
	AccessToken  string
	Authorizer   Authorizer
}

func NewClient

func NewClient(apiKey, secretKey string) *Client

func (*Client) Auth

func (client *Client) Auth() error

func (*Client) SetAuther

func (client *Client) SetAuther(auth Authorizer)

type DefaultAuthorizer

type DefaultAuthorizer struct{}

func (DefaultAuthorizer) Authorize

func (da DefaultAuthorizer) Authorize(client *Client) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL