11from ast import Bytes
22from io import BytesIO
3- from typing import Any , Dict , List , Tuple , Union , Optional
3+ from typing import Any , Dict , List , Tuple , Type , Union , Optional
44import base64
5+ from labelbox .data .annotation_types .ner .conversation_entity import ConversationEntity
56from labelbox .data .mixins import ConfidenceMixin
67import numpy as np
78
@@ -399,6 +400,33 @@ def from_common(cls,
399400 confidence = confidence )
400401
401402
403+ class NDConversationEntity (NDTextEntity ):
404+ message_id : str
405+
406+ def to_common (self ) -> ConversationEntity :
407+ return ConversationEntity (start = self .location .start , end = self .location .end , message_id = self .message_id )
408+
409+ @classmethod
410+ def from_common (cls ,
411+ conversation_entity : ConversationEntity ,
412+ classifications : List [ClassificationAnnotation ],
413+ name : str ,
414+ feature_schema_id : Cuid ,
415+ extra : Dict [str , Any ],
416+ data : Union [ImageData , TextData ],
417+ confidence : Optional [float ] = None ) -> "NDConversationEntity" :
418+ return cls (location = Location (
419+ start = conversation_entity .start ,
420+ end = conversation_entity .end ),
421+ message_id = conversation_entity .message_id ,
422+ dataRow = DataRow (id = data .uid ),
423+ name = name ,
424+ schema_id = feature_schema_id ,
425+ uuid = extra .get ('uuid' ),
426+ classifications = classifications ,
427+ confidence = confidence )
428+
429+
402430class NDObject :
403431
404432 @staticmethod
@@ -463,6 +491,7 @@ def lookup_object(
463491 Mask : NDMask ,
464492 TextEntity : NDTextEntity ,
465493 DocumentEntity : NDDocumentEntity ,
494+ ConversationEntity : NDConversationEntity ,
466495 }.get (type (annotation .value ))
467496 if result is None :
468497 raise TypeError (
@@ -472,6 +501,6 @@ def lookup_object(
472501
473502
474503NDObjectType = Union [NDLine , NDPolygon , NDPoint , NDRectangle , NDMask ,
475- NDTextEntity , NDDocumentEntity ]
504+ Type [ NDTextEntity ] , NDDocumentEntity ]
476505
477506NDFrameObjectType = NDFrameRectangle , NDFramePoint , NDFrameLine
0 commit comments