mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
style: Format code with linter and fix whitespace
This commit is contained in:
parent
e10fe50c6f
commit
2c5c2b2f67
1 changed files with 8 additions and 8 deletions
|
@ -606,30 +606,30 @@ class Model(ModelSettings):
|
||||||
"""
|
"""
|
||||||
Parse a token value string into an integer.
|
Parse a token value string into an integer.
|
||||||
Accepts formats: 8096, "8k", "10.5k", "0.5M", "10K", etc.
|
Accepts formats: 8096, "8k", "10.5k", "0.5M", "10K", etc.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
value: String or int token value
|
value: String or int token value
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Integer token value
|
Integer token value
|
||||||
"""
|
"""
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
return int(value) # Try to convert to int
|
return int(value) # Try to convert to int
|
||||||
|
|
||||||
value = value.strip().upper()
|
value = value.strip().upper()
|
||||||
|
|
||||||
if value.endswith('K'):
|
if value.endswith("K"):
|
||||||
multiplier = 1024
|
multiplier = 1024
|
||||||
value = value[:-1]
|
value = value[:-1]
|
||||||
elif value.endswith('M'):
|
elif value.endswith("M"):
|
||||||
multiplier = 1024 * 1024
|
multiplier = 1024 * 1024
|
||||||
value = value[:-1]
|
value = value[:-1]
|
||||||
else:
|
else:
|
||||||
multiplier = 1
|
multiplier = 1
|
||||||
|
|
||||||
# Convert to float first to handle decimal values like "10.5k"
|
# Convert to float first to handle decimal values like "10.5k"
|
||||||
return int(float(value) * multiplier)
|
return int(float(value) * multiplier)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue