diff --git a/superagi/controllers/resources.py b/superagi/controllers/resources.py index 3fc1ed5ff..ab83275e0 100644 --- a/superagi/controllers/resources.py +++ b/superagi/controllers/resources.py @@ -61,7 +61,7 @@ async def upload(agent_id: int, file: UploadFile = File(...), name=Form(...), si if not name.endswith(accepted_file_types): raise HTTPException(status_code=400, detail="File type not supported!") - storage_type = StorageType.get_storage_type(get_config("STORAGE_TYPE")) + storage_type = StorageType.get_storage_type(get_config("STORAGE_TYPE", StorageType.FILE.value)) save_directory = ResourceHelper.get_root_input_dir() if "{agent_id}" in save_directory: save_directory = ResourceHelper.get_formatted_agent_level_path(agent=Agent diff --git a/superagi/helper/resource_helper.py b/superagi/helper/resource_helper.py index 882ac97e2..28596be57 100644 --- a/superagi/helper/resource_helper.py +++ b/superagi/helper/resource_helper.py @@ -22,7 +22,7 @@ def make_written_file_resource(cls, file_name: str, agent: Agent, agent_executio Returns: Resource: The Resource object. """ - storage_type = StorageType.get_storage_type(get_config("STORAGE_TYPE")) + storage_type = StorageType.get_storage_type(get_config("STORAGE_TYPE", StorageType.FILE.value)) file_extension = os.path.splitext(file_name)[1][1:] if file_extension in ["png", "jpg", "jpeg"]: @@ -41,7 +41,7 @@ def make_written_file_resource(cls, file_name: str, agent: Agent, agent_executio file_path = ResourceHelper.get_agent_write_resource_path(file_name, agent, agent_execution) logger.info(final_path) - if StorageType.get_storage_type(get_config("STORAGE_TYPE")) == StorageType.S3: + if StorageType.get_storage_type(get_config("STORAGE_TYPE", StorageType.FILE.value)) == StorageType.S3: file_path = "resources" + file_path resource = Resource(name=file_name, path=file_path, storage_type=storage_type.value, size=file_size, diff --git a/superagi/types/storage_types.py b/superagi/types/storage_types.py index 9d41c7fef..c10729540 100644 --- a/superagi/types/storage_types.py +++ b/superagi/types/storage_types.py @@ -7,6 +7,8 @@ class StorageType(Enum): @classmethod def get_storage_type(cls, store): + if store is None: + raise ValueError("Storage type cannot be None.") store = store.upper() if store in cls.__members__: return cls[store]