@@ -532,14 +532,22 @@ def get_tool_execution_result_from_metadata(
532
532
return result
533
533
534
534
def has_valid_metadata (self , metadata : Any ) -> bool :
535
- # Check if metadata is not None and metadata is a non-empty string
536
- if not metadata :
535
+ # Check if metadata is not None and is either a non-empty dict or valid string
536
+ if metadata is None :
537
537
return False
538
- if not isinstance (metadata , str ):
539
- return False
540
- if metadata .strip ().lower () == "none" :
541
- return False
542
- return True
538
+
539
+ # Handle dict metadata (which is valid and contains extracted_text)
540
+ if isinstance (metadata , dict ):
541
+ return bool (metadata ) # Return True if dict is not empty
542
+
543
+ # Handle string metadata
544
+ if isinstance (metadata , str ):
545
+ if metadata .strip ().lower () == "none" or not metadata .strip ():
546
+ return False
547
+ return True
548
+
549
+ # For other types, consider them valid if they're truthy
550
+ return bool (metadata )
543
551
544
552
def get_metadata (
545
553
self , file_history : FileHistory | None = None
@@ -555,7 +563,6 @@ def get_metadata(
555
563
else :
556
564
return None
557
565
metadata : dict [str , Any ] = self .get_workflow_metadata ()
558
-
559
566
return metadata
560
567
561
568
def delete_file_execution_directory (self ) -> None :
@@ -777,6 +784,9 @@ def _push_to_queue(
777
784
q_name = self ._get_review_queue_name ()
778
785
whisper_hash = meta_data .get ("whisper-hash" ) if meta_data else None
779
786
787
+ # Get extracted text from metadata (added by structure tool)
788
+ extracted_text = meta_data .get ("extracted_text" ) if meta_data else None
789
+
780
790
queue_result = QueueResult (
781
791
file = file_name ,
782
792
status = QueueResultStatus .SUCCESS ,
@@ -785,6 +795,7 @@ def _push_to_queue(
785
795
file_content = file_content_base64 ,
786
796
whisper_hash = whisper_hash ,
787
797
file_execution_id = file_execution_id ,
798
+ extracted_text = extracted_text ,
788
799
).to_dict ()
789
800
790
801
queue_result_json = json .dumps (queue_result )
@@ -811,6 +822,9 @@ def _push_to_queue(
811
822
else :
812
823
whisper_hash = None
813
824
825
+ # Get extracted text from metadata (added by structure tool)
826
+ extracted_text = meta_data .get ("extracted_text" ) if meta_data else None
827
+
814
828
# Create QueueResult with TTL metadata
815
829
queue_result_obj = QueueResult (
816
830
file = file_name ,
@@ -820,6 +834,7 @@ def _push_to_queue(
820
834
file_content = file_content_base64 ,
821
835
whisper_hash = whisper_hash ,
822
836
file_execution_id = file_execution_id ,
837
+ extracted_text = extracted_text ,
823
838
)
824
839
825
840
# Add TTL metadata based on HITLSettings
0 commit comments