responses

package
v0.0.0-...-f684a93 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeUpdate float64 = 1
	TypeFinish float64 = 2
)
View Source
const DelimiterByte = uint8(30)

Variables

This section is empty.

Functions

This section is empty.

Types

type Final

type Final struct {
	Type         int    `json:"type"`
	InvocationId string `json:"invocationId,omitempty"`
	Item         struct {
		Messages               []*Message `json:"messages"`
		ConversationExpiryTime time.Time  `json:"conversationExpiryTime,omitempty"`
		Throttling             struct {
			MaxNumUserMessagesInConversation int `json:"maxNumUserMessagesInConversation"`
			NumUserMessagesInConversation    int `json:"numUserMessagesInConversation"`
		} `json:"throttling"`
	} `json:"item"`
}

Final response for final generate message

func (*Final) GetAnswer

func (r *Final) GetAnswer() string

GetAnswer get answer text

func (*Final) GetMaxUnit

func (r *Final) GetMaxUnit() int

GetMaxUnit get max user questions for current session

func (*Final) GetSuggestions

func (r *Final) GetSuggestions() []map[string]any

func (*Final) GetType

func (r *Final) GetType() int

GetType get type

func (*Final) GetUserUnit

func (r *Final) GetUserUnit() int

GetUserUnit get current question for current session

type GptResponse

type GptResponse interface {
	GetAnswer() string
	GetType() int
	GetMaxUnit() int
	GetUserUnit() int
	GetSuggestions() []map[string]any
}

type Message

type Message struct {
	Text          string `json:"text"`
	Author        string `json:"author"`
	AdaptiveCards []struct {
		Type    string `json:"type"`
		Version string `json:"version"`
		Body    []struct {
			Type string `json:"type"`
			Text string `json:"text"`
			Wrap bool   `json:"wrap"`
		} `json:"body"`
	} `json:"adaptiveCards,omitempty"`
	SuggestedResponses []*Suggestion `json:"suggestedResponses,omitempty"`
}

Message struct for bing answer

type MessageWrapper

type MessageWrapper struct {
	Final    bool
	Question string
	Answer   GptResponse
	Chan     chan []byte
	// contains filtered or unexported fields
}

MessageWrapper wrapper for message worker

func NewMessageWrapper

func NewMessageWrapper(question string, mutex *sync.Mutex, conn *websocket.Conn) *MessageWrapper

NewMessageWrapper create new wrapper

func (*MessageWrapper) Worker

func (m *MessageWrapper) Worker() error

Worker write and parse websocket messages

type Suggestion

type Suggestion struct {
	Text        string    `json:"text"`
	Author      string    `json:"author"`
	CreatedAt   time.Time `json:"createdAt"`
	Timestamp   time.Time `json:"timestamp"`
	MessageId   string    `json:"messageId"`
	MessageType string    `json:"messageType"`
	Offense     string    `json:"offense"`
	Feedback    struct {
		Tag       interface{} `json:"tag"`
		UpdatedOn interface{} `json:"updatedOn"`
		Type      string      `json:"type"`
	} `json:"feedback"`
	ContentOrigin string      `json:"contentOrigin"`
	Privacy       interface{} `json:"privacy"`
}

Suggestion for this question

type Undefined

type Undefined struct {
	Type int `json:"type"`
}

Undefined response for unused messages

func (*Undefined) GetAnswer

func (r *Undefined) GetAnswer() string

GetAnswer get answer text

func (*Undefined) GetMaxUnit

func (r *Undefined) GetMaxUnit() int

GetMaxUnit get max user questions for current session

func (*Undefined) GetSuggestions

func (r *Undefined) GetSuggestions() []map[string]any

func (*Undefined) GetType

func (r *Undefined) GetType() int

GetType get type

func (*Undefined) GetUserUnit

func (r *Undefined) GetUserUnit() int

GetUserUnit get current question for current session

type Update

type Update struct {
	Type      int    `json:"type"`
	Target    string `json:"target"`
	Arguments []struct {
		Cursor struct {
			J string `json:"j"`
			P int    `json:"p"`
		} `json:"cursor"`
		Messages  []*Message `json:"messages"`
		RequestId string     `json:"requestId"`
	} `json:"arguments"`
}

Update response for work generate message

func (*Update) GetAnswer

func (u *Update) GetAnswer() string

GetAnswer get answer text

func (*Update) GetMaxUnit

func (u *Update) GetMaxUnit() int

GetMaxUnit get max user questions for current session

func (*Update) GetSuggestions

func (u *Update) GetSuggestions() []map[string]any

func (*Update) GetType

func (u *Update) GetType() int

GetType get type

func (*Update) GetUserUnit

func (u *Update) GetUserUnit() int

GetUserUnit get current question for current session

Jump to

Keyboard shortcuts

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