mirror of
https://github.com/open-webui/open-webui
synced 2024-12-28 23:02:25 +00:00
refac
This commit is contained in:
parent
8dcee6b6ed
commit
33099bf9e4
@ -45,7 +45,7 @@ from fastapi import Depends, FastAPI, File, HTTPException, Request, UploadFile,
|
|||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
MAX_FILE_SIZE_MB = 25
|
MAX_FILE_SIZE_MB = 25
|
||||||
|
@ -40,7 +40,7 @@ from open_webui.env import ENV, SRC_LOG_LEVELS, ENABLE_FORWARD_USER_INFO_HEADERS
|
|||||||
from fastapi import Depends, FastAPI, HTTPException, Request
|
from fastapi import Depends, FastAPI, HTTPException, Request
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
log.setLevel(SRC_LOG_LEVELS["IMAGES"])
|
log.setLevel(SRC_LOG_LEVELS["IMAGES"])
|
||||||
|
@ -45,7 +45,7 @@ from open_webui.utils.payload import (
|
|||||||
apply_model_params_to_body_openai,
|
apply_model_params_to_body_openai,
|
||||||
apply_model_system_prompt_to_body,
|
apply_model_system_prompt_to_body,
|
||||||
)
|
)
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
from open_webui.utils.access_control import has_access
|
from open_webui.utils.access_control import has_access
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -40,7 +40,7 @@ from open_webui.utils.payload import (
|
|||||||
apply_model_system_prompt_to_body,
|
apply_model_system_prompt_to_body,
|
||||||
)
|
)
|
||||||
|
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
from open_webui.utils.access_control import has_access
|
from open_webui.utils.access_control import has_access
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ from open_webui.utils.misc import (
|
|||||||
extract_folders_after_data_docs,
|
extract_folders_after_data_docs,
|
||||||
sanitize_filename,
|
sanitize_filename,
|
||||||
)
|
)
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
|
|
||||||
from langchain.text_splitter import RecursiveCharacterTextSplitter, TokenTextSplitter
|
from langchain.text_splitter import RecursiveCharacterTextSplitter, TokenTextSplitter
|
||||||
from langchain_core.documents import Document
|
from langchain_core.documents import Document
|
||||||
|
@ -12,7 +12,7 @@ from open_webui.env import (
|
|||||||
WEBSOCKET_MANAGER,
|
WEBSOCKET_MANAGER,
|
||||||
WEBSOCKET_REDIS_URL,
|
WEBSOCKET_REDIS_URL,
|
||||||
)
|
)
|
||||||
from open_webui.utils.utils import decode_token
|
from open_webui.utils.auth import decode_token
|
||||||
from open_webui.apps.socket.utils import RedisDict
|
from open_webui.apps.socket.utils import RedisDict
|
||||||
|
|
||||||
from open_webui.env import (
|
from open_webui.env import (
|
||||||
|
@ -7,7 +7,7 @@ from open_webui.apps.webui.models.users import UserModel, Users
|
|||||||
from open_webui.env import SRC_LOG_LEVELS
|
from open_webui.env import SRC_LOG_LEVELS
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from sqlalchemy import Boolean, Column, String, Text
|
from sqlalchemy import Boolean, Column, String, Text
|
||||||
from open_webui.utils.utils import verify_password
|
from open_webui.utils.auth import verify_password
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
||||||
|
@ -32,7 +32,7 @@ from fastapi import APIRouter, Depends, HTTPException, Request, status
|
|||||||
from fastapi.responses import Response
|
from fastapi.responses import Response
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from open_webui.utils.misc import parse_duration, validate_email_format
|
from open_webui.utils.misc import parse_duration, validate_email_format
|
||||||
from open_webui.utils.utils import (
|
from open_webui.utils.auth import (
|
||||||
create_api_key,
|
create_api_key,
|
||||||
create_token,
|
create_token,
|
||||||
get_admin_user,
|
get_admin_user,
|
||||||
|
@ -19,7 +19,7 @@ from fastapi import APIRouter, Depends, HTTPException, Request, status
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
from open_webui.utils.access_control import has_permission
|
from open_webui.utils.access_control import has_permission
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -3,7 +3,7 @@ from pydantic import BaseModel
|
|||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
from open_webui.config import get_config, save_config
|
from open_webui.config import get_config, save_config
|
||||||
from open_webui.config import BannerModel
|
from open_webui.config import BannerModel
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ from open_webui.apps.webui.models.feedbacks import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ from fastapi import APIRouter, Depends, File, HTTPException, UploadFile, status
|
|||||||
from fastapi.responses import FileResponse, StreamingResponse
|
from fastapi.responses import FileResponse, StreamingResponse
|
||||||
|
|
||||||
|
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
||||||
|
@ -24,7 +24,7 @@ from fastapi import APIRouter, Depends, File, HTTPException, UploadFile, status
|
|||||||
from fastapi.responses import FileResponse, StreamingResponse
|
from fastapi.responses import FileResponse, StreamingResponse
|
||||||
|
|
||||||
|
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
||||||
|
@ -12,7 +12,7 @@ from open_webui.apps.webui.utils import load_function_module_by_id, replace_impo
|
|||||||
from open_webui.config import CACHE_DIR
|
from open_webui.config import CACHE_DIR
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from open_webui.apps.webui.models.groups import (
|
|||||||
from open_webui.config import CACHE_DIR
|
from open_webui.config import CACHE_DIR
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ from open_webui.apps.retrieval.main import process_file, ProcessFileForm
|
|||||||
|
|
||||||
|
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
from open_webui.utils.access_control import has_access, has_permission
|
from open_webui.utils.access_control import has_access, has_permission
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from open_webui.apps.webui.models.memories import Memories, MemoryModel
|
from open_webui.apps.webui.models.memories import Memories, MemoryModel
|
||||||
from open_webui.apps.retrieval.vector.connector import VECTOR_DB_CLIENT
|
from open_webui.apps.retrieval.vector.connector import VECTOR_DB_CLIENT
|
||||||
from open_webui.utils.utils import get_verified_user
|
from open_webui.utils.auth import get_verified_user
|
||||||
from open_webui.env import SRC_LOG_LEVELS
|
from open_webui.env import SRC_LOG_LEVELS
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ from open_webui.constants import ERROR_MESSAGES
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||||
|
|
||||||
|
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
from open_webui.utils.access_control import has_access, has_permission
|
from open_webui.utils.access_control import has_access, has_permission
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from open_webui.apps.webui.models.prompts import (
|
|||||||
)
|
)
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status, Request
|
from fastapi import APIRouter, Depends, HTTPException, status, Request
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
from open_webui.utils.access_control import has_access, has_permission
|
from open_webui.utils.access_control import has_access, has_permission
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
@ -13,7 +13,7 @@ from open_webui.config import CACHE_DIR
|
|||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||||
from open_webui.utils.tools import get_tools_specs
|
from open_webui.utils.tools import get_tools_specs
|
||||||
from open_webui.utils.utils import get_admin_user, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||||
from open_webui.utils.access_control import has_access, has_permission
|
from open_webui.utils.access_control import has_access, has_permission
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from open_webui.constants import ERROR_MESSAGES
|
|||||||
from open_webui.env import SRC_LOG_LEVELS
|
from open_webui.env import SRC_LOG_LEVELS
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from open_webui.utils.utils import get_admin_user, get_password_hash, get_verified_user
|
from open_webui.utils.auth import get_admin_user, get_password_hash, get_verified_user
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
||||||
|
@ -9,7 +9,7 @@ from pydantic import BaseModel
|
|||||||
from starlette.responses import FileResponse
|
from starlette.responses import FileResponse
|
||||||
from open_webui.utils.misc import get_gravatar_url
|
from open_webui.utils.misc import get_gravatar_url
|
||||||
from open_webui.utils.pdf_generator import PDFGenerator
|
from open_webui.utils.pdf_generator import PDFGenerator
|
||||||
from open_webui.utils.utils import get_admin_user
|
from open_webui.utils.auth import get_admin_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ from open_webui.utils.task import (
|
|||||||
tools_function_calling_generation_template,
|
tools_function_calling_generation_template,
|
||||||
)
|
)
|
||||||
from open_webui.utils.tools import get_tools
|
from open_webui.utils.tools import get_tools
|
||||||
from open_webui.utils.utils import (
|
from open_webui.utils.auth import (
|
||||||
decode_token,
|
decode_token,
|
||||||
get_admin_user,
|
get_admin_user,
|
||||||
get_current_user,
|
get_current_user,
|
||||||
|
@ -26,7 +26,7 @@ class TestAuths(AbstractPostgresTest):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_update_profile(self):
|
def test_update_profile(self):
|
||||||
from open_webui.utils.utils import get_password_hash
|
from open_webui.utils.auth import get_password_hash
|
||||||
|
|
||||||
user = self.auths.insert_new_auth(
|
user = self.auths.insert_new_auth(
|
||||||
email="john.doe@openwebui.com",
|
email="john.doe@openwebui.com",
|
||||||
@ -47,7 +47,7 @@ class TestAuths(AbstractPostgresTest):
|
|||||||
assert db_user.profile_image_url == "/user2.png"
|
assert db_user.profile_image_url == "/user2.png"
|
||||||
|
|
||||||
def test_update_password(self):
|
def test_update_password(self):
|
||||||
from open_webui.utils.utils import get_password_hash
|
from open_webui.utils.auth import get_password_hash
|
||||||
|
|
||||||
user = self.auths.insert_new_auth(
|
user = self.auths.insert_new_auth(
|
||||||
email="john.doe@openwebui.com",
|
email="john.doe@openwebui.com",
|
||||||
@ -74,7 +74,7 @@ class TestAuths(AbstractPostgresTest):
|
|||||||
assert new_auth is not None
|
assert new_auth is not None
|
||||||
|
|
||||||
def test_signin(self):
|
def test_signin(self):
|
||||||
from open_webui.utils.utils import get_password_hash
|
from open_webui.utils.auth import get_password_hash
|
||||||
|
|
||||||
user = self.auths.insert_new_auth(
|
user = self.auths.insert_new_auth(
|
||||||
email="john.doe@openwebui.com",
|
email="john.doe@openwebui.com",
|
||||||
|
@ -13,7 +13,7 @@ def mock_webui_user(**kwargs):
|
|||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def mock_user(app: FastAPI, **kwargs):
|
def mock_user(app: FastAPI, **kwargs):
|
||||||
from open_webui.utils.utils import (
|
from open_webui.utils.auth import (
|
||||||
get_current_user,
|
get_current_user,
|
||||||
get_verified_user,
|
get_verified_user,
|
||||||
get_admin_user,
|
get_admin_user,
|
||||||
|
@ -33,7 +33,7 @@ from open_webui.config import (
|
|||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from open_webui.env import WEBUI_SESSION_COOKIE_SAME_SITE, WEBUI_SESSION_COOKIE_SECURE
|
from open_webui.env import WEBUI_SESSION_COOKIE_SAME_SITE, WEBUI_SESSION_COOKIE_SECURE
|
||||||
from open_webui.utils.misc import parse_duration
|
from open_webui.utils.misc import parse_duration
|
||||||
from open_webui.utils.utils import get_password_hash, create_token
|
from open_webui.utils.auth import get_password_hash, create_token
|
||||||
from open_webui.utils.webhook import post_webhook
|
from open_webui.utils.webhook import post_webhook
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
Loading…
Reference in New Issue
Block a user