diff --git a/api/controllers/console/apikey.py b/api/controllers/console/apikey.py index 211ada6267c74e..22c9f85f452311 100644 --- a/api/controllers/console/apikey.py +++ b/api/controllers/console/apikey.py @@ -1,5 +1,5 @@ from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required import flask_restful from flask_restful import Resource, fields, marshal_with from werkzeug.exceptions import Forbidden diff --git a/api/controllers/console/app/app.py b/api/controllers/console/app/app.py index 0acbc3ae47d947..3f811d70557473 100644 --- a/api/controllers/console/app/app.py +++ b/api/controllers/console/app/app.py @@ -3,10 +3,9 @@ import logging from datetime import datetime -import flask from flask_login import current_user -from core.login.login import login_required -from flask_restful import Resource, reqparse, fields, marshal_with, abort, inputs +from libs.login import login_required +from flask_restful import Resource, reqparse, marshal_with, abort, inputs from werkzeug.exceptions import Forbidden from constants.model_template import model_templates, demo_model_templates @@ -17,11 +16,9 @@ from core.model_providers.error import ProviderTokenNotInitError, LLMBadRequestError from core.model_providers.model_factory import ModelFactory from core.model_providers.model_provider_factory import ModelProviderFactory -from core.model_providers.models.entity.model_params import ModelType from events.app_event import app_was_created, app_was_deleted from fields.app_fields import app_pagination_fields, app_detail_fields, template_list_fields, \ app_detail_fields_with_site -from libs.helper import TimestampField from extensions.ext_database import db from models.model import App, AppModelConfig, Site from services.app_model_config_service import AppModelConfigService diff --git a/api/controllers/console/app/audio.py b/api/controllers/console/app/audio.py index 03dd12da3ea2bd..628b586d5a7da7 100644 --- a/api/controllers/console/app/audio.py +++ b/api/controllers/console/app/audio.py @@ -2,8 +2,8 @@ import logging from flask import request -from core.login.login import login_required -from werkzeug.exceptions import InternalServerError, NotFound +from libs.login import login_required +from werkzeug.exceptions import InternalServerError import services from controllers.console import api diff --git a/api/controllers/console/app/completion.py b/api/controllers/console/app/completion.py index 02b3360a08ccdc..1da7bd8f2ce974 100644 --- a/api/controllers/console/app/completion.py +++ b/api/controllers/console/app/completion.py @@ -5,7 +5,7 @@ import flask_login from flask import Response, stream_with_context -from core.login.login import login_required +from libs.login import login_required from werkzeug.exceptions import InternalServerError, NotFound import services diff --git a/api/controllers/console/app/conversation.py b/api/controllers/console/app/conversation.py index bbc95c61f750db..af4323324e3ec6 100644 --- a/api/controllers/console/app/conversation.py +++ b/api/controllers/console/app/conversation.py @@ -2,8 +2,8 @@ import pytz from flask_login import current_user -from core.login.login import login_required -from flask_restful import Resource, reqparse, fields, marshal_with +from libs.login import login_required +from flask_restful import Resource, reqparse, marshal_with from flask_restful.inputs import int_range from sqlalchemy import or_, func from sqlalchemy.orm import joinedload @@ -15,7 +15,7 @@ from controllers.console.wraps import account_initialization_required from fields.conversation_fields import conversation_pagination_fields, conversation_detail_fields, \ conversation_message_detail_fields, conversation_with_summary_pagination_fields -from libs.helper import TimestampField, datetime_string, uuid_value +from libs.helper import datetime_string from extensions.ext_database import db from models.model import Message, MessageAnnotation, Conversation diff --git a/api/controllers/console/app/generator.py b/api/controllers/console/app/generator.py index 50161cd22d8b55..70275bb70d9028 100644 --- a/api/controllers/console/app/generator.py +++ b/api/controllers/console/app/generator.py @@ -1,5 +1,5 @@ from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, reqparse from controllers.console import api diff --git a/api/controllers/console/app/message.py b/api/controllers/console/app/message.py index d634692ed060d9..1b2765f9bce3ee 100644 --- a/api/controllers/console/app/message.py +++ b/api/controllers/console/app/message.py @@ -16,9 +16,9 @@ from controllers.console.wraps import account_initialization_required from core.model_providers.error import LLMRateLimitError, LLMBadRequestError, LLMAuthorizationError, LLMAPIConnectionError, \ ProviderTokenNotInitError, LLMAPIUnavailableError, QuotaExceededError, ModelCurrentlyNotSupportError -from core.login.login import login_required +from libs.login import login_required from fields.conversation_fields import message_detail_fields -from libs.helper import uuid_value, TimestampField +from libs.helper import uuid_value from libs.infinite_scroll_pagination import InfiniteScrollPagination from extensions.ext_database import db from models.model import MessageAnnotation, Conversation, Message, MessageFeedback diff --git a/api/controllers/console/app/model_config.py b/api/controllers/console/app/model_config.py index 5b35d234d336dc..75ee2aaafe6682 100644 --- a/api/controllers/console/app/model_config.py +++ b/api/controllers/console/app/model_config.py @@ -1,5 +1,4 @@ # -*- coding:utf-8 -*- -import json from flask import request from flask_restful import Resource @@ -9,7 +8,7 @@ from controllers.console.app import _get_app from controllers.console.setup import setup_required from controllers.console.wraps import account_initialization_required -from core.login.login import login_required +from libs.login import login_required from events.app_event import app_model_config_was_updated from extensions.ext_database import db from models.model import AppModelConfig diff --git a/api/controllers/console/app/site.py b/api/controllers/console/app/site.py index a796edf8d7f811..1812d9e1904acd 100644 --- a/api/controllers/console/app/site.py +++ b/api/controllers/console/app/site.py @@ -1,7 +1,7 @@ # -*- coding:utf-8 -*- from flask_login import current_user -from core.login.login import login_required -from flask_restful import Resource, reqparse, fields, marshal_with +from libs.login import login_required +from flask_restful import Resource, reqparse, marshal_with from werkzeug.exceptions import NotFound, Forbidden from controllers.console import api diff --git a/api/controllers/console/app/statistic.py b/api/controllers/console/app/statistic.py index c7fb8fa8eb2ec0..a0c9553977bbde 100644 --- a/api/controllers/console/app/statistic.py +++ b/api/controllers/console/app/statistic.py @@ -5,7 +5,7 @@ import pytz from flask import jsonify from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, reqparse from controllers.console import api diff --git a/api/controllers/console/auth/data_source_oauth.py b/api/controllers/console/auth/data_source_oauth.py index f42b82ab351e33..dec5a464c11280 100644 --- a/api/controllers/console/auth/data_source_oauth.py +++ b/api/controllers/console/auth/data_source_oauth.py @@ -1,16 +1,13 @@ import logging -from datetime import datetime -from typing import Optional -import flask_login import requests -from flask import request, redirect, current_app, session +from flask import request, redirect, current_app from flask_login import current_user from flask_restful import Resource from werkzeug.exceptions import Forbidden -from core.login.login import login_required +from libs.login import login_required from libs.oauth_data_source import NotionOAuth from controllers.console import api from ..setup import setup_required diff --git a/api/controllers/console/datasets/data_source.py b/api/controllers/console/datasets/data_source.py index 532f47af75e66c..1631cff1c666d5 100644 --- a/api/controllers/console/datasets/data_source.py +++ b/api/controllers/console/datasets/data_source.py @@ -2,10 +2,10 @@ import json from cachetools import TTLCache -from flask import request, current_app +from flask import request from flask_login import current_user -from core.login.login import login_required -from flask_restful import Resource, marshal_with, fields, reqparse, marshal +from libs.login import login_required +from flask_restful import Resource, marshal_with, reqparse from werkzeug.exceptions import NotFound from controllers.console import api @@ -15,7 +15,6 @@ from core.indexing_runner import IndexingRunner from extensions.ext_database import db from fields.data_source_fields import integrate_notion_info_list_fields, integrate_list_fields -from libs.helper import TimestampField from models.dataset import Document from models.source import DataSourceBinding from services.dataset_service import DatasetService, DocumentService diff --git a/api/controllers/console/datasets/datasets.py b/api/controllers/console/datasets/datasets.py index 445cf8dd1eca6f..7aa2a7bfc46d93 100644 --- a/api/controllers/console/datasets/datasets.py +++ b/api/controllers/console/datasets/datasets.py @@ -4,8 +4,8 @@ from flask_login import current_user from controllers.console.apikey import api_key_list, api_key_fields -from core.login.login import login_required -from flask_restful import Resource, reqparse, fields, marshal, marshal_with +from libs.login import login_required +from flask_restful import Resource, reqparse, marshal, marshal_with from werkzeug.exceptions import NotFound, Forbidden import services from controllers.console import api diff --git a/api/controllers/console/datasets/datasets_document.py b/api/controllers/console/datasets/datasets_document.py index 5cdc79efd5b927..e85433c83ff591 100644 --- a/api/controllers/console/datasets/datasets_document.py +++ b/api/controllers/console/datasets/datasets_document.py @@ -1,11 +1,10 @@ # -*- coding:utf-8 -*- -import random from datetime import datetime from typing import List from flask import request, current_app from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, fields, marshal, marshal_with, reqparse from sqlalchemy import desc, asc from werkzeug.exceptions import NotFound, Forbidden @@ -25,7 +24,6 @@ from extensions.ext_redis import redis_client from fields.document_fields import document_with_segments_fields, document_fields, \ dataset_and_document_fields, document_status_fields -from libs.helper import TimestampField from extensions.ext_database import db from models.dataset import DatasetProcessRule, Dataset from models.dataset import Document, DocumentSegment diff --git a/api/controllers/console/datasets/datasets_segments.py b/api/controllers/console/datasets/datasets_segments.py index 8c164e2aa7dfdf..a0715233a4ffaf 100644 --- a/api/controllers/console/datasets/datasets_segments.py +++ b/api/controllers/console/datasets/datasets_segments.py @@ -14,13 +14,12 @@ from controllers.console.wraps import account_initialization_required from core.model_providers.error import LLMBadRequestError, ProviderTokenNotInitError from core.model_providers.model_factory import ModelFactory -from core.login.login import login_required +from libs.login import login_required from extensions.ext_database import db from extensions.ext_redis import redis_client from fields.segment_fields import segment_fields from models.dataset import DocumentSegment -from libs.helper import TimestampField from services.dataset_service import DatasetService, DocumentService, SegmentService from tasks.enable_segment_to_index_task import enable_segment_to_index_task from tasks.disable_segment_from_index_task import disable_segment_from_index_task diff --git a/api/controllers/console/datasets/file.py b/api/controllers/console/datasets/file.py index 52331ff391f6df..de2e347b182ae4 100644 --- a/api/controllers/console/datasets/file.py +++ b/api/controllers/console/datasets/file.py @@ -2,8 +2,8 @@ from flask import request, current_app import services -from core.login.login import login_required -from flask_restful import Resource, marshal_with, fields +from libs.login import login_required +from flask_restful import Resource, marshal_with from controllers.console import api from controllers.console.datasets.error import NoFileUploadedError, TooManyFilesError, FileTooLargeError, \ diff --git a/api/controllers/console/datasets/hit_testing.py b/api/controllers/console/datasets/hit_testing.py index a2a703ca5f4b7f..6d3397e16f1b59 100644 --- a/api/controllers/console/datasets/hit_testing.py +++ b/api/controllers/console/datasets/hit_testing.py @@ -1,7 +1,7 @@ import logging from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, reqparse, marshal from werkzeug.exceptions import InternalServerError, NotFound, Forbidden diff --git a/api/controllers/console/explore/installed_app.py b/api/controllers/console/explore/installed_app.py index 0518de12ab17f2..d36d02828ee5f9 100644 --- a/api/controllers/console/explore/installed_app.py +++ b/api/controllers/console/explore/installed_app.py @@ -2,8 +2,8 @@ from datetime import datetime from flask_login import current_user -from core.login.login import login_required -from flask_restful import Resource, reqparse, fields, marshal_with, inputs +from libs.login import login_required +from flask_restful import Resource, reqparse, marshal_with, inputs from sqlalchemy import and_ from werkzeug.exceptions import NotFound, Forbidden, BadRequest @@ -12,7 +12,6 @@ from controllers.console.wraps import account_initialization_required from extensions.ext_database import db from fields.installed_app_fields import installed_app_list_fields -from libs.helper import TimestampField from models.model import App, InstalledApp, RecommendedApp from services.account_service import TenantService diff --git a/api/controllers/console/explore/recommended_app.py b/api/controllers/console/explore/recommended_app.py index 7f34c0e678d2e8..f2d8b89803b6cd 100644 --- a/api/controllers/console/explore/recommended_app.py +++ b/api/controllers/console/explore/recommended_app.py @@ -1,6 +1,6 @@ # -*- coding:utf-8 -*- from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, fields, marshal_with from sqlalchemy import and_ diff --git a/api/controllers/console/explore/wraps.py b/api/controllers/console/explore/wraps.py index 9c88b131e92135..5e65c94d0d00a4 100644 --- a/api/controllers/console/explore/wraps.py +++ b/api/controllers/console/explore/wraps.py @@ -1,5 +1,5 @@ from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource from functools import wraps diff --git a/api/controllers/console/universal_chat/wraps.py b/api/controllers/console/universal_chat/wraps.py index 8ed472d3b6498e..1fd1747848e896 100644 --- a/api/controllers/console/universal_chat/wraps.py +++ b/api/controllers/console/universal_chat/wraps.py @@ -2,7 +2,7 @@ from functools import wraps from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource from controllers.console.setup import setup_required from controllers.console.wraps import account_initialization_required diff --git a/api/controllers/console/workspace/account.py b/api/controllers/console/workspace/account.py index 238ba96cc6daed..8df13d9d02a177 100644 --- a/api/controllers/console/workspace/account.py +++ b/api/controllers/console/workspace/account.py @@ -4,7 +4,7 @@ import pytz from flask import current_app, request from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, reqparse, fields, marshal_with from services.errors.account import CurrentPasswordIncorrectError as ServiceCurrentPasswordIncorrectError diff --git a/api/controllers/console/workspace/members.py b/api/controllers/console/workspace/members.py index ed829a5dce5470..00c3e173af630a 100644 --- a/api/controllers/console/workspace/members.py +++ b/api/controllers/console/workspace/members.py @@ -1,7 +1,7 @@ # -*- coding:utf-8 -*- from flask import current_app from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, reqparse, marshal_with, abort, fields, marshal import services diff --git a/api/controllers/console/workspace/model_providers.py b/api/controllers/console/workspace/model_providers.py index 48c57193b3e363..bdc08ae6dd86af 100644 --- a/api/controllers/console/workspace/model_providers.py +++ b/api/controllers/console/workspace/model_providers.py @@ -1,5 +1,5 @@ from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, reqparse from werkzeug.exceptions import Forbidden diff --git a/api/controllers/console/workspace/models.py b/api/controllers/console/workspace/models.py index 08eb41e8852b4a..7099b8f23dbfc4 100644 --- a/api/controllers/console/workspace/models.py +++ b/api/controllers/console/workspace/models.py @@ -1,5 +1,5 @@ from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, reqparse from controllers.console import api diff --git a/api/controllers/console/workspace/providers.py b/api/controllers/console/workspace/providers.py index df09aad9fd9baa..267fb6975fc260 100644 --- a/api/controllers/console/workspace/providers.py +++ b/api/controllers/console/workspace/providers.py @@ -1,6 +1,6 @@ # -*- coding:utf-8 -*- from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, reqparse from werkzeug.exceptions import Forbidden diff --git a/api/controllers/console/workspace/tool_providers.py b/api/controllers/console/workspace/tool_providers.py index 692e84ac07367c..3cc9c14fb54324 100644 --- a/api/controllers/console/workspace/tool_providers.py +++ b/api/controllers/console/workspace/tool_providers.py @@ -1,7 +1,7 @@ import json from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, abort, reqparse from werkzeug.exceptions import Forbidden diff --git a/api/controllers/console/workspace/workspace.py b/api/controllers/console/workspace/workspace.py index 89bb33c05307ce..76308771194751 100644 --- a/api/controllers/console/workspace/workspace.py +++ b/api/controllers/console/workspace/workspace.py @@ -3,9 +3,8 @@ from flask import request from flask_login import current_user -from core.login.login import login_required +from libs.login import login_required from flask_restful import Resource, fields, marshal_with, reqparse, marshal, inputs -from flask_restful.inputs import int_range from controllers.console import api from controllers.console.admin import admin_required diff --git a/api/controllers/service_api/dataset/dataset.py b/api/controllers/service_api/dataset/dataset.py index 29f9a5613ce1cf..17b659cb1a44d0 100644 --- a/api/controllers/service_api/dataset/dataset.py +++ b/api/controllers/service_api/dataset/dataset.py @@ -4,12 +4,9 @@ from controllers.service_api import api from controllers.service_api.dataset.error import DatasetNameDuplicateError from controllers.service_api.wraps import DatasetApiResource -from core.login.login import current_user +from libs.login import current_user from core.model_providers.models.entity.model_params import ModelType -from extensions.ext_database import db from fields.dataset_fields import dataset_detail_fields -from models.account import Account, TenantAccountJoin -from models.dataset import Dataset from services.dataset_service import DatasetService from services.provider_service import ProviderService diff --git a/api/controllers/service_api/dataset/document.py b/api/controllers/service_api/dataset/document.py index a8e1c4ab732457..de786f8ccf1ec3 100644 --- a/api/controllers/service_api/dataset/document.py +++ b/api/controllers/service_api/dataset/document.py @@ -1,8 +1,6 @@ -import datetime import json -import uuid -from flask import current_app, request +from flask import request from flask_restful import reqparse, marshal from sqlalchemy import desc from werkzeug.exceptions import NotFound @@ -13,13 +11,11 @@ from controllers.service_api.dataset.error import ArchivedDocumentImmutableError, DocumentIndexingError, \ NoFileUploadedError, TooManyFilesError from controllers.service_api.wraps import DatasetApiResource -from core.login.login import current_user +from libs.login import current_user from core.model_providers.error import ProviderTokenNotInitError from extensions.ext_database import db -from extensions.ext_storage import storage from fields.document_fields import document_fields, document_status_fields from models.dataset import Dataset, Document, DocumentSegment -from models.model import UploadFile from services.dataset_service import DocumentService from services.file_service import FileService diff --git a/api/controllers/service_api/wraps.py b/api/controllers/service_api/wraps.py index 44d051707b946e..4a45af35d6ecac 100644 --- a/api/controllers/service_api/wraps.py +++ b/api/controllers/service_api/wraps.py @@ -7,10 +7,9 @@ from flask_restful import Resource from werkzeug.exceptions import NotFound, Unauthorized -from core.login.login import _get_user +from libs.login import _get_user from extensions.ext_database import db from models.account import Tenant, TenantAccountJoin, Account -from models.dataset import Dataset from models.model import ApiToken, App diff --git a/api/core/login/login.py b/api/libs/login.py similarity index 100% rename from api/core/login/login.py rename to api/libs/login.py