Skip to content

Commit

Permalink
Add an optional argument to the Massage function
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Jan 28, 2025
1 parent d2d9519 commit ecc30b1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions v2/massage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import "strings"

// Massage will try to extract a shorter message from a longer LLM output
// using pretty "hacky" string manipulation techniques.
func Massage(generatedOutput string) string {
// If the optional noUppercaseLetter argument is false, the first letter will not be made uppercase.
func Massage(generatedOutput string, noUppercaseLetter ...bool) string {
s := generatedOutput
// Keep the part after ":", if applicable
if strings.Contains(s, ":") {
Expand Down Expand Up @@ -68,8 +69,11 @@ func Massage(generatedOutput string) string {
if len(s) < 4 {
return strings.TrimSpace(generatedOutput)
}
// Let the first letter be uppercase
s = strings.ToUpper(string([]rune(s)[0])) + string([]rune(s)[1:])

if !(len(noUppercaseLetter) > 0 && !noUppercaseLetter[0]) {
// Let the first letter be uppercase
s = strings.ToUpper(string([]rune(s)[0])) + string([]rune(s)[1:])
}

// Trim spaces
s = strings.TrimSpace(s)
Expand Down

0 comments on commit ecc30b1

Please sign in to comment.