From 7b347d89c09d339eb3dbe58f9be6acab0acbd78d Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 26 Jan 2024 19:02:22 -0300 Subject: [PATCH] Add storage service to dependencies --- src/backend/langflow/services/deps.py | 8 +++++++- src/backend/langflow/services/schema.py | 1 + src/backend/langflow/services/utils.py | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/backend/langflow/services/deps.py b/src/backend/langflow/services/deps.py index 28e7d2977..dea2ee461 100644 --- a/src/backend/langflow/services/deps.py +++ b/src/backend/langflow/services/deps.py @@ -3,6 +3,8 @@ from typing import TYPE_CHECKING, Generator from langflow.services import ServiceType, service_manager if TYPE_CHECKING: + from sqlmodel import Session + from langflow.services.cache.service import BaseCacheService from langflow.services.chat.service import ChatService from langflow.services.credentials.service import CredentialService @@ -11,9 +13,13 @@ if TYPE_CHECKING: from langflow.services.plugins.service import PluginService from langflow.services.session.service import SessionService from langflow.services.settings.service import SettingsService + from langflow.services.storage.service import StorageService from langflow.services.store.service import StoreService from langflow.services.task.service import TaskService - from sqlmodel import Session + + +def get_storage_service() -> "StorageService": + return service_manager.get(ServiceType.STORAGE_SERVICE) # type: ignore def get_credential_service() -> "CredentialService": diff --git a/src/backend/langflow/services/schema.py b/src/backend/langflow/services/schema.py index 8265c1108..bd2971255 100644 --- a/src/backend/langflow/services/schema.py +++ b/src/backend/langflow/services/schema.py @@ -17,3 +17,4 @@ class ServiceType(str, Enum): PLUGIN_SERVICE = "plugin_service" STORE_SERVICE = "store_service" CREDENTIAL_SERVICE = "credential_service" + STORAGE_SERVICE = "storage_service" diff --git a/src/backend/langflow/services/utils.py b/src/backend/langflow/services/utils.py index 850c1c683..37d5ba424 100644 --- a/src/backend/langflow/services/utils.py +++ b/src/backend/langflow/services/utils.py @@ -1,10 +1,11 @@ +from loguru import logger +from sqlmodel import Session, select + from langflow.services.auth.utils import create_super_user, verify_password from langflow.services.database.utils import initialize_database from langflow.services.manager import service_manager from langflow.services.schema import ServiceType from langflow.services.settings.constants import DEFAULT_SUPERUSER, DEFAULT_SUPERUSER_PASSWORD -from loguru import logger -from sqlmodel import Session, select from .deps import get_db_service, get_session, get_settings_service @@ -18,6 +19,7 @@ def get_factories_and_deps(): from langflow.services.plugins import factory as plugins_factory from langflow.services.session import factory as session_service_factory # type: ignore from langflow.services.settings import factory as settings_factory + from langflow.services.storage import factory as storage_factory from langflow.services.store import factory as store_factory from langflow.services.task import factory as task_factory @@ -44,6 +46,7 @@ def get_factories_and_deps(): (plugins_factory.PluginServiceFactory(), [ServiceType.SETTINGS_SERVICE]), (store_factory.StoreServiceFactory(), [ServiceType.SETTINGS_SERVICE]), (credentials_factory.CredentialServiceFactory(), [ServiceType.SETTINGS_SERVICE]), + (storage_factory.StorageServiceFactory(), [ServiceType.SESSION_SERVICE, ServiceType.SETTINGS_SERVICE]), ]