Skip to content

Commit

Permalink
[Feat] add default negative feedback (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoo0515 authored Feb 22, 2024
1 parent c018a2f commit d7b614a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/handler/feedback.handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (handler *FeedbackHandlerImpl) GetPronunciationFeedback(c echo.Context) err
}

transcript := firstToUpper(feedbackResponse.GetTranscript())
negativeFeedback := getNegativeFeedbackOrDefault(feedbackResponse.GetNegativeFeedback())

result := pb.GetPronunciationFeedbackResponse{
PronunciationFeedback: &pb.PronunciationFeedbackDTO{
Expand All @@ -94,7 +95,7 @@ func (handler *FeedbackHandlerImpl) GetPronunciationFeedback(c echo.Context) err
VolumeScore: feedbackResponse.GetVolumeScore(),
SpeedScore: feedbackResponse.GetSpeedScore(),
PositiveFeedback: feedbackResponse.GetPositiveFeedback(),
NegativeFeedback: feedbackResponse.GetNegativeFeedback(),
NegativeFeedback: negativeFeedback,
},
}

Expand Down Expand Up @@ -157,12 +158,13 @@ func (handler *FeedbackHandlerImpl) GetCommunicationFeedback(c echo.Context) err
log.Printf("grpc request failed: %v", err)
return model.NewCustomHTTPError(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
negativeFeedback := getNegativeFeedbackOrDefault(response.GetNegativeFeedback())

result := pb.GetCommunicationFeedbackResponse{
CommunicationFeedback: &pb.CommunicationFeedbackDTO{
SceneId: request.GetSceneId(),
PositiveFeedback: response.GetPositiveFeedback(),
NegativeFeedback: response.GetNegativeFeedback(),
NegativeFeedback: negativeFeedback,
EnhancedAnswer: response.GetEnhancedAnswer(),
},
}
Expand Down Expand Up @@ -209,6 +211,13 @@ func firstToUpper(s string) string {
return string(unicode.ToUpper(r)) + lowerCase[size:]
}

func getNegativeFeedbackOrDefault(negativeFeedback string) string {
if negativeFeedback == "" {
return "Nothing to improve. Great job!"
}
return negativeFeedback
}

func FeedbackHandlerInit(sentenceService service.SentenceService, sceneService service.SceneService, storageService service.StorageService) *FeedbackHandlerImpl {
return &FeedbackHandlerImpl{
sentenceService: sentenceService,
Expand Down

0 comments on commit d7b614a

Please sign in to comment.