Skip to content

Commit

Permalink
Refactoring responses name
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-one committed Apr 4, 2023
1 parent aded11b commit 3c58662
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions responses/final.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"time"
)

// FinalResponse response for final generate message
type FinalResponse struct {
// Final response for final generate message
type Final struct {
Type int `json:"type"`
InvocationId string `json:"invocationId,omitempty"`
Item struct {
Expand All @@ -19,7 +19,7 @@ type FinalResponse struct {
}

// GetAnswer get answer text
func (r *FinalResponse) GetAnswer() string {
func (r *Final) GetAnswer() string {
item := r.Item
if len(item.Messages) == 0 {
return ""
Expand All @@ -31,21 +31,21 @@ func (r *FinalResponse) GetAnswer() string {
}

// GetType get type
func (r *FinalResponse) GetType() int {
func (r *Final) GetType() int {
return r.Type
}

// GetMaxUnit get max user questions for current session
func (r *FinalResponse) GetMaxUnit() int {
func (r *Final) GetMaxUnit() int {
return r.Item.Throttling.MaxNumUserMessagesInConversation
}

// GetUserUnit get current question for current session
func (r *FinalResponse) GetUserUnit() int {
func (r *Final) GetUserUnit() int {
return r.Item.Throttling.NumUserMessagesInConversation
}

func (r *FinalResponse) GetSuggestions() []*Suggestion {
func (r *Final) GetSuggestions() []*Suggestion {
item := r.Item
if len(item.Messages) == 0 {
return nil
Expand Down
6 changes: 3 additions & 3 deletions responses/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func (m *MessageWrapper) Worker() error {
defer m.mu.Unlock()

var response map[string]any
var updateResponse UpdateResponse
var finalResponse FinalResponse
var undefinedResponse UndefinedResponse
var updateResponse Update
var finalResponse Final
var undefinedResponse Undefined

for {
var message []byte
Expand Down
14 changes: 7 additions & 7 deletions responses/undefined.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package responses

// UndefinedResponse response for unused messages
type UndefinedResponse struct {
// Undefined response for unused messages
type Undefined struct {
Type int `json:"type"`
}

// GetAnswer get answer text
func (r *UndefinedResponse) GetAnswer() string {
func (r *Undefined) GetAnswer() string {
return ""
}

// GetType get type
func (r *UndefinedResponse) GetType() int {
func (r *Undefined) GetType() int {
return r.Type
}

// GetMaxUnit get max user questions for current session
func (r *UndefinedResponse) GetMaxUnit() int {
func (r *Undefined) GetMaxUnit() int {
return 0
}

// GetUserUnit get current question for current session
func (r *UndefinedResponse) GetUserUnit() int {
func (r *Undefined) GetUserUnit() int {
return 0
}

func (r *UndefinedResponse) GetSuggestions() []*Suggestion {
func (r *Undefined) GetSuggestions() []*Suggestion {
return nil
}
14 changes: 7 additions & 7 deletions responses/update.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package responses

// UpdateResponse response for work generate message
type UpdateResponse struct {
// Update response for work generate message
type Update struct {
Type int `json:"type"`
Target string `json:"target"`
Arguments []struct {
Expand All @@ -15,7 +15,7 @@ type UpdateResponse struct {
}

// GetAnswer get answer text
func (u *UpdateResponse) GetAnswer() string {
func (u *Update) GetAnswer() string {
arg := u.Arguments[0]
if len(arg.Messages) == 0 {
return ""
Expand All @@ -27,20 +27,20 @@ func (u *UpdateResponse) GetAnswer() string {
}

// GetType get type
func (u *UpdateResponse) GetType() int {
func (u *Update) GetType() int {
return u.Type
}

// GetMaxUnit get max user questions for current session
func (u *UpdateResponse) GetMaxUnit() int {
func (u *Update) GetMaxUnit() int {
return 0
}

// GetUserUnit get current question for current session
func (u *UpdateResponse) GetUserUnit() int {
func (u *Update) GetUserUnit() int {
return 0
}

func (u *UpdateResponse) GetSuggestions() []*Suggestion {
func (u *Update) GetSuggestions() []*Suggestion {
return nil
}

0 comments on commit 3c58662

Please sign in to comment.