Estimate output token budget from structural signals.
(prompt: str, tier: str)
| 336 | |
| 337 | |
| 338 | def estimate_output_budget(prompt: str, tier: str) -> int: |
| 339 | """Estimate output token budget from structural signals.""" |
| 340 | tokens = estimate_tokens(prompt) |
| 341 | if tokens < 10: |
| 342 | return OutputBudget.SHORT |
| 343 | |
| 344 | code = score_code_markers(prompt) |
| 345 | enum = score_enumeration_density(prompt) |
| 346 | if code.score > 0.3 and enum.score > 0.3: |
| 347 | return OutputBudget.LONG |
| 348 | if tokens > 200: |
| 349 | return OutputBudget.LONG |
| 350 | |
| 351 | tier_defaults = { |
| 352 | "SIMPLE": OutputBudget.SHORT, |
| 353 | "MEDIUM": OutputBudget.MEDIUM, |
| 354 | "COMPLEX": OutputBudget.LONG, |
| 355 | } |
| 356 | return tier_defaults.get(tier, OutputBudget.MEDIUM) |
no test coverage detected