From c34eb8ee1575b5ad9e148e49965ce0c003272cca Mon Sep 17 00:00:00 2001 From: Mohamed Akram <69890013+mohamed99akram@users.noreply.github.com> Date: Fri, 14 Jun 2024 04:39:46 +0300 Subject: [PATCH] Unstructured Upsert bug (#2628) * Unstructured Upsert bug When upserting with the API, the uploaded files are of type pdfFile, txtFile, etc. but the code reads only fileObject which is the uploaded file using the button * Update UnstructuredFile.ts fixed linting error --------- Co-authored-by: Mohamed Akram --- .../documentloaders/Unstructured/UnstructuredFile.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/components/nodes/documentloaders/Unstructured/UnstructuredFile.ts b/packages/components/nodes/documentloaders/Unstructured/UnstructuredFile.ts index f1cf6c457..7e8964b16 100644 --- a/packages/components/nodes/documentloaders/Unstructured/UnstructuredFile.ts +++ b/packages/components/nodes/documentloaders/Unstructured/UnstructuredFile.ts @@ -448,7 +448,16 @@ class UnstructuredFile_DocumentLoaders implements INode { if (_omitMetadataKeys) { omitMetadataKeys = _omitMetadataKeys.split(',').map((key) => key.trim()) } - const fileBase64 = nodeData.inputs?.fileObject as string + // give priority to upload with upsert then to fileObject (upload from UI component) + const fileBase64 = + nodeData.inputs?.pdfFile || + nodeData.inputs?.txtFile || + nodeData.inputs?.yamlFile || + nodeData.inputs?.docxFile || + nodeData.inputs?.jsonlinesFile || + nodeData.inputs?.csvFile || + nodeData.inputs?.jsonFile || + (nodeData.inputs?.fileObject as string) const obj: UnstructuredLoaderOptions = { apiUrl: unstructuredAPIUrl,