Format Percent • AI Agent SDK
format_percent: Smart percentage formatting for context utilization display.
format_percent
Function
</div>
This function is defined in the context module.
Smart percentage formatting for context utilization display.
- For values < 0.1%: shows “<0.1%”
- For values < 1%: shows 2 decimal places (e.g., “0.02%”)
- For values >= 1%: shows 1 decimal place (e.g., “5.3%”)
Signature
def format_percent(value: float) -> strParameters
ParamField
floatA ratio (0.0 to 1.0+), NOT already multiplied by 100
Returns
ResponseField
strFormatted percentage string
Source
View on GitHubpraisonaiagents/context/__init__.py at line 44