fix: anthropic non-empty blocks

This commit is contained in:
adamdottv 2025-05-02 10:21:34 -05:00 committed by Adam
parent 49423da081
commit f004a0b8c3
2 changed files with 20 additions and 12 deletions

View file

@ -48,7 +48,10 @@ type TextContent struct {
Text string `json:"text"`
}
func (tc TextContent) String() string {
func (tc *TextContent) String() string {
if tc == nil {
return ""
}
return tc.Text
}
@ -115,13 +118,13 @@ type Message struct {
UpdatedAt int64
}
func (m *Message) Content() TextContent {
func (m *Message) Content() *TextContent {
for _, part := range m.Parts {
if c, ok := part.(TextContent); ok {
return c
return &c
}
}
return TextContent{}
return nil
}
func (m *Message) ReasoningContent() ReasoningContent {