hunk.code_window: from typing import Optional
   from uuid import UUID
   import resend
   from logger import get_logger
   from models.settings import CommonsDep, common_dependencies
   from pydantic import BaseModel
   logger = get_logger(__name__)
  
hunk.labels: keep keep keep keep keep replace keep keep keep keep keep
hunk.after_edit: from models.settings import BrainSettings, CommonsDep, common_dependencies
  
hunk.file_path: backend/core/models/brains_subscription_invitations.py
hunk.type: replace
file: import os
  
  import sentry_sdk
  from fastapi import FastAPI, HTTPException
  from fastapi.responses import JSONResponse
  from logger import get_logger
  from routes.completions_routes import completions_router
  
  logger = get_logger(__name__)
  
  if os.getenv("SENTRY_DSN"):
      sentry_sdk.init(
          dsn=os.getenv("SENTRY_DSN"),
          # Set traces_sample_rate to 1.0 to capture 100%
          # of transactions for performance monitoring.
          # We recommend adjusting this value in production,
          traces_sample_rate=1.0,
      )
  
  app = FastAPI()
  
  app.include_router(completions_router)
  
  
  @app.exception_handler(HTTPException)
  async def http_exception_handler(_, exc):
      return JSONResponse(
          status_code=exc.status_code,
          content={"detail": exc.detail},
      )
  