Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[FIX] Fixing regression for remote storage file view (#1063)

harini-venkataraman078bff4d6f4e
diff --git a/backend/utils/file_storage/helpers/prompt_studio_file_helper.py b/backend/utils/file_storage/helpers/prompt_studio_file_helper.py
index 8b6811069..5bd01c73d 100644
--- a/backend/utils/file_storage/helpers/prompt_studio_file_helper.py
+++ b/backend/utils/file_storage/helpers/prompt_studio_file_helper.py
@@ -2,7 +2,7 @@ import base64
import logging
import os
from pathlib import Path
-from typing import Any, Union
+from typing import Any
from file_management.file_management_helper import FileManagerHelper
from unstract.sdk.file_storage import FileStorage
@@ -77,7 +77,7 @@ class PromptStudioFileHelper:
@staticmethod
def fetch_file_contents(
org_id: str, user_id: str, tool_id: str, file_name: str
- ) -> Union[bytes, str]:
+ ) -> dict[str, Any]:
"""Method to fetch file contents from the remote location.
The path is constructed in runtime based on the args"""
fs_instance = EnvHelper.get_storage(
@@ -125,7 +125,7 @@ class PromptStudioFileHelper:
encoding="utf-8",
)
encoded_string = base64.b64encode(bytes(text_content_bytes))
- return encoded_string
+ return {"data": encoded_string, "mime_type": file_content_type}
elif file_content_type == "text/plain":
text_content_string: str = fs_instance.read(
@@ -134,7 +134,7 @@ class PromptStudioFileHelper:
legacy_storage_path=legacy_file_path,
encoding="utf-8",
)
- return text_content_string
+ return {"data": text_content_string, "mime_type": file_content_type}
else:
raise ValueError(f"Unsupported file type: {file_content_type}")