Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Text(ConfidenceMixin, CustomMetricsMixin, BaseModel):
"""

answer: str
classifications: Optional[List["ClassificationAnnotation"]] = None


class ClassificationAnnotation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ def to_common(self) -> Text:
answer=self.answer,
confidence=self.confidence,
custom_metrics=self.custom_metrics,
classifications=[
NDSubclassification.to_common(annot)
for annot in self.classifications
]
if self.classifications
else None,
)

@classmethod
Expand All @@ -98,6 +104,12 @@ def from_common(
schema_id=feature_schema_id,
confidence=text.confidence,
custom_metrics=text.custom_metrics,
classifications=[
NDSubclassification.from_common(annot)
for annot in text.classifications
]
if text.classifications
else None,
)


Expand Down Expand Up @@ -245,6 +257,12 @@ def from_common(
message_id=message_id,
confidence=text.confidence,
custom_metrics=text.custom_metrics,
classifications=[
NDSubclassification.from_common(annot)
for annot in text.classifications
]
if text.classifications
else None,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing serializer to remove empty classifications in NDText

Low Severity

NDText is missing the serialize_model method that NDChecklist and NDRadio have to remove empty classifications from serialized output. When NDText has classifications=[] (e.g., from deserializing ndjson with an empty list), it will serialize with "classifications": [], while NDChecklist and NDRadio would omit the key entirely. This creates inconsistent serialization behavior across classification types.

Additional Locations (2)

Fix in Cursor Fix in Web

)


Expand Down
Loading