drbot

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

README

drbot-go

  • Drbot Wrapped API

Usage

  • How to import?
    go get -u github.com/Cellularhacker/drbot-go
    

※ Important

package name is just drbot. so you have to use like drbot.Client not drbot-go.Client.

Documentation

Index

Constants

View Source
const (
	ValueChannelAdmin      = "admin"
	ValueIntendId          = ""
	ValueIsStartFalse      = 0
	ValueIsStartTrue       = 1
	ValueLangEn            = "en"
	ValueLangJa            = "ja"
	ValueLangKo            = "ko"
	ValueModelMessage      = "message"
	ValueRequestTypeButton = "button"
	ValueRequestTypeText   = "text"
	ValueTimeZoneAsiaSeoul = "Asia/Seoul"
	ValueUtteranceStart    = "[start]"
	ValueVisitCountStart   = int64(1)
)
View Source
const (
	PathAPI = "api"
)

Variables

View Source
var ErrInvalidMakeRequestChatResponseData = fmt.Errorf("invalid 'MakeRequestChat()' response data")
View Source
var ErrNeedChatDataExceptStartingTheChat = fmt.Errorf("need 'ChatData' except starting the chat")
View Source
var ErrNotInitialized = fmt.Errorf("not initialized")

Functions

func GetNewUUID

func GetNewUUID() string

func IsInitialized

func IsInitialized() bool

func MakeRequest

func MakeRequest(method, path string, p url.Values, body []byte) ([]byte, error)

func MakeRequestAdmin

func MakeRequestAdmin(method, path string, p url.Values, body []byte) ([]byte, error)

func MakeRequestChat

func MakeRequestChat(method, path string, p url.Values, body []byte) ([]byte, error)

func SetVariables

func SetVariables(drbotAPIEndpoint, drbotChatAPIEndpoint, drbotAdminAPIEndpoint string)

SetVariables - Mark: You should have to call this function while initializing step or before run main.

Types

type ChatContext

type ChatContext struct {
}

type ChatData

type ChatData struct {
	UserID     string `json:"user_id"`
	VisitCount int64  `json:"visit_count"`
	SessionId  string `json:"session_id"`
	Message    string `json:"message"`
	Language   string `json:"language,omitempty"`
}

func NewChatData

func NewChatData() *ChatData

type ChatInput

type ChatInput struct {
	Text string `json:"text"`
}

type ChatIntent

type ChatIntent struct {
	Module      string  `json:"module"`
	IntentId    string  `json:"intent_id"`
	IntentTitle string  `json:"intent_title"`
	Confidence  float64 `json:"confidence"`
}

type ChatItem

type ChatItem []struct {
	Title       string          `json:"title"`
	Subtitle    string          `json:"subtitle,omitempty"`
	Description string          `json:"description,omitempty"`
	Similarity  string          `json:"similarity,omitempty"`
	Source      string          `json:"source,omitempty"`
	Thumbnail   json.RawMessage `json:"thumbnail,omitempty"` // MARK: Guess -> *string
	Buttons     json.RawMessage `json:"buttons,omitempty"`
}

type ChatOutput

type ChatOutput struct {
	Type  string     `json:"type"`
	Items []ChatItem `json:"items"`
}

type ChatReq

type ChatReq struct {
	UserRequest *UserRequest `json:"userRequest"`
	VisitCount  int64        `json:"visit_count"`
	Context     *ChatContext `json:"context"`
}

func NewInitChatReq

func NewInitChatReq() *ChatReq

func (*ChatReq) Bytes

func (scr *ChatReq) Bytes() []byte

func (*ChatReq) String

func (scr *ChatReq) String() string

type ChatResp

type ChatResp struct {
	Outputs []ChatOutput `json:"outputs"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func GetDrbotClient

func GetDrbotClient() *Client

func (*Client) Do

func (dc *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) GetMaxRetriesCount

func (dc *Client) GetMaxRetriesCount() int

func (*Client) GetRetryDelay

func (dc *Client) GetRetryDelay() time.Duration

func (*Client) SetMaxRetries

func (dc *Client) SetMaxRetries(maxRetries int) *Client

func (*Client) SetRetryDelay

func (dc *Client) SetRetryDelay(retryDelay time.Duration) *Client

type SendChatResp

type SendChatResp struct {
	UserRequest  UserRequest `json:"userRequest"`
	Animation    string      `json:"animation"`
	Input        ChatInput   `json:"input"`
	Context      ChatContext `json:"context"`
	Intent       ChatIntent  `json:"intent"`
	Response     ChatResp    `json:"response"`
	VisitCount   int         `json:"visit_count"`
	CreatedAt    string      `json:"created_at"`
	ResponseTime int         `json:"response_time"`
}

func NewSendChatResp

func NewSendChatResp() *SendChatResp

func SendChat

func SendChat(isStart bool, initData ...*ChatData) (*SendChatResp, error)

type UserReq

type UserReq struct {
	Id        string `json:"id"`
	SessionId string `json:"sessionId"`
}

type UserRequest

type UserRequest struct {
	Model       string   `json:"model"`
	IntentId    string   `json:"intentId"`
	IsStart     int      `json:"isStart"`
	Timezone    string   `json:"timezone"`
	Utterance   string   `json:"utterance"`
	Lang        string   `json:"lang"`
	Channel     string   `json:"channel"`
	TopFolderId string   `json:"top_folder_id,omitempty"`
	CbcType     string   `json:"cbc_type,omitempty"`
	CbcRound    int64    `json:"cbc_round,omitempty"`
	CbcTerm     int64    `json:"cbc_term,omitempty"`
	RequestType string   `json:"requestType"`
	User        *UserReq `json:"user"`
}

Jump to

Keyboard shortcuts

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