ContentPartSize returns the byte length of a MessagePart's primary text or data field.
(part fantasy.MessagePart)
| 190 | // ContentPartSize returns the byte length of a MessagePart's |
| 191 | // primary text or data field. |
| 192 | func ContentPartSize(part fantasy.MessagePart) int { |
| 193 | switch p := part.(type) { |
| 194 | case fantasy.TextPart: |
| 195 | return len(p.Text) |
| 196 | case fantasy.ReasoningPart: |
| 197 | return len(p.Text) |
| 198 | case fantasy.FilePart: |
| 199 | return len(p.Data) |
| 200 | case fantasy.ToolCallPart: |
| 201 | return len(p.Input) |
| 202 | case fantasy.ToolResultPart: |
| 203 | return toolResultOutputSize(p.Output) |
| 204 | default: |
| 205 | return 0 |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | // ToolResultSize returns the byte length of a |
| 210 | // ToolResultContent's primary text or data field. |
no test coverage detected