mirror of
https://github.com/StanGirard/quivr.git
synced 2024-09-11 13:15:41 +03:00
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
This commit is contained in:
parent
5b79025a03
commit
8af6d61e76
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,6 +6,9 @@ toto.txt
|
|||||||
*.ipynb
|
*.ipynb
|
||||||
log.txt
|
log.txt
|
||||||
|
|
||||||
|
backend/venv
|
||||||
|
backend/.env
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -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
|
21
.idea/inspectionProfiles/Project_Default.xml
Normal file
21
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredErrors">
|
||||||
|
<list>
|
||||||
|
<option value="N803" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredIdentifiers">
|
||||||
|
<list>
|
||||||
|
<option value="bytes.__await__" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/quivr-llm.iml" filepath="$PROJECT_DIR$/.idea/quivr-llm.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
15
.idea/quivr-llm.iml
Normal file
15
.idea/quivr-llm.iml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/backend" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/backend/core" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -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 auth.jwt_token_handler import decode_access_token, verify_token
|
||||||
from fastapi import Depends, HTTPException, Request
|
from fastapi import Depends, HTTPException, Request
|
||||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
||||||
from models.users import User
|
from models import User
|
||||||
|
|
||||||
|
|
||||||
class AuthBearer(HTTPBearer):
|
class AuthBearer(HTTPBearer):
|
||||||
|
@ -4,7 +4,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from jose import jwt
|
from jose import jwt
|
||||||
from jose.exceptions import JWTError
|
from jose.exceptions import JWTError
|
||||||
from models.users import User
|
from models import User
|
||||||
|
|
||||||
SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
|
SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
|
||||||
ALGORITHM = "HS256"
|
ALGORITHM = "HS256"
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# import needed here when running main.py to debug backend
|
# import needed here when running main.py to debug backend
|
||||||
# you will need to run pip install python-dotenv
|
# you will need to run pip install python-dotenv
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
from fastapi import FastAPI, HTTPException, Request, status
|
from fastapi import FastAPI, HTTPException, Request, status
|
||||||
@ -26,15 +28,10 @@ app = FastAPI()
|
|||||||
|
|
||||||
add_cors_middleware(app)
|
add_cors_middleware(app)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.include_router(chat_router)
|
app.include_router(chat_router)
|
||||||
app.include_router(misc_router)
|
app.include_router(misc_router)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.exception_handler(HTTPException)
|
@app.exception_handler(HTTPException)
|
||||||
async def http_exception_handler(_, exc):
|
async def http_exception_handler(_, exc):
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
@ -47,7 +44,7 @@ async def http_exception_handler(_, exc):
|
|||||||
def handle_request_validation_error(app: FastAPI):
|
def handle_request_validation_error(app: FastAPI):
|
||||||
@app.exception_handler(RequestValidationError)
|
@app.exception_handler(RequestValidationError)
|
||||||
async def validation_exception_handler(
|
async def validation_exception_handler(
|
||||||
request: Request, exc: RequestValidationError
|
request: Request, exc: RequestValidationError
|
||||||
):
|
):
|
||||||
exc_str = f"{exc}".replace("\n", " ").replace(" ", " ")
|
exc_str = f"{exc}".replace("\n", " ").replace(" ", " ")
|
||||||
logger.error(request, exc_str)
|
logger.error(request, exc_str)
|
||||||
@ -66,5 +63,5 @@ handle_request_validation_error(app)
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# run main.py to debug backend
|
# run main.py to debug backend
|
||||||
import uvicorn
|
import uvicorn
|
||||||
uvicorn.run(app, host="0.0.0.0", port=5050)
|
|
||||||
|
|
||||||
|
uvicorn.run(app, host="0.0.0.0", port=5050)
|
||||||
|
@ -3,8 +3,10 @@ from typing import AsyncIterable, List
|
|||||||
|
|
||||||
from langchain.callbacks.streaming_aiter import AsyncIteratorCallbackHandler
|
from langchain.callbacks.streaming_aiter import AsyncIteratorCallbackHandler
|
||||||
from logger import get_logger
|
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 pydantic import BaseModel # For data validation and settings management
|
||||||
|
from models import BrainSettings # Importing settings related to the 'brain'
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@ import asyncio
|
|||||||
import json
|
import json
|
||||||
from typing import AsyncIterable, Awaitable
|
from typing import AsyncIterable, Awaitable
|
||||||
from uuid import UUID
|
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.callbacks.streaming_aiter import AsyncIteratorCallbackHandler
|
||||||
from langchain.chains import ConversationalRetrievalChain, LLMChain
|
from langchain.chains import ConversationalRetrievalChain, LLMChain
|
||||||
from langchain.chains.question_answering import load_qa_chain
|
from langchain.chains.question_answering import load_qa_chain
|
||||||
@ -13,16 +15,19 @@ from langchain.prompts.chat import (
|
|||||||
HumanMessagePromptTemplate,
|
HumanMessagePromptTemplate,
|
||||||
SystemMessagePromptTemplate,
|
SystemMessagePromptTemplate,
|
||||||
)
|
)
|
||||||
|
|
||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.chats import ChatQuestion
|
from models import ChatQuestion
|
||||||
from models.databases.supabase.chats import CreateChatHistory
|
from models.databases.supabase.chats import CreateChatHistory
|
||||||
from repository.brain.get_brain_by_id import get_brain_by_id
|
from repository.brain import get_brain_by_id, get_brain_prompt_id
|
||||||
from repository.brain.get_brain_prompt_id import get_brain_prompt_id
|
from repository.chat import (
|
||||||
from repository.chat.format_chat_history import format_chat_history
|
get_chat_history,
|
||||||
from repository.chat.get_chat_history import GetChatHistoryOutput, get_chat_history
|
update_chat_history,
|
||||||
from repository.chat.update_chat_history import update_chat_history
|
format_chat_history,
|
||||||
from repository.chat.update_message_by_id import update_message_by_id
|
GetChatHistoryOutput,
|
||||||
from repository.prompt.get_prompt_by_id import get_prompt_by_id
|
update_message_by_id,
|
||||||
|
)
|
||||||
|
from repository.prompt import get_prompt_by_id
|
||||||
from supabase.client import Client, create_client
|
from supabase.client import Client, create_client
|
||||||
from vectorstore.supabase import CustomSupabaseVectorStore
|
from vectorstore.supabase import CustomSupabaseVectorStore
|
||||||
|
|
||||||
|
@ -10,15 +10,17 @@ from langchain.prompts.chat import (
|
|||||||
ChatPromptTemplate,
|
ChatPromptTemplate,
|
||||||
HumanMessagePromptTemplate,
|
HumanMessagePromptTemplate,
|
||||||
)
|
)
|
||||||
from repository.chat.update_message_by_id import update_message_by_id
|
|
||||||
from models.databases.supabase.chats import CreateChatHistory
|
from models.databases.supabase.chats import CreateChatHistory
|
||||||
from repository.chat.format_chat_history import format_chat_history
|
from repository.chat import (
|
||||||
from repository.chat.get_chat_history import get_chat_history
|
update_message_by_id,
|
||||||
from repository.chat.update_chat_history import update_chat_history
|
format_chat_history,
|
||||||
from repository.chat.format_chat_history import format_history_to_openai_mesages
|
get_chat_history,
|
||||||
|
update_chat_history,
|
||||||
|
format_history_to_openai_mesages,
|
||||||
|
GetChatHistoryOutput,
|
||||||
|
)
|
||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.chats import ChatQuestion
|
from models import ChatQuestion
|
||||||
from repository.chat.get_chat_history import GetChatHistoryOutput
|
|
||||||
|
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
@ -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
|
||||||
|
# )
|
@ -5,8 +5,8 @@ import time
|
|||||||
import openai
|
import openai
|
||||||
from langchain.schema import Document
|
from langchain.schema import Document
|
||||||
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
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
|
from utils.file import compute_sha1_from_content
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from langchain.schema import Document
|
from langchain.schema import Document
|
||||||
from models.brains import Brain
|
from models import Brain, File
|
||||||
from models.files import File
|
|
||||||
from utils.vectors import Neurons
|
from utils.vectors import Neurons
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import CSVLoader
|
from langchain.document_loaders import CSVLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import Docx2txtLoader
|
from langchain.document_loaders import Docx2txtLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders.epub import UnstructuredEPubLoader
|
from langchain.document_loaders.epub import UnstructuredEPubLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -4,8 +4,7 @@ import time
|
|||||||
from langchain.document_loaders import GitLoader
|
from langchain.document_loaders import GitLoader
|
||||||
from langchain.schema import Document
|
from langchain.schema import Document
|
||||||
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
||||||
from models.brains import Brain
|
from models import Brain, File
|
||||||
from models.files import File
|
|
||||||
from utils.file import compute_sha1_from_content
|
from utils.file import compute_sha1_from_content
|
||||||
from utils.vectors import Neurons
|
from utils.vectors import Neurons
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import UnstructuredHTMLLoader
|
from langchain.document_loaders import UnstructuredHTMLLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import UnstructuredMarkdownLoader
|
from langchain.document_loaders import UnstructuredMarkdownLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import NotebookLoader
|
from langchain.document_loaders import NotebookLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import PyMuPDFLoader
|
from langchain.document_loaders import PyMuPDFLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import PyMuPDFLoader
|
from langchain.document_loaders import PyMuPDFLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import UnstructuredPowerPointLoader
|
from langchain.document_loaders import UnstructuredPowerPointLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from langchain.document_loaders import TextLoader
|
from langchain.document_loaders import TextLoader
|
||||||
from models.files import File
|
from models import File
|
||||||
|
|
||||||
from .common import process_file
|
from .common import process_file
|
||||||
|
|
||||||
|
12
backend/repository/brain/__init__.py
Normal file
12
backend/repository/brain/__init__.py
Normal file
@ -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
|
@ -1,6 +1,5 @@
|
|||||||
from models.brain_entity import BrainEntity
|
|
||||||
from models.databases.supabase.brains import CreateBrainProperties
|
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:
|
def create_brain(brain: CreateBrainProperties) -> BrainEntity:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.settings import get_supabase_db
|
from models import get_supabase_db
|
||||||
from routes.authorizations.types import RoleEnum
|
from routes.authorizations.types import RoleEnum
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.brain_entity import BrainEntity
|
from models import BrainEntity, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def get_brain_by_id(brain_id: UUID) -> BrainEntity | None:
|
def get_brain_by_id(brain_id: UUID) -> BrainEntity | None:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.brain_entity import BrainEntity
|
from models import BrainEntity, get_supabase_client
|
||||||
from models.settings import get_supabase_client
|
|
||||||
|
|
||||||
|
|
||||||
def get_brain_details(brain_id: UUID) -> BrainEntity | None:
|
def get_brain_details(brain_id: UUID) -> BrainEntity | None:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.brain_entity import MinimalBrainEntity
|
from models import MinimalBrainEntity, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def get_brain_for_user(user_id: UUID, brain_id: UUID) -> MinimalBrainEntity:
|
def get_brain_for_user(user_id: UUID, brain_id: UUID) -> MinimalBrainEntity:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from uuid import UUID
|
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:
|
def get_brain_prompt_id(brain_id: UUID) -> UUID | None:
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.brain_entity import BrainEntity
|
from models import BrainEntity, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
from repository.brain import get_brain_by_id
|
||||||
from repository.brain.get_brain_by_id import get_brain_by_id
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
from models.brain_entity import BrainEntity
|
|
||||||
from models.databases.supabase.brains import CreateBrainProperties
|
from models.databases.supabase.brains import CreateBrainProperties
|
||||||
from models.users import User
|
from models import BrainEntity, 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 routes.authorizations.types import RoleEnum
|
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:
|
def get_default_user_brain_or_create_new(user: User) -> BrainEntity:
|
||||||
default_brain = get_user_default_brain(user.id)
|
default_brain = get_user_default_brain(user.id)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.brain_entity import BrainEntity
|
from models import BrainEntity, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def get_user_brains(user_id: UUID) -> list[BrainEntity]:
|
def get_user_brains(user_id: UUID) -> list[BrainEntity]:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.settings import get_supabase_client
|
from models import get_supabase_client
|
||||||
from repository.brain.get_default_user_brain import get_user_default_brain
|
from repository.brain import get_user_default_brain
|
||||||
|
|
||||||
|
|
||||||
def set_as_default_brain_for_user(user_id: UUID, brain_id: UUID):
|
def set_as_default_brain_for_user(user_id: UUID, brain_id: UUID):
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.brain_entity import BrainEntity
|
|
||||||
from models.databases.supabase.brains import BrainUpdatableProperties
|
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:
|
def update_brain_by_id(brain_id: UUID, brain: BrainUpdatableProperties) -> BrainEntity:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from uuid import UUID
|
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:
|
def update_brain_user_rights(brain_id: UUID, user_id: UUID, rights: str) -> None:
|
||||||
|
@ -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
|
@ -1,10 +1,9 @@
|
|||||||
import resend
|
import resend
|
||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.brains_subscription_invitations import BrainSubscription
|
from models import BrainSubscription, BrainSettings
|
||||||
from models.settings import BrainSettings
|
|
||||||
|
|
||||||
from repository.brain.get_brain_details import get_brain_details
|
from repository.brain import get_brain_details
|
||||||
from repository.brain_subscription.get_brain_url import get_brain_url
|
from repository.brain_subscription import get_brain_url
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.brains_subscription_invitations import BrainSubscription
|
from models import BrainSubscription, get_supabase_client
|
||||||
from models.settings import get_supabase_client
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -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
|
@ -2,8 +2,7 @@ from dataclasses import dataclass
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.chat import Chat
|
from models import Chat, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from models.chat import Chat
|
from models import Chat, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def get_chat_by_id(chat_id: str) -> Chat:
|
def get_chat_by_id(chat_id: str) -> Chat:
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.chat import ChatHistory
|
from models import ChatHistory, get_supabase_db
|
||||||
from models.settings import get_supabase_db # For type hinting
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from repository.brain.get_brain_by_id import get_brain_by_id
|
from repository.brain import get_brain_by_id
|
||||||
from repository.prompt.get_prompt_by_id import get_prompt_by_id
|
from repository.prompt import get_prompt_by_id
|
||||||
|
|
||||||
|
|
||||||
class GetChatHistoryOutput(BaseModel):
|
class GetChatHistoryOutput(BaseModel):
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from models.chat import Chat
|
from models import Chat, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def get_user_chats(user_id: str) -> List[Chat]:
|
def get_user_chats(user_id: str) -> List[Chat]:
|
||||||
|
@ -2,8 +2,7 @@ from dataclasses import dataclass
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.chat import Chat
|
from models import Chat, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException
|
||||||
from models.chat import ChatHistory
|
|
||||||
from models.databases.supabase.chats import CreateChatHistory
|
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:
|
def update_chat_history(chat_history: CreateChatHistory) -> ChatHistory:
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.chat import ChatHistory
|
from models import ChatHistory, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
5
backend/repository/prompt/__init__.py
Normal file
5
backend/repository/prompt/__init__.py
Normal file
@ -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
|
@ -1,6 +1,5 @@
|
|||||||
from models.databases.supabase.prompts import CreatePromptProperties
|
from models.databases.supabase.prompts import CreatePromptProperties
|
||||||
from models.prompt import Prompt
|
from models import Prompt, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def create_prompt(prompt: CreatePromptProperties) -> Prompt:
|
def create_prompt(prompt: CreatePromptProperties) -> Prompt:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.databases.supabase.prompts import DeletePromptResponse
|
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:
|
def delete_prompt_by_id(prompt_id: UUID) -> DeletePromptResponse:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.prompt import Prompt
|
from models import Prompt, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def get_prompt_by_id(prompt_id: UUID) -> Prompt | None:
|
def get_prompt_by_id(prompt_id: UUID) -> Prompt | None:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from models.prompt import Prompt
|
from models import Prompt, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def get_public_prompts() -> list[Prompt]:
|
def get_public_prompts() -> list[Prompt]:
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.databases.supabase.prompts import PromptUpdatableProperties
|
from models.databases.supabase.prompts import PromptUpdatableProperties
|
||||||
from models.prompt import Prompt
|
from models import Prompt, get_supabase_db
|
||||||
from models.settings import get_supabase_db
|
|
||||||
|
|
||||||
|
|
||||||
def update_prompt_by_id(prompt_id: UUID, prompt: PromptUpdatableProperties) -> Prompt:
|
def update_prompt_by_id(prompt_id: UUID, prompt: PromptUpdatableProperties) -> Prompt:
|
||||||
|
2
backend/repository/user/__init__.py
Normal file
2
backend/repository/user/__init__.py
Normal file
@ -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
|
@ -1,6 +1,6 @@
|
|||||||
from uuid import UUID
|
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:
|
def get_user_email_by_user_id(user_id: UUID) -> str:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from uuid import UUID
|
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:
|
def get_user_id_by_user_email(email: str) -> UUID:
|
||||||
|
3
backend/repository/user_identity/__init__.py
Normal file
3
backend/repository/user_identity/__init__.py
Normal file
@ -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
|
@ -1,5 +1,4 @@
|
|||||||
from models.settings import get_supabase_client
|
from models import get_supabase_client, UserIdentity
|
||||||
from models.user_identity import UserIdentity
|
|
||||||
|
|
||||||
|
|
||||||
def create_user_identity(user_identity: UserIdentity) -> UserIdentity:
|
def create_user_identity(user_identity: UserIdentity) -> UserIdentity:
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.settings import get_supabase_client
|
from models import get_supabase_client, UserIdentity
|
||||||
from models.user_identity import UserIdentity
|
|
||||||
from repository.user_identity.create_user_identity import create_user_identity
|
from repository.user_identity.create_user_identity import create_user_identity
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from models.settings import get_supabase_client
|
from models import get_supabase_client, UserIdentity
|
||||||
from models.user_identity import UserIdentity
|
|
||||||
from pydantic import BaseModel
|
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):
|
class UserIdentityUpdatableProperties(BaseModel):
|
||||||
|
@ -6,10 +6,13 @@ from asyncpg.exceptions import UniqueViolationError
|
|||||||
from auth import AuthBearer, get_current_user
|
from auth import AuthBearer, get_current_user
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
from logger import get_logger
|
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 pydantic import BaseModel
|
||||||
|
|
||||||
|
from models import get_supabase_db, User
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ from uuid import UUID
|
|||||||
|
|
||||||
from auth.auth_bearer import get_current_user
|
from auth.auth_bearer import get_current_user
|
||||||
from fastapi import Depends, HTTPException, status
|
from fastapi import Depends, HTTPException, status
|
||||||
from models.users import User
|
from models import User
|
||||||
from repository.brain.get_brain_for_user import get_brain_for_user
|
from repository.brain import get_brain_for_user
|
||||||
|
|
||||||
from routes.authorizations.types import RoleEnum
|
from routes.authorizations.types import RoleEnum
|
||||||
|
|
||||||
|
@ -7,22 +7,20 @@ from models.databases.supabase.brains import (
|
|||||||
BrainUpdatableProperties,
|
BrainUpdatableProperties,
|
||||||
CreateBrainProperties,
|
CreateBrainProperties,
|
||||||
)
|
)
|
||||||
from models.settings import BrainRateLimiting
|
from models import BrainRateLimiting, User
|
||||||
from models.users import User
|
|
||||||
from repository.brain.create_brain import create_brain
|
from repository.brain import (
|
||||||
from repository.brain.create_brain_user import create_brain_user
|
create_brain,
|
||||||
from repository.brain.get_brain_details import get_brain_details
|
get_user_brains,
|
||||||
from repository.brain.get_default_user_brain import get_user_default_brain
|
get_brain_details,
|
||||||
from repository.brain.get_default_user_brain_or_create_new import (
|
create_brain_user,
|
||||||
|
update_brain_by_id,
|
||||||
|
get_user_default_brain,
|
||||||
|
set_as_default_brain_for_user,
|
||||||
get_default_user_brain_or_create_new,
|
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 (
|
from repository.prompt import get_prompt_by_id, delete_prompt_by_id
|
||||||
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 routes.authorizations.brain_authorization import (
|
from routes.authorizations.brain_authorization import (
|
||||||
has_brain_authorization,
|
has_brain_authorization,
|
||||||
|
@ -7,6 +7,7 @@ from venv import logger
|
|||||||
from auth import AuthBearer, get_current_user
|
from auth import AuthBearer, get_current_user
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request
|
from fastapi import APIRouter, Depends, HTTPException, Query, Request
|
||||||
from fastapi.responses import StreamingResponse
|
from fastapi.responses import StreamingResponse
|
||||||
|
from llm.qa_headless import HeadlessQA
|
||||||
from llm.openai import OpenAIBrainPicking
|
from llm.openai import OpenAIBrainPicking
|
||||||
from llm.qa_headless import HeadlessQA
|
from llm.qa_headless import HeadlessQA
|
||||||
from models.brain_entity import BrainEntity
|
from models.brain_entity import BrainEntity
|
||||||
@ -14,15 +15,27 @@ from models.brains import Brain
|
|||||||
from models.chat import Chat
|
from models.chat import Chat
|
||||||
from models.chats import ChatQuestion
|
from models.chats import ChatQuestion
|
||||||
from models.databases.supabase.supabase import SupabaseDB
|
from models.databases.supabase.supabase import SupabaseDB
|
||||||
from models.settings import LLMSettings, get_supabase_db
|
from models import (
|
||||||
from models.users import User
|
User,
|
||||||
from repository.brain.get_brain_details import get_brain_details
|
Chat,
|
||||||
from repository.chat.create_chat import CreateChatProperties, create_chat
|
Brain,
|
||||||
from repository.chat.get_chat_by_id import get_chat_by_id
|
LLMSettings,
|
||||||
from repository.chat.get_chat_history import GetChatHistoryOutput, get_chat_history
|
BrainEntity,
|
||||||
from repository.chat.get_user_chats import get_user_chats
|
ChatQuestion,
|
||||||
from repository.chat.update_chat import ChatUpdatableProperties, update_chat
|
get_supabase_db,
|
||||||
from repository.user_identity.get_user_identity import get_user_identity
|
)
|
||||||
|
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()
|
chat_router = APIRouter()
|
||||||
|
|
||||||
@ -273,6 +286,11 @@ async def create_stream_question_handler(
|
|||||||
if brain_id:
|
if brain_id:
|
||||||
gpt_answer_generator = OpenAIBrainPicking(
|
gpt_answer_generator = OpenAIBrainPicking(
|
||||||
chat_id=str(chat_id),
|
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
|
model=(brain_details or chat_question).model
|
||||||
if current_user.user_openai_api_key
|
if current_user.user_openai_api_key
|
||||||
else "gpt-3.5-turbo",
|
else "gpt-3.5-turbo",
|
||||||
@ -282,12 +300,18 @@ async def create_stream_question_handler(
|
|||||||
temperature=(brain_details or chat_question).temperature
|
temperature=(brain_details or chat_question).temperature
|
||||||
if current_user.user_openai_api_key
|
if current_user.user_openai_api_key
|
||||||
else 256,
|
else 256,
|
||||||
|
>>>>>>> main
|
||||||
brain_id=str(brain_id),
|
brain_id=str(brain_id),
|
||||||
user_openai_api_key=current_user.user_openai_api_key, # pyright: ignore reportPrivateUsage=none
|
user_openai_api_key=current_user.user_openai_api_key, # pyright: ignore reportPrivateUsage=none
|
||||||
streaming=True,
|
streaming=True,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
gpt_answer_generator = HeadlessQA(
|
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
|
model=chat_question.model
|
||||||
if current_user.user_openai_api_key
|
if current_user.user_openai_api_key
|
||||||
else "gpt-3.5-turbo",
|
else "gpt-3.5-turbo",
|
||||||
@ -297,6 +321,7 @@ async def create_stream_question_handler(
|
|||||||
max_tokens=chat_question.max_tokens
|
max_tokens=chat_question.max_tokens
|
||||||
if current_user.user_openai_api_key
|
if current_user.user_openai_api_key
|
||||||
else 0,
|
else 0,
|
||||||
|
>>>>>>> main
|
||||||
user_openai_api_key=current_user.user_openai_api_key, # pyright: ignore reportPrivateUsage=none
|
user_openai_api_key=current_user.user_openai_api_key, # pyright: ignore reportPrivateUsage=none
|
||||||
chat_id=str(chat_id),
|
chat_id=str(chat_id),
|
||||||
streaming=True,
|
streaming=True,
|
||||||
|
@ -6,9 +6,7 @@ from uuid import UUID
|
|||||||
from auth import AuthBearer, get_current_user
|
from auth import AuthBearer, get_current_user
|
||||||
from crawl.crawler import CrawlWebsite
|
from crawl.crawler import CrawlWebsite
|
||||||
from fastapi import APIRouter, Depends, Query, Request, UploadFile
|
from fastapi import APIRouter, Depends, Query, Request, UploadFile
|
||||||
from models.brains import Brain
|
from models import User, Brain, File
|
||||||
from models.files import File
|
|
||||||
from models.users import User
|
|
||||||
from parsers.github import process_github
|
from parsers.github import process_github
|
||||||
from utils.file import convert_bytes
|
from utils.file import convert_bytes
|
||||||
from utils.processors import filter_file
|
from utils.processors import filter_file
|
||||||
|
@ -2,9 +2,7 @@ from uuid import UUID
|
|||||||
|
|
||||||
from auth import AuthBearer, get_current_user
|
from auth import AuthBearer, get_current_user
|
||||||
from fastapi import APIRouter, Depends, Query
|
from fastapi import APIRouter, Depends, Query
|
||||||
from models.brains import Brain
|
from models import User, get_supabase_db, Brain
|
||||||
from models.settings import get_supabase_db
|
|
||||||
from models.users import User
|
|
||||||
from routes.authorizations.brain_authorization import (
|
from routes.authorizations.brain_authorization import (
|
||||||
RoleEnum,
|
RoleEnum,
|
||||||
has_brain_authorization,
|
has_brain_authorization,
|
||||||
|
@ -6,11 +6,13 @@ from models.databases.supabase.prompts import (
|
|||||||
CreatePromptProperties,
|
CreatePromptProperties,
|
||||||
PromptUpdatableProperties,
|
PromptUpdatableProperties,
|
||||||
)
|
)
|
||||||
from models.prompt import Prompt
|
from models import Prompt
|
||||||
from repository.prompt.create_prompt import create_prompt
|
from repository.prompt import (
|
||||||
from repository.prompt.get_prompt_by_id import get_prompt_by_id
|
create_prompt,
|
||||||
from repository.prompt.get_public_prompts import get_public_prompts
|
get_prompt_by_id,
|
||||||
from repository.prompt.update_prompt_by_id import update_prompt_by_id
|
get_public_prompts,
|
||||||
|
update_prompt_by_id,
|
||||||
|
)
|
||||||
|
|
||||||
prompt_router = APIRouter()
|
prompt_router = APIRouter()
|
||||||
|
|
||||||
|
@ -3,26 +3,21 @@ from uuid import UUID
|
|||||||
|
|
||||||
from auth.auth_bearer import AuthBearer, get_current_user
|
from auth.auth_bearer import AuthBearer, get_current_user
|
||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from models.brains import Brain
|
from models import User, BrainSubscription, Brain, PromptStatusEnum
|
||||||
from models.brains_subscription_invitations import BrainSubscription
|
|
||||||
from models.prompt import PromptStatusEnum
|
|
||||||
from models.users import User
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from repository.brain.create_brain_user import create_brain_user
|
from repository.brain import (
|
||||||
from repository.brain.get_brain_by_id import get_brain_by_id
|
get_brain_by_id,
|
||||||
from repository.brain.get_brain_details import get_brain_details
|
create_brain_user,
|
||||||
from repository.brain.get_brain_for_user import get_brain_for_user
|
get_brain_details,
|
||||||
from repository.brain.update_user_rights import update_brain_user_rights
|
get_brain_for_user,
|
||||||
from repository.brain_subscription.resend_invitation_email import (
|
update_brain_user_rights,
|
||||||
|
)
|
||||||
|
from repository.brain_subscription import (
|
||||||
|
SubscriptionInvitationService,
|
||||||
resend_invitation_email,
|
resend_invitation_email,
|
||||||
)
|
)
|
||||||
from repository.brain_subscription.subscription_invitation_service import (
|
from repository.prompt import delete_prompt_by_id, get_prompt_by_id
|
||||||
SubscriptionInvitationService,
|
from repository.user import get_user_id_by_user_email, get_user_email_by_user_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.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 routes.authorizations.brain_authorization import (
|
from routes.authorizations.brain_authorization import (
|
||||||
RoleEnum,
|
RoleEnum,
|
||||||
has_brain_authorization,
|
has_brain_authorization,
|
||||||
|
@ -3,11 +3,9 @@ from uuid import UUID
|
|||||||
|
|
||||||
from auth import AuthBearer, get_current_user
|
from auth import AuthBearer, get_current_user
|
||||||
from fastapi import APIRouter, Depends, Query, Request, UploadFile
|
from fastapi import APIRouter, Depends, Query, Request, UploadFile
|
||||||
from models.brains import Brain
|
from models import User, File, Brain
|
||||||
from models.files import File
|
from repository.brain import get_brain_details
|
||||||
from models.users import User
|
from repository.user_identity import get_user_identity
|
||||||
from repository.brain.get_brain_details import get_brain_details
|
|
||||||
from repository.user_identity.get_user_identity import get_user_identity
|
|
||||||
from routes.authorizations.brain_authorization import (
|
from routes.authorizations.brain_authorization import (
|
||||||
RoleEnum,
|
RoleEnum,
|
||||||
validate_brain_authorization,
|
validate_brain_authorization,
|
||||||
|
@ -3,15 +3,12 @@ import time
|
|||||||
|
|
||||||
from auth import AuthBearer, get_current_user
|
from auth import AuthBearer, get_current_user
|
||||||
from fastapi import APIRouter, Depends, Request
|
from fastapi import APIRouter, Depends, Request
|
||||||
from models.brains import Brain
|
from models import User, Brain, BrainRateLimiting, UserIdentity
|
||||||
from models.settings import BrainRateLimiting
|
from repository.brain import get_user_default_brain
|
||||||
from models.user_identity import UserIdentity
|
from repository.user_identity import (
|
||||||
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 (
|
|
||||||
UserIdentityUpdatableProperties,
|
UserIdentityUpdatableProperties,
|
||||||
update_user_identity,
|
update_user_identity,
|
||||||
|
get_user_identity,
|
||||||
)
|
)
|
||||||
|
|
||||||
user_router = APIRouter()
|
user_router = APIRouter()
|
||||||
|
@ -2,9 +2,9 @@ from concurrent.futures import ThreadPoolExecutor
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from langchain.embeddings.openai import OpenAIEmbeddings
|
from langchain.embeddings.openai import OpenAIEmbeddings
|
||||||
|
from pydantic import BaseModel
|
||||||
from logger import get_logger
|
from logger import get_logger
|
||||||
from models.settings import get_documents_vector_store, get_embeddings, get_supabase_db
|
from models.settings import get_documents_vector_store, get_embeddings, get_supabase_db
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user