tian

package
v0.0.0-...-a0ccaba Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TianURL = "https://api.tianapi.com/txapi/robot/index" // 天行机器人接口

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code int

返回码

const Success Code = 200

返回成功

type NewsList

type NewsList struct {
	Reply    string `json:"reply"`    // 回复内容
	Datatype string `json:"datatype"` // 回复内容类型,text文本;view图文;image图片
}

天行机器人的回复

type Response

type Response struct {
	Code     Code       `json:"code"`     // 返回码
	Msg      string     `json:"msg"`      // 返回信息
	NewsList []NewsList `json:"newslist"` // 天行机器人的回复
}

天行机器人的响应

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

检查响应是否成功

type Tian

type Tian struct {
	Key      string `json:"key"`      // API密钥,需自行注册获得
	Question string `json:"question"` // 聊天文本内容
	UniqueID string `json:"uniqueid"` // 用户唯一身份ID,方便上下文关联
	Mode     uint   `json:"mode"`     // 工作模式,宽松模式0(回答率高)、精确模式1(相关性高)、私有模式2(只从私有词库中回答)
	Priv     uint   `json:"priv"`     // 私有词库匹配模式,完整匹配0[默认]、智能匹配1,模糊匹配2,结尾匹配3,开头匹配4
	Restype  uint   `json:"restype"`  // 输入类型,文本0、语音1、人脸图片2
}

天行机器人

func (*Tian) Chat

func (t *Tian) Chat() (string, error)

聊天,实现AI接口

func (*Tian) ChatWith

func (t *Tian) ChatWith(text string, id string) (string, error)

聊天,实现AI接口

func (*Tian) Request

func (t *Tian) Request() (*Response, error)

请求

Jump to

Keyboard shortcuts

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