Skip to content

Commit 838feda

Browse files
committed
Update generate.go
1 parent 0095beb commit 838feda

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

go/ai/generate.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,19 @@ func (mr *ModelResponse) Interrupts() []*Part {
774774
return parts
775775
}
776776

777+
// Media returns the media content of the [ModelResponse] as a string.
778+
func (mr *ModelResponse) Media() string {
779+
if mr.Message == nil {
780+
return ""
781+
}
782+
for _, part := range mr.Message.Content {
783+
if part.IsMedia() {
784+
return part.Text
785+
}
786+
}
787+
return ""
788+
}
789+
777790
// Text returns the text content of the [ModelResponseChunk]
778791
// as a string. It returns an error if there is no Content
779792
// in the response chunk.

0 commit comments

Comments
 (0)