Skip to content

Commit ca5643f

Browse files
committed
Added Flatten method
1 parent fc42839 commit ca5643f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/openai/chat.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package openai
22

33
import (
44
// Packages
5+
"strings"
6+
57
"github.com/mutablelogic/go-client/pkg/client"
68
)
79

@@ -50,6 +52,17 @@ func (msg *Message) AppendImageFile(file ...string) *Message {
5052
return msg
5153
}
5254

55+
// Return the text of the message
56+
func (arr MessageContentArray) Flatten() string {
57+
var content []string
58+
for _, v := range arr {
59+
if v.Text != nil {
60+
content = append(content, *v.Text)
61+
}
62+
}
63+
return strings.Join(content, "\n")
64+
}
65+
5366
///////////////////////////////////////////////////////////////////////////////
5467
// API CALLS
5568

0 commit comments

Comments
 (0)