Skip to content

Commit

Permalink
use an even higher level fn
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-bernstein committed Nov 26, 2024
1 parent 1bb1cf8 commit b075aee
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/label_studio_sdk/label_interface/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,13 +853,14 @@ def generate_sample_prediction(self) -> Optional[dict]:
'value': {'choices': ['Neutral']}}]}
NOTE: `id` field in result is not required when importing predictions; it will be generated automatically.
NOTE: for each control tag, depends on tag.to_json_schema() being implemented correctly
"""
prediction = PredictionValue(
model_version='sample model version',
result=[
control.label(JSF(control.to_json_schema()).generate())
result=self.create_regions({
control.name: JSF(control.to_json_schema()).generate()
for control in self.controls
]
})
)
prediction_dct = prediction.model_dump()
if self.validate_prediction(prediction_dct):
Expand All @@ -884,13 +885,14 @@ def generate_sample_annotation(self) -> Optional[dict]:
'value': {'choices': ['Negative']}}]}
NOTE: `id` field in result is not required when importing predictions; it will be generated automatically.
NOTE: for each control tag, depends on tag.to_json_schema() being implemented correctly
"""
annotation = AnnotationValue(
completed_by=-1, # annotator's user id
result=[
control.label(JSF(control.to_json_schema()).generate())
result=self.create_regions({
control.name: JSF(control.to_json_schema()).generate()
for control in self.controls
]
})
)
annotation_dct = annotation.model_dump()
if self.validate_annotation(annotation_dct):
Expand Down

0 comments on commit b075aee

Please sign in to comment.