mirror of
https://github.com/escalante29/healthy-fit.git
synced 2026-03-21 09:08:46 +01:00
Set up backend and frontend structure for a health and fitness tracker using Python (FastAPI, SQLModel, DSPy) and React. Includes Docker and Compose configs, authentication, nutrition AI module, health/nutrition/user endpoints, database models, and basic frontend with routing and context. Enables tracking nutrition, health metrics, and user management, with architecture ready for future mobile and cloud deployment.
26 lines
783 B
Python
26 lines
783 B
Python
import dspy
|
|
from pydantic import BaseModel, Field
|
|
|
|
class NutritionalInfo(BaseModel):
|
|
name: str
|
|
calories: float
|
|
protein: float
|
|
carbs: float
|
|
fats: float
|
|
micros: dict | None = None
|
|
|
|
class ExtractNutrition(dspy.Signature):
|
|
"""Extract nutritional information from a food description."""
|
|
description: str = dspy.InputField(desc="Description of the food or meal")
|
|
nutritional_info: NutritionalInfo = dspy.OutputField(desc="Nutritional information as a structured object")
|
|
|
|
class NutritionModule(dspy.Module):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.extract = dspy.ChainOfThought(ExtractNutrition)
|
|
|
|
def forward(self, description: str):
|
|
return self.extract(description=description)
|
|
|
|
nutrition_module = NutritionModule()
|