From 8af6d61e761436b3af404be1dbff2a97d4c413bc Mon Sep 17 00:00:00 2001
From: MaHDi <64260599+MaHDiaLaGaB@users.noreply.github.com>
Date: Mon, 21 Aug 2023 13:25:16 +0300
Subject: [PATCH] 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
---
.gitignore | 3 ++
.idea/.gitignore | 8 ++++
.idea/inspectionProfiles/Project_Default.xml | 21 +++++++++
.../inspectionProfiles/profiles_settings.xml | 6 +++
.idea/misc.xml | 4 ++
.idea/modules.xml | 8 ++++
.idea/quivr-llm.iml | 15 +++++++
.idea/vcs.xml | 6 +++
backend/auth/auth_bearer.py | 2 +-
backend/auth/jwt_token_handler.py | 2 +-
backend/chat_service.py | 11 ++---
backend/llm/base.py | 4 +-
backend/llm/qa_base.py | 21 +++++----
backend/llm/qa_headless.py | 16 ++++---
backend/models/__init__.py | 28 ++++++++++++
backend/parsers/audio.py | 4 +-
backend/parsers/common.py | 3 +-
backend/parsers/csv.py | 2 +-
backend/parsers/docx.py | 2 +-
backend/parsers/epub.py | 2 +-
backend/parsers/github.py | 3 +-
backend/parsers/html.py | 2 +-
backend/parsers/markdown.py | 2 +-
backend/parsers/notebook.py | 2 +-
backend/parsers/odt.py | 2 +-
backend/parsers/pdf.py | 2 +-
backend/parsers/powerpoint.py | 2 +-
backend/parsers/txt.py | 2 +-
backend/repository/brain/__init__.py | 12 ++++++
backend/repository/brain/create_brain.py | 3 +-
backend/repository/brain/create_brain_user.py | 2 +-
backend/repository/brain/get_brain_by_id.py | 3 +-
backend/repository/brain/get_brain_details.py | 3 +-
.../repository/brain/get_brain_for_user.py | 3 +-
.../repository/brain/get_brain_prompt_id.py | 2 +-
.../brain/get_default_user_brain.py | 5 +--
.../get_default_user_brain_or_create_new.py | 12 +++---
backend/repository/brain/get_user_brains.py | 3 +-
.../brain/set_as_default_brain_for_user.py | 4 +-
backend/repository/brain/update_brain.py | 3 +-
.../repository/brain/update_user_rights.py | 2 +-
.../repository/brain_subscription/__init__.py | 3 ++
.../resend_invitation_email.py | 7 ++-
.../subscription_invitation_service.py | 3 +-
backend/repository/chat/__init__.py | 9 ++++
backend/repository/chat/create_chat.py | 3 +-
backend/repository/chat/get_chat_by_id.py | 3 +-
backend/repository/chat/get_chat_history.py | 7 ++-
backend/repository/chat/get_user_chats.py | 3 +-
backend/repository/chat/update_chat.py | 3 +-
.../repository/chat/update_chat_history.py | 3 +-
.../repository/chat/update_message_by_id.py | 3 +-
backend/repository/prompt/__init__.py | 5 +++
backend/repository/prompt/create_prompt.py | 3 +-
.../repository/prompt/delete_prompt_py_id.py | 2 +-
backend/repository/prompt/get_prompt_by_id.py | 3 +-
.../repository/prompt/get_public_prompts.py | 3 +-
.../repository/prompt/update_prompt_by_id.py | 3 +-
backend/repository/user/__init__.py | 2 +
.../user/get_user_email_by_user_id.py | 2 +-
.../user/get_user_id_by_user_email.py | 2 +-
backend/repository/user_identity/__init__.py | 3 ++
.../user_identity/create_user_identity.py | 3 +-
.../user_identity/get_user_identity.py | 3 +-
.../user_identity/update_user_identity.py | 5 +--
backend/routes/api_key_routes.py | 7 ++-
.../authorizations/brain_authorization.py | 4 +-
backend/routes/brain_routes.py | 26 ++++++-----
backend/routes/chat_routes.py | 43 +++++++++++++++----
backend/routes/crawl_routes.py | 4 +-
backend/routes/explore_routes.py | 4 +-
backend/routes/prompt_routes.py | 12 +++---
backend/routes/subscription_routes.py | 29 ++++++-------
backend/routes/upload_routes.py | 8 ++--
backend/routes/user_routes.py | 11 ++---
backend/utils/vectors.py | 2 +-
76 files changed, 304 insertions(+), 174 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/inspectionProfiles/Project_Default.xml
create mode 100644 .idea/inspectionProfiles/profiles_settings.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/quivr-llm.iml
create mode 100644 .idea/vcs.xml
create mode 100644 backend/repository/brain/__init__.py
create mode 100644 backend/repository/prompt/__init__.py
create mode 100644 backend/repository/user/__init__.py
create mode 100644 backend/repository/user_identity/__init__.py
diff --git a/.gitignore b/.gitignore
index 8717446f4..b7fd00982 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,9 @@ toto.txt
*.ipynb
log.txt
+backend/venv
+backend/.env
+
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 000000000..13566b81b
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 000000000..c857d01b5
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 000000000..105ce2da2
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 000000000..a971a2c93
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 000000000..ecc2fe0b8
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/quivr-llm.iml b/.idea/quivr-llm.iml
new file mode 100644
index 000000000..86ca1eafe
--- /dev/null
+++ b/.idea/quivr-llm.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 000000000..35eb1ddfb
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/auth/auth_bearer.py b/backend/auth/auth_bearer.py
index 55c815890..d0b6d5031 100644
--- a/backend/auth/auth_bearer.py
+++ b/backend/auth/auth_bearer.py
@@ -5,7 +5,7 @@ from auth.api_key_handler import get_user_from_api_key, verify_api_key
from auth.jwt_token_handler import decode_access_token, verify_token
from fastapi import Depends, HTTPException, Request
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
-from models.users import User
+from models import User
class AuthBearer(HTTPBearer):
diff --git a/backend/auth/jwt_token_handler.py b/backend/auth/jwt_token_handler.py
index 60b85dc80..95669396b 100644
--- a/backend/auth/jwt_token_handler.py
+++ b/backend/auth/jwt_token_handler.py
@@ -4,7 +4,7 @@ from typing import Optional
from jose import jwt
from jose.exceptions import JWTError
-from models.users import User
+from models import User
SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
ALGORITHM = "HS256"
diff --git a/backend/chat_service.py b/backend/chat_service.py
index b664060c8..b17f2a42f 100644
--- a/backend/chat_service.py
+++ b/backend/chat_service.py
@@ -1,8 +1,10 @@
import os
+
if __name__ == "__main__":
# import needed here when running main.py to debug backend
# you will need to run pip install python-dotenv
from dotenv import load_dotenv
+
load_dotenv()
import sentry_sdk
from fastapi import FastAPI, HTTPException, Request, status
@@ -26,15 +28,10 @@ app = FastAPI()
add_cors_middleware(app)
-
-
app.include_router(chat_router)
app.include_router(misc_router)
-
-
-
@app.exception_handler(HTTPException)
async def http_exception_handler(_, exc):
return JSONResponse(
@@ -47,7 +44,7 @@ async def http_exception_handler(_, exc):
def handle_request_validation_error(app: FastAPI):
@app.exception_handler(RequestValidationError)
async def validation_exception_handler(
- request: Request, exc: RequestValidationError
+ request: Request, exc: RequestValidationError
):
exc_str = f"{exc}".replace("\n", " ").replace(" ", " ")
logger.error(request, exc_str)
@@ -66,5 +63,5 @@ handle_request_validation_error(app)
if __name__ == "__main__":
# run main.py to debug backend
import uvicorn
- uvicorn.run(app, host="0.0.0.0", port=5050)
+ uvicorn.run(app, host="0.0.0.0", port=5050)
diff --git a/backend/llm/base.py b/backend/llm/base.py
index ab7ca42c8..cc26c1271 100644
--- a/backend/llm/base.py
+++ b/backend/llm/base.py
@@ -3,8 +3,10 @@ from typing import AsyncIterable, List
from langchain.callbacks.streaming_aiter import AsyncIteratorCallbackHandler
from logger import get_logger
-from models.settings import BrainSettings # Importing settings related to the 'brain'
+from models import BrainSettings # Importing settings related to the 'brain'
+
from pydantic import BaseModel # For data validation and settings management
+from models import BrainSettings # Importing settings related to the 'brain'
logger = get_logger(__name__)
diff --git a/backend/llm/qa_base.py b/backend/llm/qa_base.py
index f3f54cea0..68ce77d56 100644
--- a/backend/llm/qa_base.py
+++ b/backend/llm/qa_base.py
@@ -2,7 +2,9 @@ import asyncio
import json
from typing import AsyncIterable, Awaitable
from uuid import UUID
+from logger import get_logger
+from supabase.client import Client, create_client
from langchain.callbacks.streaming_aiter import AsyncIteratorCallbackHandler
from langchain.chains import ConversationalRetrievalChain, LLMChain
from langchain.chains.question_answering import load_qa_chain
@@ -13,16 +15,19 @@ from langchain.prompts.chat import (
HumanMessagePromptTemplate,
SystemMessagePromptTemplate,
)
+
from logger import get_logger
-from models.chats import ChatQuestion
+from models import ChatQuestion
from models.databases.supabase.chats import CreateChatHistory
-from repository.brain.get_brain_by_id import get_brain_by_id
-from repository.brain.get_brain_prompt_id import get_brain_prompt_id
-from repository.chat.format_chat_history import format_chat_history
-from repository.chat.get_chat_history import GetChatHistoryOutput, get_chat_history
-from repository.chat.update_chat_history import update_chat_history
-from repository.chat.update_message_by_id import update_message_by_id
-from repository.prompt.get_prompt_by_id import get_prompt_by_id
+from repository.brain import get_brain_by_id, get_brain_prompt_id
+from repository.chat import (
+ get_chat_history,
+ update_chat_history,
+ format_chat_history,
+ GetChatHistoryOutput,
+ update_message_by_id,
+)
+from repository.prompt import get_prompt_by_id
from supabase.client import Client, create_client
from vectorstore.supabase import CustomSupabaseVectorStore
diff --git a/backend/llm/qa_headless.py b/backend/llm/qa_headless.py
index 74889ac85..138313475 100644
--- a/backend/llm/qa_headless.py
+++ b/backend/llm/qa_headless.py
@@ -10,15 +10,17 @@ from langchain.prompts.chat import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
)
-from repository.chat.update_message_by_id import update_message_by_id
from models.databases.supabase.chats import CreateChatHistory
-from repository.chat.format_chat_history import format_chat_history
-from repository.chat.get_chat_history import get_chat_history
-from repository.chat.update_chat_history import update_chat_history
-from repository.chat.format_chat_history import format_history_to_openai_mesages
+from repository.chat import (
+ update_message_by_id,
+ format_chat_history,
+ get_chat_history,
+ update_chat_history,
+ format_history_to_openai_mesages,
+ GetChatHistoryOutput,
+)
from logger import get_logger
-from models.chats import ChatQuestion
-from repository.chat.get_chat_history import GetChatHistoryOutput
+from models import ChatQuestion
from pydantic import BaseModel
diff --git a/backend/models/__init__.py b/backend/models/__init__.py
index e69de29bb..7def742b9 100644
--- a/backend/models/__init__.py
+++ b/backend/models/__init__.py
@@ -0,0 +1,28 @@
+from .files import File
+from .users import User
+from .brains import Brain
+from .chat import Chat, ChatHistory
+from .user_identity import UserIdentity
+from .prompt import Prompt, PromptStatusEnum
+from .chats import ChatQuestion, ChatMessage
+from .brain_entity import BrainEntity, MinimalBrainEntity
+from .brains_subscription_invitations import BrainSubscription
+from .settings import (
+ BrainRateLimiting,
+ BrainSettings,
+ LLMSettings,
+ get_supabase_db,
+ get_supabase_client,
+ get_embeddings,
+ get_documents_vector_store
+)
+
+# TODO uncomment the below import when start using SQLalchemy
+# from .sqlalchemy_repository import (
+# User,
+# Brain,
+# BrainUser,
+# BrainVector,
+# BrainSubscriptionInvitation,
+# ApiKey
+# )
diff --git a/backend/parsers/audio.py b/backend/parsers/audio.py
index fdf16069a..b4a798117 100644
--- a/backend/parsers/audio.py
+++ b/backend/parsers/audio.py
@@ -5,8 +5,8 @@ import time
import openai
from langchain.schema import Document
from langchain.text_splitter import RecursiveCharacterTextSplitter
-from models.files import File
-from models.settings import get_documents_vector_store
+
+from models import File, get_documents_vector_store
from utils.file import compute_sha1_from_content
diff --git a/backend/parsers/common.py b/backend/parsers/common.py
index db8843f5a..d8dcc14ea 100644
--- a/backend/parsers/common.py
+++ b/backend/parsers/common.py
@@ -1,8 +1,7 @@
import time
from langchain.schema import Document
-from models.brains import Brain
-from models.files import File
+from models import Brain, File
from utils.vectors import Neurons
diff --git a/backend/parsers/csv.py b/backend/parsers/csv.py
index 4df75b535..e8c195f38 100644
--- a/backend/parsers/csv.py
+++ b/backend/parsers/csv.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import CSVLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/docx.py b/backend/parsers/docx.py
index ab9d246af..641fcc13f 100644
--- a/backend/parsers/docx.py
+++ b/backend/parsers/docx.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import Docx2txtLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/epub.py b/backend/parsers/epub.py
index 33047523f..fc5233f2d 100644
--- a/backend/parsers/epub.py
+++ b/backend/parsers/epub.py
@@ -1,5 +1,5 @@
from langchain.document_loaders.epub import UnstructuredEPubLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/github.py b/backend/parsers/github.py
index 2b49c06b3..ddd40acee 100644
--- a/backend/parsers/github.py
+++ b/backend/parsers/github.py
@@ -4,8 +4,7 @@ import time
from langchain.document_loaders import GitLoader
from langchain.schema import Document
from langchain.text_splitter import RecursiveCharacterTextSplitter
-from models.brains import Brain
-from models.files import File
+from models import Brain, File
from utils.file import compute_sha1_from_content
from utils.vectors import Neurons
diff --git a/backend/parsers/html.py b/backend/parsers/html.py
index 47bcf0c2a..c1908578a 100644
--- a/backend/parsers/html.py
+++ b/backend/parsers/html.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import UnstructuredHTMLLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/markdown.py b/backend/parsers/markdown.py
index 185ca517e..1f2e6679b 100644
--- a/backend/parsers/markdown.py
+++ b/backend/parsers/markdown.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import UnstructuredMarkdownLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/notebook.py b/backend/parsers/notebook.py
index d5b2d1f45..d05dd5a3d 100644
--- a/backend/parsers/notebook.py
+++ b/backend/parsers/notebook.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import NotebookLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/odt.py b/backend/parsers/odt.py
index bba254dd2..a80ac2f54 100644
--- a/backend/parsers/odt.py
+++ b/backend/parsers/odt.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import PyMuPDFLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/pdf.py b/backend/parsers/pdf.py
index 0d029010b..18501a706 100644
--- a/backend/parsers/pdf.py
+++ b/backend/parsers/pdf.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import PyMuPDFLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/powerpoint.py b/backend/parsers/powerpoint.py
index 4b0b2b56f..878aa6a63 100644
--- a/backend/parsers/powerpoint.py
+++ b/backend/parsers/powerpoint.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import UnstructuredPowerPointLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/parsers/txt.py b/backend/parsers/txt.py
index f03412f14..1e6dd399a 100644
--- a/backend/parsers/txt.py
+++ b/backend/parsers/txt.py
@@ -1,5 +1,5 @@
from langchain.document_loaders import TextLoader
-from models.files import File
+from models import File
from .common import process_file
diff --git a/backend/repository/brain/__init__.py b/backend/repository/brain/__init__.py
new file mode 100644
index 000000000..b7d5dee86
--- /dev/null
+++ b/backend/repository/brain/__init__.py
@@ -0,0 +1,12 @@
+from .create_brain import create_brain
+from .get_brain_by_id import get_brain_by_id
+from .update_brain import update_brain_by_id
+from .get_user_brains import get_user_brains
+from .get_brain_details import get_brain_details
+from .create_brain_user import create_brain_user
+from .get_brain_for_user import get_brain_for_user
+from .get_brain_prompt_id import get_brain_prompt_id
+from .update_user_rights import update_brain_user_rights
+from .get_default_user_brain import get_user_default_brain
+from .set_as_default_brain_for_user import set_as_default_brain_for_user
+from .get_default_user_brain_or_create_new import get_default_user_brain_or_create_new
diff --git a/backend/repository/brain/create_brain.py b/backend/repository/brain/create_brain.py
index 201426585..84d7665ab 100644
--- a/backend/repository/brain/create_brain.py
+++ b/backend/repository/brain/create_brain.py
@@ -1,6 +1,5 @@
-from models.brain_entity import BrainEntity
from models.databases.supabase.brains import CreateBrainProperties
-from models.settings import get_supabase_db
+from models import BrainEntity, get_supabase_db
def create_brain(brain: CreateBrainProperties) -> BrainEntity:
diff --git a/backend/repository/brain/create_brain_user.py b/backend/repository/brain/create_brain_user.py
index b4c84f971..3d156d988 100644
--- a/backend/repository/brain/create_brain_user.py
+++ b/backend/repository/brain/create_brain_user.py
@@ -1,6 +1,6 @@
from uuid import UUID
-from models.settings import get_supabase_db
+from models import get_supabase_db
from routes.authorizations.types import RoleEnum
diff --git a/backend/repository/brain/get_brain_by_id.py b/backend/repository/brain/get_brain_by_id.py
index f0b464a29..a0fd73be1 100644
--- a/backend/repository/brain/get_brain_by_id.py
+++ b/backend/repository/brain/get_brain_by_id.py
@@ -1,7 +1,6 @@
from uuid import UUID
-from models.brain_entity import BrainEntity
-from models.settings import get_supabase_db
+from models import BrainEntity, get_supabase_db
def get_brain_by_id(brain_id: UUID) -> BrainEntity | None:
diff --git a/backend/repository/brain/get_brain_details.py b/backend/repository/brain/get_brain_details.py
index 1377a0595..035224ba2 100644
--- a/backend/repository/brain/get_brain_details.py
+++ b/backend/repository/brain/get_brain_details.py
@@ -1,7 +1,6 @@
from uuid import UUID
-from models.brain_entity import BrainEntity
-from models.settings import get_supabase_client
+from models import BrainEntity, get_supabase_client
def get_brain_details(brain_id: UUID) -> BrainEntity | None:
diff --git a/backend/repository/brain/get_brain_for_user.py b/backend/repository/brain/get_brain_for_user.py
index 9ec9c5f2a..35ae3c2d7 100644
--- a/backend/repository/brain/get_brain_for_user.py
+++ b/backend/repository/brain/get_brain_for_user.py
@@ -1,7 +1,6 @@
from uuid import UUID
-from models.brain_entity import MinimalBrainEntity
-from models.settings import get_supabase_db
+from models import MinimalBrainEntity, get_supabase_db
def get_brain_for_user(user_id: UUID, brain_id: UUID) -> MinimalBrainEntity:
diff --git a/backend/repository/brain/get_brain_prompt_id.py b/backend/repository/brain/get_brain_prompt_id.py
index 9aa67b45f..6692381a4 100644
--- a/backend/repository/brain/get_brain_prompt_id.py
+++ b/backend/repository/brain/get_brain_prompt_id.py
@@ -1,6 +1,6 @@
from uuid import UUID
-from repository.brain.get_brain_by_id import get_brain_by_id
+from repository.brain import get_brain_by_id
def get_brain_prompt_id(brain_id: UUID) -> UUID | None:
diff --git a/backend/repository/brain/get_default_user_brain.py b/backend/repository/brain/get_default_user_brain.py
index cbf7d85df..5616c9a46 100644
--- a/backend/repository/brain/get_default_user_brain.py
+++ b/backend/repository/brain/get_default_user_brain.py
@@ -1,9 +1,8 @@
from uuid import UUID
from logger import get_logger
-from models.brain_entity import BrainEntity
-from models.settings import get_supabase_db
-from repository.brain.get_brain_by_id import get_brain_by_id
+from models import BrainEntity, get_supabase_db
+from repository.brain import get_brain_by_id
logger = get_logger(__name__)
diff --git a/backend/repository/brain/get_default_user_brain_or_create_new.py b/backend/repository/brain/get_default_user_brain_or_create_new.py
index 45b7fdb2b..6b8f35713 100644
--- a/backend/repository/brain/get_default_user_brain_or_create_new.py
+++ b/backend/repository/brain/get_default_user_brain_or_create_new.py
@@ -1,11 +1,13 @@
-from models.brain_entity import BrainEntity
from models.databases.supabase.brains import CreateBrainProperties
-from models.users import User
-from repository.brain.create_brain import create_brain
-from repository.brain.create_brain_user import create_brain_user
-from repository.brain.get_default_user_brain import get_user_default_brain
+from models import BrainEntity, User
from routes.authorizations.types import RoleEnum
+from repository.brain import (
+ create_brain,
+ create_brain_user,
+ get_user_default_brain
+)
+
def get_default_user_brain_or_create_new(user: User) -> BrainEntity:
default_brain = get_user_default_brain(user.id)
diff --git a/backend/repository/brain/get_user_brains.py b/backend/repository/brain/get_user_brains.py
index b250d14dd..45ed98217 100644
--- a/backend/repository/brain/get_user_brains.py
+++ b/backend/repository/brain/get_user_brains.py
@@ -1,7 +1,6 @@
from uuid import UUID
-from models.brain_entity import BrainEntity
-from models.settings import get_supabase_db
+from models import BrainEntity, get_supabase_db
def get_user_brains(user_id: UUID) -> list[BrainEntity]:
diff --git a/backend/repository/brain/set_as_default_brain_for_user.py b/backend/repository/brain/set_as_default_brain_for_user.py
index 8d5f45e9a..0d9f4cd01 100644
--- a/backend/repository/brain/set_as_default_brain_for_user.py
+++ b/backend/repository/brain/set_as_default_brain_for_user.py
@@ -1,7 +1,7 @@
from uuid import UUID
-from models.settings import get_supabase_client
-from repository.brain.get_default_user_brain import get_user_default_brain
+from models import get_supabase_client
+from repository.brain import get_user_default_brain
def set_as_default_brain_for_user(user_id: UUID, brain_id: UUID):
diff --git a/backend/repository/brain/update_brain.py b/backend/repository/brain/update_brain.py
index 13b496c31..132301b63 100644
--- a/backend/repository/brain/update_brain.py
+++ b/backend/repository/brain/update_brain.py
@@ -1,8 +1,7 @@
from uuid import UUID
-from models.brain_entity import BrainEntity
from models.databases.supabase.brains import BrainUpdatableProperties
-from models.settings import get_supabase_db
+from models import BrainEntity, get_supabase_db
def update_brain_by_id(brain_id: UUID, brain: BrainUpdatableProperties) -> BrainEntity:
diff --git a/backend/repository/brain/update_user_rights.py b/backend/repository/brain/update_user_rights.py
index 2bf491f7e..0b796b7f1 100644
--- a/backend/repository/brain/update_user_rights.py
+++ b/backend/repository/brain/update_user_rights.py
@@ -1,6 +1,6 @@
from uuid import UUID
-from models.settings import get_supabase_client
+from models import get_supabase_client
def update_brain_user_rights(brain_id: UUID, user_id: UUID, rights: str) -> None:
diff --git a/backend/repository/brain_subscription/__init__.py b/backend/repository/brain_subscription/__init__.py
index e69de29bb..2eae654b4 100644
--- a/backend/repository/brain_subscription/__init__.py
+++ b/backend/repository/brain_subscription/__init__.py
@@ -0,0 +1,3 @@
+from .get_brain_url import get_brain_url
+from .resend_invitation_email import resend_invitation_email
+from .subscription_invitation_service import SubscriptionInvitationService
diff --git a/backend/repository/brain_subscription/resend_invitation_email.py b/backend/repository/brain_subscription/resend_invitation_email.py
index 9efe2e0c7..1c7b6a31d 100644
--- a/backend/repository/brain_subscription/resend_invitation_email.py
+++ b/backend/repository/brain_subscription/resend_invitation_email.py
@@ -1,10 +1,9 @@
import resend
from logger import get_logger
-from models.brains_subscription_invitations import BrainSubscription
-from models.settings import BrainSettings
+from models import BrainSubscription, BrainSettings
-from repository.brain.get_brain_details import get_brain_details
-from repository.brain_subscription.get_brain_url import get_brain_url
+from repository.brain import get_brain_details
+from repository.brain_subscription import get_brain_url
logger = get_logger(__name__)
diff --git a/backend/repository/brain_subscription/subscription_invitation_service.py b/backend/repository/brain_subscription/subscription_invitation_service.py
index 06a92b1e6..120464e88 100644
--- a/backend/repository/brain_subscription/subscription_invitation_service.py
+++ b/backend/repository/brain_subscription/subscription_invitation_service.py
@@ -1,6 +1,5 @@
from logger import get_logger
-from models.brains_subscription_invitations import BrainSubscription
-from models.settings import get_supabase_client
+from models import BrainSubscription, get_supabase_client
logger = get_logger(__name__)
diff --git a/backend/repository/chat/__init__.py b/backend/repository/chat/__init__.py
index e69de29bb..eed1d5332 100644
--- a/backend/repository/chat/__init__.py
+++ b/backend/repository/chat/__init__.py
@@ -0,0 +1,9 @@
+from .create_chat import create_chat, CreateChatProperties
+from .update_chat import update_chat, ChatUpdatableProperties
+from .get_user_chats import get_user_chats
+from .get_chat_by_id import get_chat_by_id
+from .get_chat_history import GetChatHistoryOutput, get_chat_history
+from .update_chat_history import update_chat_history
+from .update_message_by_id import update_message_by_id
+from .format_chat_history import format_history_to_openai_mesages
+from .format_chat_history import format_chat_history, format_history_to_openai_mesages
diff --git a/backend/repository/chat/create_chat.py b/backend/repository/chat/create_chat.py
index 846b9ff9e..972a015c3 100644
--- a/backend/repository/chat/create_chat.py
+++ b/backend/repository/chat/create_chat.py
@@ -2,8 +2,7 @@ from dataclasses import dataclass
from uuid import UUID
from logger import get_logger
-from models.chat import Chat
-from models.settings import get_supabase_db
+from models import Chat, get_supabase_db
logger = get_logger(__name__)
diff --git a/backend/repository/chat/get_chat_by_id.py b/backend/repository/chat/get_chat_by_id.py
index 7b1830311..dd153b286 100644
--- a/backend/repository/chat/get_chat_by_id.py
+++ b/backend/repository/chat/get_chat_by_id.py
@@ -1,5 +1,4 @@
-from models.chat import Chat
-from models.settings import get_supabase_db
+from models import Chat, get_supabase_db
def get_chat_by_id(chat_id: str) -> Chat:
diff --git a/backend/repository/chat/get_chat_history.py b/backend/repository/chat/get_chat_history.py
index d561be09b..8adde5f05 100644
--- a/backend/repository/chat/get_chat_history.py
+++ b/backend/repository/chat/get_chat_history.py
@@ -1,12 +1,11 @@
from typing import List, Optional
from uuid import UUID
-from models.chat import ChatHistory
-from models.settings import get_supabase_db # For type hinting
+from models import ChatHistory, get_supabase_db
from pydantic import BaseModel
-from repository.brain.get_brain_by_id import get_brain_by_id
-from repository.prompt.get_prompt_by_id import get_prompt_by_id
+from repository.brain import get_brain_by_id
+from repository.prompt import get_prompt_by_id
class GetChatHistoryOutput(BaseModel):
diff --git a/backend/repository/chat/get_user_chats.py b/backend/repository/chat/get_user_chats.py
index bec926820..9b6c41884 100644
--- a/backend/repository/chat/get_user_chats.py
+++ b/backend/repository/chat/get_user_chats.py
@@ -1,7 +1,6 @@
from typing import List
-from models.chat import Chat
-from models.settings import get_supabase_db
+from models import Chat, get_supabase_db
def get_user_chats(user_id: str) -> List[Chat]:
diff --git a/backend/repository/chat/update_chat.py b/backend/repository/chat/update_chat.py
index 2fd4e0422..a7c964f6c 100644
--- a/backend/repository/chat/update_chat.py
+++ b/backend/repository/chat/update_chat.py
@@ -2,8 +2,7 @@ from dataclasses import dataclass
from typing import Optional
from logger import get_logger
-from models.chat import Chat
-from models.settings import get_supabase_db
+from models import Chat, get_supabase_db
logger = get_logger(__name__)
diff --git a/backend/repository/chat/update_chat_history.py b/backend/repository/chat/update_chat_history.py
index 3f948cf7a..c623008f9 100644
--- a/backend/repository/chat/update_chat_history.py
+++ b/backend/repository/chat/update_chat_history.py
@@ -1,9 +1,8 @@
from typing import List
from fastapi import HTTPException
-from models.chat import ChatHistory
from models.databases.supabase.chats import CreateChatHistory
-from models.settings import get_supabase_db
+from models import ChatHistory, get_supabase_db
def update_chat_history(chat_history: CreateChatHistory) -> ChatHistory:
diff --git a/backend/repository/chat/update_message_by_id.py b/backend/repository/chat/update_message_by_id.py
index aa78c8f47..ba2bacc6a 100644
--- a/backend/repository/chat/update_message_by_id.py
+++ b/backend/repository/chat/update_message_by_id.py
@@ -1,6 +1,5 @@
from logger import get_logger
-from models.chat import ChatHistory
-from models.settings import get_supabase_db
+from models import ChatHistory, get_supabase_db
logger = get_logger(__name__)
diff --git a/backend/repository/prompt/__init__.py b/backend/repository/prompt/__init__.py
new file mode 100644
index 000000000..7fb737c00
--- /dev/null
+++ b/backend/repository/prompt/__init__.py
@@ -0,0 +1,5 @@
+from .create_prompt import create_prompt
+from .get_prompt_by_id import get_prompt_by_id
+from .get_public_prompts import get_public_prompts
+from .update_prompt_by_id import update_prompt_by_id
+from .delete_prompt_py_id import delete_prompt_by_id
diff --git a/backend/repository/prompt/create_prompt.py b/backend/repository/prompt/create_prompt.py
index 7eb92715e..6bd4e799c 100644
--- a/backend/repository/prompt/create_prompt.py
+++ b/backend/repository/prompt/create_prompt.py
@@ -1,6 +1,5 @@
from models.databases.supabase.prompts import CreatePromptProperties
-from models.prompt import Prompt
-from models.settings import get_supabase_db
+from models import Prompt, get_supabase_db
def create_prompt(prompt: CreatePromptProperties) -> Prompt:
diff --git a/backend/repository/prompt/delete_prompt_py_id.py b/backend/repository/prompt/delete_prompt_py_id.py
index 9ced4c61d..19bb91376 100644
--- a/backend/repository/prompt/delete_prompt_py_id.py
+++ b/backend/repository/prompt/delete_prompt_py_id.py
@@ -1,7 +1,7 @@
from uuid import UUID
from models.databases.supabase.prompts import DeletePromptResponse
-from models.settings import get_supabase_db
+from models import get_supabase_db
def delete_prompt_by_id(prompt_id: UUID) -> DeletePromptResponse:
diff --git a/backend/repository/prompt/get_prompt_by_id.py b/backend/repository/prompt/get_prompt_by_id.py
index 55d05a2d7..cb0f60fea 100644
--- a/backend/repository/prompt/get_prompt_by_id.py
+++ b/backend/repository/prompt/get_prompt_by_id.py
@@ -1,7 +1,6 @@
from uuid import UUID
-from models.prompt import Prompt
-from models.settings import get_supabase_db
+from models import Prompt, get_supabase_db
def get_prompt_by_id(prompt_id: UUID) -> Prompt | None:
diff --git a/backend/repository/prompt/get_public_prompts.py b/backend/repository/prompt/get_public_prompts.py
index f57a8739f..af2df7ed2 100644
--- a/backend/repository/prompt/get_public_prompts.py
+++ b/backend/repository/prompt/get_public_prompts.py
@@ -1,5 +1,4 @@
-from models.prompt import Prompt
-from models.settings import get_supabase_db
+from models import Prompt, get_supabase_db
def get_public_prompts() -> list[Prompt]:
diff --git a/backend/repository/prompt/update_prompt_by_id.py b/backend/repository/prompt/update_prompt_by_id.py
index 440afb5fa..9f79cdc09 100644
--- a/backend/repository/prompt/update_prompt_by_id.py
+++ b/backend/repository/prompt/update_prompt_by_id.py
@@ -1,8 +1,7 @@
from uuid import UUID
from models.databases.supabase.prompts import PromptUpdatableProperties
-from models.prompt import Prompt
-from models.settings import get_supabase_db
+from models import Prompt, get_supabase_db
def update_prompt_by_id(prompt_id: UUID, prompt: PromptUpdatableProperties) -> Prompt:
diff --git a/backend/repository/user/__init__.py b/backend/repository/user/__init__.py
new file mode 100644
index 000000000..31e1f6f2d
--- /dev/null
+++ b/backend/repository/user/__init__.py
@@ -0,0 +1,2 @@
+from .get_user_email_by_user_id import get_user_email_by_user_id
+from .get_user_id_by_user_email import get_user_id_by_user_email
diff --git a/backend/repository/user/get_user_email_by_user_id.py b/backend/repository/user/get_user_email_by_user_id.py
index c82bfedf4..4f05392b8 100644
--- a/backend/repository/user/get_user_email_by_user_id.py
+++ b/backend/repository/user/get_user_email_by_user_id.py
@@ -1,6 +1,6 @@
from uuid import UUID
-from models.settings import get_supabase_client
+from models import get_supabase_client
def get_user_email_by_user_id(user_id: UUID) -> str:
diff --git a/backend/repository/user/get_user_id_by_user_email.py b/backend/repository/user/get_user_id_by_user_email.py
index d39f7b4bf..7afd53791 100644
--- a/backend/repository/user/get_user_id_by_user_email.py
+++ b/backend/repository/user/get_user_id_by_user_email.py
@@ -1,6 +1,6 @@
from uuid import UUID
-from models.settings import get_supabase_client
+from models import get_supabase_client
def get_user_id_by_user_email(email: str) -> UUID:
diff --git a/backend/repository/user_identity/__init__.py b/backend/repository/user_identity/__init__.py
new file mode 100644
index 000000000..86170c779
--- /dev/null
+++ b/backend/repository/user_identity/__init__.py
@@ -0,0 +1,3 @@
+from .get_user_identity import get_user_identity
+from .create_user_identity import create_user_identity
+from .update_user_identity import update_user_identity, UserIdentityUpdatableProperties
diff --git a/backend/repository/user_identity/create_user_identity.py b/backend/repository/user_identity/create_user_identity.py
index e159c74ac..4e7f838a7 100644
--- a/backend/repository/user_identity/create_user_identity.py
+++ b/backend/repository/user_identity/create_user_identity.py
@@ -1,5 +1,4 @@
-from models.settings import get_supabase_client
-from models.user_identity import UserIdentity
+from models import get_supabase_client, UserIdentity
def create_user_identity(user_identity: UserIdentity) -> UserIdentity:
diff --git a/backend/repository/user_identity/get_user_identity.py b/backend/repository/user_identity/get_user_identity.py
index 14d80255a..5465cd525 100644
--- a/backend/repository/user_identity/get_user_identity.py
+++ b/backend/repository/user_identity/get_user_identity.py
@@ -1,7 +1,6 @@
from uuid import UUID
-from models.settings import get_supabase_client
-from models.user_identity import UserIdentity
+from models import get_supabase_client, UserIdentity
from repository.user_identity.create_user_identity import create_user_identity
diff --git a/backend/repository/user_identity/update_user_identity.py b/backend/repository/user_identity/update_user_identity.py
index 07b91c468..9a04ee4c7 100644
--- a/backend/repository/user_identity/update_user_identity.py
+++ b/backend/repository/user_identity/update_user_identity.py
@@ -1,10 +1,9 @@
from typing import Optional
from uuid import UUID
-from models.settings import get_supabase_client
-from models.user_identity import UserIdentity
+from models import get_supabase_client, UserIdentity
from pydantic import BaseModel
-from repository.user_identity.create_user_identity import create_user_identity
+from repository.user_identity import create_user_identity
class UserIdentityUpdatableProperties(BaseModel):
diff --git a/backend/routes/api_key_routes.py b/backend/routes/api_key_routes.py
index f6b28a88f..8692d9ded 100644
--- a/backend/routes/api_key_routes.py
+++ b/backend/routes/api_key_routes.py
@@ -6,10 +6,13 @@ from asyncpg.exceptions import UniqueViolationError
from auth import AuthBearer, get_current_user
from fastapi import APIRouter, Depends
from logger import get_logger
-from models.settings import get_supabase_db
-from models.users import User
+
+from models import get_supabase_db, User
+
from pydantic import BaseModel
+from models import get_supabase_db, User
+
logger = get_logger(__name__)
diff --git a/backend/routes/authorizations/brain_authorization.py b/backend/routes/authorizations/brain_authorization.py
index b50c15966..c604f29c9 100644
--- a/backend/routes/authorizations/brain_authorization.py
+++ b/backend/routes/authorizations/brain_authorization.py
@@ -3,8 +3,8 @@ from uuid import UUID
from auth.auth_bearer import get_current_user
from fastapi import Depends, HTTPException, status
-from models.users import User
-from repository.brain.get_brain_for_user import get_brain_for_user
+from models import User
+from repository.brain import get_brain_for_user
from routes.authorizations.types import RoleEnum
diff --git a/backend/routes/brain_routes.py b/backend/routes/brain_routes.py
index 82426d928..c754405aa 100644
--- a/backend/routes/brain_routes.py
+++ b/backend/routes/brain_routes.py
@@ -7,22 +7,20 @@ from models.databases.supabase.brains import (
BrainUpdatableProperties,
CreateBrainProperties,
)
-from models.settings import BrainRateLimiting
-from models.users import User
-from repository.brain.create_brain import create_brain
-from repository.brain.create_brain_user import create_brain_user
-from repository.brain.get_brain_details import get_brain_details
-from repository.brain.get_default_user_brain import get_user_default_brain
-from repository.brain.get_default_user_brain_or_create_new import (
+from models import BrainRateLimiting, User
+
+from repository.brain import (
+ create_brain,
+ get_user_brains,
+ get_brain_details,
+ create_brain_user,
+ update_brain_by_id,
+ get_user_default_brain,
+ set_as_default_brain_for_user,
get_default_user_brain_or_create_new,
)
-from repository.brain.get_user_brains import get_user_brains
-from repository.brain.set_as_default_brain_for_user import (
- set_as_default_brain_for_user,
-)
-from repository.brain.update_brain import update_brain_by_id
-from repository.prompt.delete_prompt_py_id import delete_prompt_by_id
-from repository.prompt.get_prompt_by_id import get_prompt_by_id
+
+from repository.prompt import get_prompt_by_id, delete_prompt_by_id
from routes.authorizations.brain_authorization import (
has_brain_authorization,
diff --git a/backend/routes/chat_routes.py b/backend/routes/chat_routes.py
index a660fcd83..c1f42a43f 100644
--- a/backend/routes/chat_routes.py
+++ b/backend/routes/chat_routes.py
@@ -7,6 +7,7 @@ from venv import logger
from auth import AuthBearer, get_current_user
from fastapi import APIRouter, Depends, HTTPException, Query, Request
from fastapi.responses import StreamingResponse
+from llm.qa_headless import HeadlessQA
from llm.openai import OpenAIBrainPicking
from llm.qa_headless import HeadlessQA
from models.brain_entity import BrainEntity
@@ -14,15 +15,27 @@ from models.brains import Brain
from models.chat import Chat
from models.chats import ChatQuestion
from models.databases.supabase.supabase import SupabaseDB
-from models.settings import LLMSettings, get_supabase_db
-from models.users import User
-from repository.brain.get_brain_details import get_brain_details
-from repository.chat.create_chat import CreateChatProperties, create_chat
-from repository.chat.get_chat_by_id import get_chat_by_id
-from repository.chat.get_chat_history import GetChatHistoryOutput, get_chat_history
-from repository.chat.get_user_chats import get_user_chats
-from repository.chat.update_chat import ChatUpdatableProperties, update_chat
-from repository.user_identity.get_user_identity import get_user_identity
+from models import (
+ User,
+ Chat,
+ Brain,
+ LLMSettings,
+ BrainEntity,
+ ChatQuestion,
+ get_supabase_db,
+)
+from repository.brain import get_brain_details
+from repository.chat import (
+ create_chat,
+ update_chat,
+ get_chat_by_id,
+ get_user_chats,
+ get_chat_history,
+ GetChatHistoryOutput,
+ CreateChatProperties,
+ ChatUpdatableProperties,
+)
+from repository.user_identity import get_user_identity
chat_router = APIRouter()
@@ -273,6 +286,11 @@ async def create_stream_question_handler(
if brain_id:
gpt_answer_generator = OpenAIBrainPicking(
chat_id=str(chat_id),
+<<<<<<< HEAD
+ model=(brain_details or chat_question).model if current_user.user_openai_api_key else "gpt-3.5-turbo",
+ max_tokens=(brain_details or chat_question).max_tokens if current_user.user_openai_api_key else 0,
+ temperature=(brain_details or chat_question).temperature if current_user.user_openai_api_key else 256,
+=======
model=(brain_details or chat_question).model
if current_user.user_openai_api_key
else "gpt-3.5-turbo",
@@ -282,12 +300,18 @@ async def create_stream_question_handler(
temperature=(brain_details or chat_question).temperature
if current_user.user_openai_api_key
else 256,
+>>>>>>> main
brain_id=str(brain_id),
user_openai_api_key=current_user.user_openai_api_key, # pyright: ignore reportPrivateUsage=none
streaming=True,
)
else:
gpt_answer_generator = HeadlessQA(
+<<<<<<< HEAD
+ model=chat_question.model if current_user.user_openai_api_key else "gpt-3.5-turbo",
+ temperature=chat_question.temperature if current_user.user_openai_api_key else 256,
+ max_tokens=chat_question.max_tokens if current_user.user_openai_api_key else 0,
+=======
model=chat_question.model
if current_user.user_openai_api_key
else "gpt-3.5-turbo",
@@ -297,6 +321,7 @@ async def create_stream_question_handler(
max_tokens=chat_question.max_tokens
if current_user.user_openai_api_key
else 0,
+>>>>>>> main
user_openai_api_key=current_user.user_openai_api_key, # pyright: ignore reportPrivateUsage=none
chat_id=str(chat_id),
streaming=True,
diff --git a/backend/routes/crawl_routes.py b/backend/routes/crawl_routes.py
index 6706cbe0c..fa62667c7 100644
--- a/backend/routes/crawl_routes.py
+++ b/backend/routes/crawl_routes.py
@@ -6,9 +6,7 @@ from uuid import UUID
from auth import AuthBearer, get_current_user
from crawl.crawler import CrawlWebsite
from fastapi import APIRouter, Depends, Query, Request, UploadFile
-from models.brains import Brain
-from models.files import File
-from models.users import User
+from models import User, Brain, File
from parsers.github import process_github
from utils.file import convert_bytes
from utils.processors import filter_file
diff --git a/backend/routes/explore_routes.py b/backend/routes/explore_routes.py
index e01eb6c66..b094394fb 100644
--- a/backend/routes/explore_routes.py
+++ b/backend/routes/explore_routes.py
@@ -2,9 +2,7 @@ from uuid import UUID
from auth import AuthBearer, get_current_user
from fastapi import APIRouter, Depends, Query
-from models.brains import Brain
-from models.settings import get_supabase_db
-from models.users import User
+from models import User, get_supabase_db, Brain
from routes.authorizations.brain_authorization import (
RoleEnum,
has_brain_authorization,
diff --git a/backend/routes/prompt_routes.py b/backend/routes/prompt_routes.py
index bc323f726..76482195d 100644
--- a/backend/routes/prompt_routes.py
+++ b/backend/routes/prompt_routes.py
@@ -6,11 +6,13 @@ from models.databases.supabase.prompts import (
CreatePromptProperties,
PromptUpdatableProperties,
)
-from models.prompt import Prompt
-from repository.prompt.create_prompt import create_prompt
-from repository.prompt.get_prompt_by_id import get_prompt_by_id
-from repository.prompt.get_public_prompts import get_public_prompts
-from repository.prompt.update_prompt_by_id import update_prompt_by_id
+from models import Prompt
+from repository.prompt import (
+ create_prompt,
+ get_prompt_by_id,
+ get_public_prompts,
+ update_prompt_by_id,
+)
prompt_router = APIRouter()
diff --git a/backend/routes/subscription_routes.py b/backend/routes/subscription_routes.py
index 1d4e4778f..8c3539467 100644
--- a/backend/routes/subscription_routes.py
+++ b/backend/routes/subscription_routes.py
@@ -3,26 +3,21 @@ from uuid import UUID
from auth.auth_bearer import AuthBearer, get_current_user
from fastapi import APIRouter, Depends, HTTPException
-from models.brains import Brain
-from models.brains_subscription_invitations import BrainSubscription
-from models.prompt import PromptStatusEnum
-from models.users import User
+from models import User, BrainSubscription, Brain, PromptStatusEnum
from pydantic import BaseModel
-from repository.brain.create_brain_user import create_brain_user
-from repository.brain.get_brain_by_id import get_brain_by_id
-from repository.brain.get_brain_details import get_brain_details
-from repository.brain.get_brain_for_user import get_brain_for_user
-from repository.brain.update_user_rights import update_brain_user_rights
-from repository.brain_subscription.resend_invitation_email import (
+from repository.brain import (
+ get_brain_by_id,
+ create_brain_user,
+ get_brain_details,
+ get_brain_for_user,
+ update_brain_user_rights,
+)
+from repository.brain_subscription import (
+ SubscriptionInvitationService,
resend_invitation_email,
)
-from repository.brain_subscription.subscription_invitation_service import (
- SubscriptionInvitationService,
-)
-from repository.prompt.delete_prompt_py_id import delete_prompt_by_id
-from repository.prompt.get_prompt_by_id import get_prompt_by_id
-from repository.user.get_user_email_by_user_id import get_user_email_by_user_id
-from repository.user.get_user_id_by_user_email import get_user_id_by_user_email
+from repository.prompt import delete_prompt_by_id, get_prompt_by_id
+from repository.user import get_user_id_by_user_email, get_user_email_by_user_id
from routes.authorizations.brain_authorization import (
RoleEnum,
has_brain_authorization,
diff --git a/backend/routes/upload_routes.py b/backend/routes/upload_routes.py
index 92411b65a..ee0ae9e64 100644
--- a/backend/routes/upload_routes.py
+++ b/backend/routes/upload_routes.py
@@ -3,11 +3,9 @@ from uuid import UUID
from auth import AuthBearer, get_current_user
from fastapi import APIRouter, Depends, Query, Request, UploadFile
-from models.brains import Brain
-from models.files import File
-from models.users import User
-from repository.brain.get_brain_details import get_brain_details
-from repository.user_identity.get_user_identity import get_user_identity
+from models import User, File, Brain
+from repository.brain import get_brain_details
+from repository.user_identity import get_user_identity
from routes.authorizations.brain_authorization import (
RoleEnum,
validate_brain_authorization,
diff --git a/backend/routes/user_routes.py b/backend/routes/user_routes.py
index f12ffaa43..fa51eb6f1 100644
--- a/backend/routes/user_routes.py
+++ b/backend/routes/user_routes.py
@@ -3,15 +3,12 @@ import time
from auth import AuthBearer, get_current_user
from fastapi import APIRouter, Depends, Request
-from models.brains import Brain
-from models.settings import BrainRateLimiting
-from models.user_identity import UserIdentity
-from models.users import User
-from repository.brain.get_default_user_brain import get_user_default_brain
-from repository.user_identity.get_user_identity import get_user_identity
-from repository.user_identity.update_user_identity import (
+from models import User, Brain, BrainRateLimiting, UserIdentity
+from repository.brain import get_user_default_brain
+from repository.user_identity import (
UserIdentityUpdatableProperties,
update_user_identity,
+ get_user_identity,
)
user_router = APIRouter()
diff --git a/backend/utils/vectors.py b/backend/utils/vectors.py
index cc12cee82..d182326e7 100644
--- a/backend/utils/vectors.py
+++ b/backend/utils/vectors.py
@@ -2,9 +2,9 @@ from concurrent.futures import ThreadPoolExecutor
from typing import List
from langchain.embeddings.openai import OpenAIEmbeddings
+from pydantic import BaseModel
from logger import get_logger
from models.settings import get_documents_vector_store, get_embeddings, get_supabase_db
-from pydantic import BaseModel
logger = get_logger(__name__)