(input: { cfg: ConfigV1.Info; model: Provider.Model; outputTokenMax?: number })
| 8 | const COMPACTION_BUFFER = 20_000 |
| 9 | |
| 10 | export function usable(input: { cfg: ConfigV1.Info; model: Provider.Model; outputTokenMax?: number }) { |
| 11 | const context = input.model.limit.context |
| 12 | if (context === 0) return 0 |
| 13 | |
| 14 | const reserved = |
| 15 | input.cfg.compaction?.reserved ?? |
| 16 | Math.min(COMPACTION_BUFFER, ProviderTransform.maxOutputTokens(input.model, input.outputTokenMax)) |
| 17 | return input.model.limit.input |
| 18 | ? Math.max(0, input.model.limit.input - reserved) |
| 19 | : Math.max(0, context - ProviderTransform.maxOutputTokens(input.model, input.outputTokenMax)) |
| 20 | } |
| 21 | |
| 22 | export function isOverflow(input: { |
| 23 | cfg: ConfigV1.Info |
no outgoing calls
no test coverage detected