mirror of
https://github.com/escalante29/healthy-fit.git
synced 2026-03-21 12:48:47 +01:00
Introduces DSPy-based nutrition and plan generation modules, including image analysis for nutritional info and personalized diet/exercise plans. Adds new API endpoints for health metrics/goals, nutrition image analysis, and plan management. Updates models, schemas, and backend structure to support these features, and includes initial training data and configuration for prompt optimization.
31 lines
1011 B
Python
31 lines
1011 B
Python
from datetime import datetime
|
|
from typing import Dict, List, Optional
|
|
|
|
from pgvector.sqlalchemy import Vector
|
|
from sqlalchemy import Column
|
|
from sqlmodel import JSON, Field, SQLModel
|
|
|
|
|
|
class FoodItem(SQLModel, table=True):
|
|
id: Optional[int] = Field(default=None, primary_key=True)
|
|
name: str = Field(index=True)
|
|
calories: float
|
|
protein: float
|
|
carbs: float
|
|
fats: float
|
|
micros: Dict = Field(default={}, sa_column=Column(JSON))
|
|
embedding: List[float] = Field(sa_column=Column(Vector(1536))) # OpenAI embedding size
|
|
|
|
|
|
class FoodLog(SQLModel, table=True):
|
|
id: Optional[int] = Field(default=None, primary_key=True)
|
|
user_id: int = Field(foreign_key="user.id")
|
|
food_item_id: Optional[int] = Field(default=None, foreign_key="fooditem.id")
|
|
name: str # In case no food item is linked or custom entry
|
|
calories: float
|
|
protein: float
|
|
carbs: float
|
|
fats: float
|
|
image_url: Optional[str] = None
|
|
timestamp: datetime = Field(default_factory=datetime.utcnow)
|