MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / estimate_output_budget

Function estimate_output_budget

uncommon_route/router/structural.py:338–356  ·  view source on GitHub ↗

Estimate output token budget from structural signals.

(prompt: str, tier: str)

Source from the content-addressed store, hash-verified

336
337
338def 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)

Callers 3

_handle_chat_coreFunction · 0.90
select_modelFunction · 0.90
select_from_poolFunction · 0.90

Calls 4

estimate_tokensFunction · 0.85
score_code_markersFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected