quivr/backend/repository/brain/get_default_user_brain.py
MaHDi 8af6d61e76
improve (importing): reorganization of the import structure (#964)
* reorganize import level

* add __init__, reorganize import from __init__

* reorganize import level

* reorganize import level

* fix circular import error by keep the import deep as "from models.settings"

* fix the relative import

* restor unwanted staged files

* add backend/venv and backend/.env to gitignore

* clean importing
2023-08-21 12:25:16 +02:00

22 lines
532 B
Python

from uuid import UUID
from logger import get_logger
from models import BrainEntity, get_supabase_db
from repository.brain import get_brain_by_id
logger = get_logger(__name__)
def get_user_default_brain(user_id: UUID) -> BrainEntity | None:
supabase_db = get_supabase_db()
brain_id = supabase_db.get_default_user_brain_id(user_id)
logger.info(f"Default brain response: {brain_id}")
if brain_id is None:
return None
logger.info(f"Default brain id: {brain_id}")
return get_brain_by_id(brain_id)