(msg: WithParts)
| 138 | } |
| 139 | |
| 140 | export function countMessageTextTokens(msg: WithParts): number { |
| 141 | const texts: string[] = [] |
| 142 | const parts = Array.isArray(msg.parts) ? msg.parts : [] |
| 143 | for (const part of parts) { |
| 144 | if (part.type === "text") { |
| 145 | texts.push(part.text) |
| 146 | } |
| 147 | } |
| 148 | if (texts.length === 0) return 0 |
| 149 | return estimateTokensBatch(texts) |
| 150 | } |
| 151 | |
| 152 | export function countAllMessageTokens(msg: WithParts): number { |
| 153 | const parts = Array.isArray(msg.parts) ? msg.parts : [] |
nothing calls this directly
no test coverage detected