Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion message/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func unmarshalRawContent(data json.RawMessage) (Content, error) {
return &raw, nil
}

// Text returns the first text content in the response, or empty string.
// Text returns the concatenated text of all TextContent in the response,
// or empty string if there is none.
func (cs Contents) Text() string {
var sb strings.Builder
for _, c := range cs {
Expand Down
4 changes: 4 additions & 0 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ func NewText(text string) *Message {
return New(&TextContent{Text: text})
}

// String implements fmt.Stringer, returning the concatenated text of all
// TextContent in the message (delegating to Contents.Text).
func (m *Message) String() string {
return m.Contents.Text()
}

// Usage returns the aggregated UsageDetails carried by the message's
// UsageContent (delegating to Contents.Usage).
func (m *Message) Usage() UsageDetails {
return m.Contents.Usage()
}
Expand Down
Loading