Beable commited on
Commit
8b203aa
·
verified ·
1 Parent(s): 079dd15

Update diet_tool.py

Browse files
Files changed (1) hide show
  1. diet_tool.py +3 -19
diet_tool.py CHANGED
@@ -4,7 +4,7 @@ import math
4
  from typing import Dict, List, Any, Optional
5
  from dataclasses import dataclass
6
  from datetime import datetime, timedelta
7
- from usda_provider import fetch_nutrition_usda
8
 
9
  @dataclass
10
  class UserProfile:
@@ -407,24 +407,8 @@ def calculate_nutrition_info(food_name: str, portion_grams: float) -> Dict[str,
407
  "vitamins": food["vitamins"],
408
  "minerals": food["minerals"]
409
  }
410
- # If not found locally, get from USDA
411
- usda = fetch_nutrition_usda(food_name, portion_grams)
412
- if usda:
413
- return {
414
- "food_name": food_name,
415
- "portion_grams": usda.get("portion_grams", portion_grams),
416
- "calories": usda.get("calories"),
417
- "protein": usda.get("protein"),
418
- "carbs": usda.get("carbs"),
419
- "fat": usda.get("fat"),
420
- "fiber": usda.get("fiber"),
421
- "vitamins": usda.get("vitamins", {}),
422
- "minerals": usda.get("minerals", {}),
423
- "source": "USDA",
424
- "fdc_id": usda.get("fdc_id"),
425
- "description": usda.get("description"),
426
- }
427
- return {"error": f"'{food_name}' not found (local and USDA)"}
428
 
429
  except Exception as e:
430
  return {"error": f"Error while calculating nutritional value: {str(e)}"}
 
4
  from typing import Dict, List, Any, Optional
5
  from dataclasses import dataclass
6
  from datetime import datetime, timedelta
7
+ # USDA provider removed - using local food database only
8
 
9
  @dataclass
10
  class UserProfile:
 
407
  "vitamins": food["vitamins"],
408
  "minerals": food["minerals"]
409
  }
410
+ # If not found locally, return error (USDA fetching removed)
411
+ return {"error": f"'{food_name}' not found in local database"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
 
413
  except Exception as e:
414
  return {"error": f"Error while calculating nutritional value: {str(e)}"}