mirror of
https://github.com/escalante29/healthy-fit.git
synced 2026-03-21 10:48:46 +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.
39 lines
946 B
Python
39 lines
946 B
Python
from typing import Any
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
from sqlmodel import Session, select
|
|
|
|
from app.api import deps
|
|
from app.core import security
|
|
from app.models.user import User
|
|
from app.schemas.user import UserCreate, UserRead
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.post("/", response_model=UserRead)
|
|
def create_user(
|
|
*,
|
|
session: Session = Depends(deps.get_session),
|
|
user_in: UserCreate,
|
|
) -> Any:
|
|
"""
|
|
Create new user.
|
|
"""
|
|
user = session.exec(select(User).where(User.email == user_in.email)).first()
|
|
if user:
|
|
raise HTTPException(
|
|
status_code=400,
|
|
detail="The user with this email already exists in the system",
|
|
)
|
|
|
|
user = User(
|
|
email=user_in.email,
|
|
username=user_in.username,
|
|
password_hash=security.get_password_hash(user_in.password),
|
|
)
|
|
session.add(user)
|
|
session.commit()
|
|
session.refresh(user)
|
|
return user
|