( usage: PiAssistantUsage | null, contextLimit: number, )
| 80 | * totalInputTokens = info.tokens.input + info.tokens.cache.read + info.tokens.cache.write |
| 81 | */ |
| 82 | export function computePiPressure( |
| 83 | usage: PiAssistantUsage | null, |
| 84 | contextLimit: number, |
| 85 | ): PiPressure | null { |
| 86 | if (!usage) return null; |
| 87 | const input = usage.input ?? 0; |
| 88 | const cacheRead = usage.cacheRead ?? 0; |
| 89 | const cacheWrite = usage.cacheWrite ?? 0; |
| 90 | const inputTokens = input + cacheRead + cacheWrite; |
| 91 | if (inputTokens === 0) return null; |
| 92 | const percentage = contextLimit > 0 ? (inputTokens / contextLimit) * 100 : 0; |
| 93 | return { inputTokens, percentage }; |
| 94 | } |
no outgoing calls
no test coverage detected