Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions go/ai/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,19 @@ func (mr *ModelResponse) Interrupts() []*Part {
return parts
}

// Media returns the media content of the [ModelResponse] as a string.
func (mr *ModelResponse) Media() string {
if mr.Message == nil {
return ""
}
for _, part := range mr.Message.Content {
if part.IsMedia() {
return part.Text
}
}
return ""
}

// Text returns the text content of the [ModelResponseChunk]
// as a string. It returns an error if there is no Content
// in the response chunk.
Expand Down
Loading