Skip to content

Commit

Permalink
feat(sdk): Add support for record.status on filter
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Jun 28, 2024
1 parent 5060360 commit d22dfd9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions argilla/src/argilla/_models/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
from pydantic import BaseModel, Field


class RecordFilterScopeModel(BaseModel):
entity: Literal["record"] = "record"
property: Literal["status"] = "status"


class ResponseFilterScopeModel(BaseModel):
"""Filter scope for filtering on a response entity."""

Expand All @@ -42,6 +47,7 @@ class MetadataFilterScopeModel(BaseModel):

ScopeModel = Annotated[
Union[
RecordFilterScopeModel,
ResponseFilterScopeModel,
SuggestionFilterScopeModel,
MetadataFilterScopeModel,
Expand Down
4 changes: 3 additions & 1 deletion argilla/src/argilla/records/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
FilterModel,
AndFilterModel,
QueryModel,
RecordFilterScopeModel,
)


Expand Down Expand Up @@ -54,8 +55,9 @@ def model(self) -> FilterModel:
@staticmethod
def _extract_filter_scope(field: str) -> ScopeModel:
field = field.strip()

if field == "status":
return RecordFilterScopeModel(property="status")
elif field == "responses.status":
return ResponseFilterScopeModel(property="status")
elif "metadata" in field:
_, md_property = field.split(".")
Expand Down

0 comments on commit d22dfd9

Please sign in to comment.