Skip to content

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

[Fix] Extracted file content not found (#1062)

jagadeeswaran-zipstack06fb3b7defb7
diff --git a/backend/file_management/file_management_helper.py b/backend/file_management/file_management_helper.py
index 4bbc6ccf8..c30138f35 100644
--- a/backend/file_management/file_management_helper.py
+++ b/backend/file_management/file_management_helper.py
@@ -177,9 +177,6 @@ class FileManagerHelper:
raise ConnectorApiRequestError
data = ""
- # Check if the file type is in the allowed list
- if file_content_type not in allowed_content_types:
- raise InvalidFileType(f"File type '{file_content_type}' is not allowed.")
# Handle allowed file types
if file_content_type == "application/pdf":
@@ -191,6 +188,10 @@ class FileManagerHelper:
logger.info(f"Reading text file: {file_path}")
data = file.read()
+ # Check if the file type is in the allowed list
+ elif file_content_type not in allowed_content_types:
+ raise InvalidFileType(f"File type '{file_content_type}' is not allowed.")
+
else:
logger.warning(f"File type '{file_content_type}' is not handled.")
diff --git a/backend/prompt_studio/prompt_studio_core_v2/views.py b/backend/prompt_studio/prompt_studio_core_v2/views.py
index 87c1b034a..4eaa67bdb 100644
--- a/backend/prompt_studio/prompt_studio_core_v2/views.py
+++ b/backend/prompt_studio/prompt_studio_core_v2/views.py
@@ -453,7 +453,9 @@ class PromptStudioCoreView(viewsets.ModelViewSet):
if not file_path.endswith("/"):
file_path += "/"
file_path += file_name
- contents = FileManagerHelper.fetch_file_contents(file_system, file_path)
+ contents = FileManagerHelper.fetch_file_contents(
+ file_system, file_path, allowed_content_types
+ )
else:
try:
contents = PromptStudioFileHelper.fetch_file_contents(
diff --git a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx
index 2cafd2dca..7ae0663a9 100644
--- a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx
+++ b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx
@@ -259,7 +259,7 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {
throw new Error("Fail to load the file");
};
} else if (viewType === viewTypes.extract) {
- setExtractTxt(data);
+ setExtractTxt(data?.data);
}
};