From 3c586621191c743fe5ca5d18677f8225788b15ff Mon Sep 17 00:00:00 2001 From: Pavel Zarubin Date: Tue, 4 Apr 2023 03:01:09 +0300 Subject: [PATCH] Refactoring responses name --- responses/final.go | 14 +++++++------- responses/message.go | 6 +++--- responses/undefined.go | 14 +++++++------- responses/update.go | 14 +++++++------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/responses/final.go b/responses/final.go index 30c4167..adefa8e 100644 --- a/responses/final.go +++ b/responses/final.go @@ -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 { @@ -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 "" @@ -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 diff --git a/responses/message.go b/responses/message.go index de2b69f..4c66e08 100644 --- a/responses/message.go +++ b/responses/message.go @@ -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 diff --git a/responses/undefined.go b/responses/undefined.go index 2001b65..4d1100b 100644 --- a/responses/undefined.go +++ b/responses/undefined.go @@ -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 } diff --git a/responses/update.go b/responses/update.go index 665583f..a0a83ef 100644 --- a/responses/update.go +++ b/responses/update.go @@ -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 { @@ -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 "" @@ -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 }