GoodLuckChuck commited on
Commit
b39eb31
·
verified ·
1 Parent(s): df66bd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -540,9 +540,14 @@ class GroceryListAgent:
540
 
541
  def _format_quantity(self, quantity: float) -> str:
542
  """Format quantity to be more readable."""
 
 
 
 
543
  if quantity.is_integer():
544
  return str(int(quantity))
545
- # Round to 2 decimal places
 
546
  return f"{quantity:.2f}".rstrip('0').rstrip('.')
547
 
548
  async def generate_list(self, recipes: List[Recipe]) -> str:
 
540
 
541
  def _format_quantity(self, quantity: float) -> str:
542
  """Format quantity to be more readable."""
543
+ # Convert to float first to handle both int and float inputs
544
+ quantity = float(quantity)
545
+
546
+ # Check if it's effectively a whole number
547
  if quantity.is_integer():
548
  return str(int(quantity))
549
+
550
+ # Round to 2 decimal places and remove trailing zeros
551
  return f"{quantity:.2f}".rstrip('0').rstrip('.')
552
 
553
  async def generate_list(self, recipes: List[Recipe]) -> str: