Skip to content

Commit

Permalink
Storage type default (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
luciferlinx101 authored Jul 13, 2023
1 parent f0db87e commit fc19d9a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superagi/controllers/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions superagi/helper/resource_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions superagi/types/storage_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit fc19d9a

Please sign in to comment.