Skip to content

Commit 01db97b

Browse files
authored
fix(go): exclude reasoning part when return value from Text() function (#3165)
1 parent adf8c3e commit 01db97b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

go/ai/generate.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,13 +768,16 @@ func (c *ModelResponseChunk) Text() string {
768768
}
769769
var sb strings.Builder
770770
for _, p := range c.Content {
771-
sb.WriteString(p.Text)
771+
if p.IsText() || p.IsData() {
772+
sb.WriteString(p.Text)
773+
}
772774
}
773775
return sb.String()
774776
}
775777

776778
// Text returns the contents of a [Message] as a string. It
777779
// returns an empty string if the message has no content.
780+
// If you want to get reasoning from the message, use Reasoning() instead.
778781
func (m *Message) Text() string {
779782
if m == nil {
780783
return ""
@@ -787,7 +790,9 @@ func (m *Message) Text() string {
787790
}
788791
var sb strings.Builder
789792
for _, p := range m.Content {
790-
sb.WriteString(p.Text)
793+
if p.IsText() || p.IsData() {
794+
sb.WriteString(p.Text)
795+
}
791796
}
792797
return sb.String()
793798
}

0 commit comments

Comments
 (0)