-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UN-1920 Fix:Dynamic passing of File storage init
- Loading branch information
1 parent
3c491e5
commit 3386976
Showing
9 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
prompt-service/src/unstract/prompt_service/prompt_service_file_helper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Union | ||
|
||
from unstract.prompt_service.constants import FileStorageKeys, FileStorageType | ||
from unstract.prompt_service.env_manager import EnvLoader | ||
from unstract.sdk.file_storage import ( | ||
FileStorageProvider, | ||
PermanentFileStorage, | ||
SharedTemporaryFileStorage, | ||
) | ||
|
||
|
||
class PromptServiceFileHelper: | ||
@staticmethod | ||
def initialize_file_storage( | ||
type: FileStorageType, | ||
) -> Union[PermanentFileStorage, SharedTemporaryFileStorage]: | ||
provider_data = EnvLoader.load_provider_credentials() | ||
provider = provider_data[FileStorageKeys.FILE_STORAGE_PROVIDER] | ||
provider_value = FileStorageProvider(provider) | ||
credentials = provider_data[FileStorageKeys.FILE_STORAGE_CREDENTIALS] | ||
if type.value == FileStorageType.PERMANENT.value: | ||
file_storage = PermanentFileStorage(provider=provider_value, **credentials) | ||
elif type.value == FileStorageType.TEMPORARY.value: | ||
file_storage = SharedTemporaryFileStorage( | ||
provider=provider_value, **credentials | ||
) | ||
else: | ||
file_storage = PermanentFileStorage( | ||
provider=FileStorageProvider.LOCAL, **credentials | ||
) | ||
return file_storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters