nucliadb-models 6.3.0.post3417__py3-none-any.whl → 6.3.0.post3422__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ from pydantic import BaseModel, Discriminator, Tag, model_validator
26
26
  from typing_extensions import Annotated, Self
27
27
 
28
28
  from .common import FieldTypeName, Paragraph
29
+ from .metadata import ResourceProcessingStatus
29
30
  from .utils import DateTime
30
31
 
31
32
  F = TypeVar("F")
@@ -217,6 +218,20 @@ class OriginPath(BaseModel, extra="forbid"):
217
218
  )
218
219
 
219
220
 
221
+ class OriginSource(BaseModel, extra="forbid"):
222
+ """Matches the origin source id"""
223
+
224
+ prop: Literal["origin_source"]
225
+ id: str = pydantic.Field(description=("Source ID"))
226
+
227
+
228
+ class OriginCollaborator(BaseModel, extra="forbid"):
229
+ """Matches the origin collaborators"""
230
+
231
+ prop: Literal["origin_collaborator"]
232
+ collaborator: str = pydantic.Field(description=("Collaborator"))
233
+
234
+
220
235
  class Generated(BaseModel, extra="forbid"):
221
236
  """Matches if the field was generated by the given source"""
222
237
 
@@ -236,6 +251,13 @@ class Kind(BaseModel, extra="forbid"):
236
251
  kind: Paragraph.TypeParagraph = pydantic.Field(description="The kind of paragraph to match")
237
252
 
238
253
 
254
+ class Status(BaseModel, extra="forbid"):
255
+ """Matches resource in a certain processing status"""
256
+
257
+ prop: Literal["status"]
258
+ status: ResourceProcessingStatus = pydantic.Field(description="The status of the resource")
259
+
260
+
239
261
  # The discriminator function is optional, everything works without it.
240
262
  # We implement it because it makes pydantic produce more user-friendly errors
241
263
  def filter_discriminator(v: Any) -> Optional[str]:
@@ -269,14 +291,16 @@ FieldFilterExpression = Annotated[
269
291
  Annotated[Keyword, Tag("keyword")],
270
292
  Annotated[DateCreated, Tag("created")],
271
293
  Annotated[DateModified, Tag("modified")],
272
- Annotated[OriginTag, Tag("origin_tag")],
273
294
  Annotated[Label, Tag("label")],
274
295
  Annotated[ResourceMimetype, Tag("resource_mimetype")],
275
296
  Annotated[FieldMimetype, Tag("field_mimetype")],
276
297
  Annotated[Entity, Tag("entity")],
277
298
  Annotated[Language, Tag("language")],
299
+ Annotated[OriginTag, Tag("origin_tag")],
278
300
  Annotated[OriginMetadata, Tag("origin_metadata")],
279
301
  Annotated[OriginPath, Tag("origin_path")],
302
+ Annotated[OriginSource, Tag("origin_source")],
303
+ Annotated[OriginCollaborator, Tag("origin_collaborator")],
280
304
  Annotated[Generated, Tag("generated")],
281
305
  ],
282
306
  Discriminator(filter_discriminator),
@@ -293,10 +317,31 @@ ParagraphFilterExpression = Annotated[
293
317
  Discriminator(filter_discriminator),
294
318
  ]
295
319
 
320
+ ResourceFilterExpression = Annotated[
321
+ Union[
322
+ Annotated[And["ResourceFilterExpression"], Tag("and")],
323
+ Annotated[Or["ResourceFilterExpression"], Tag("or")],
324
+ Annotated[Not["ResourceFilterExpression"], Tag("not")],
325
+ Annotated[Resource, Tag("resource")],
326
+ Annotated[DateCreated, Tag("created")],
327
+ Annotated[DateModified, Tag("modified")],
328
+ Annotated[Label, Tag("label")],
329
+ Annotated[ResourceMimetype, Tag("resource_mimetype")],
330
+ Annotated[Language, Tag("language")],
331
+ Annotated[OriginTag, Tag("origin_tag")],
332
+ Annotated[OriginMetadata, Tag("origin_metadata")],
333
+ Annotated[OriginPath, Tag("origin_path")],
334
+ Annotated[OriginSource, Tag("origin_source")],
335
+ Annotated[OriginCollaborator, Tag("origin_collaborator")],
336
+ Annotated[Status, Tag("status")],
337
+ ],
338
+ Discriminator(filter_discriminator),
339
+ ]
340
+
296
341
 
297
342
  class FilterExpression(BaseModel, extra="forbid"):
298
343
  """Returns only documents that match this filter expression.
299
- Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search/#filters
344
+ Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search_filters
300
345
 
301
346
  This allows building complex filtering expressions and replaces the following parameters:
302
347
  `fields`, `filters`, `range_*`, `resource_filters`, `keyword_filters`.
@@ -321,3 +366,14 @@ class FilterExpression(BaseModel, extra="forbid"):
321
366
  "OR returns text_blocks that match one of the two filters"
322
367
  ),
323
368
  )
369
+
370
+
371
+ class CatalogFilterExpression(BaseModel, extra="forbid"):
372
+ """Returns only documents that match this filter expression.
373
+ Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search_filters
374
+
375
+ This allows building complex filtering expressions and replaces the following parameters:
376
+ `filters`, `range_*`, `with_status`.
377
+ """
378
+
379
+ resource: ResourceFilterExpression = pydantic.Field(description="Filter to apply to resources")
nucliadb_models/search.py CHANGED
@@ -45,7 +45,7 @@ from nucliadb_models.internal.shards import ( # noqa isort: skip
45
45
  ShardReplica,
46
46
  KnowledgeboxShards,
47
47
  )
48
- from nucliadb_models.filter import FilterExpression
48
+ from nucliadb_models.filters import CatalogFilterExpression, FilterExpression
49
49
 
50
50
  ANSWER_JSON_SCHEMA_EXAMPLE = {
51
51
  "name": "structred_response",
@@ -649,11 +649,21 @@ class SearchParamDefaults:
649
649
  title="Filter resource by an expression",
650
650
  description=(
651
651
  "Returns only documents that match this filter expression."
652
- "Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search/#filters"
652
+ "Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search_filters"
653
653
  "This allows building complex filtering expressions and replaces the following parameters:"
654
654
  "`fields`, `filters`, `range_*`, `resource_filters`, `keyword_filters`."
655
655
  ),
656
656
  )
657
+ catalog_filter_expression = ParamDefault(
658
+ default=None,
659
+ title="Filter resource by an expression",
660
+ description=(
661
+ "Returns only documents that match this filter expression."
662
+ "Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search_filters"
663
+ "This allows building complex filtering expressions and replaces the following parameters:"
664
+ "`filters`, `range_*`, `with_status`."
665
+ ),
666
+ )
657
667
 
658
668
 
659
669
  class Filter(BaseModel):
@@ -671,6 +681,9 @@ class Filter(BaseModel):
671
681
 
672
682
  class CatalogRequest(BaseModel):
673
683
  query: str = SearchParamDefaults.query.to_pydantic_field()
684
+ filter_expression: SkipJsonSchema[Optional[CatalogFilterExpression]] = (
685
+ SearchParamDefaults.catalog_filter_expression.to_pydantic_field()
686
+ )
674
687
  filters: Union[list[str], list[Filter]] = Field(
675
688
  default=[],
676
689
  title="Filters",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nucliadb_models
3
- Version: 6.3.0.post3417
3
+ Version: 6.3.0.post3422
4
4
  Author-email: Nuclia <nucliadb@nuclia.com>
5
5
  License: AGPL
6
6
  Project-URL: Homepage, https://nuclia.com
@@ -8,7 +8,7 @@ nucliadb_models/export_import.py,sha256=A1KTjwQCRtyVAWcgabXsdltI78rauXBmZX1ie6Rx
8
8
  nucliadb_models/external_index_providers.py,sha256=aVyj-P4kVqfqPjF13E_lUM0FZsq8-DTbIsh-kHOgt2s,1787
9
9
  nucliadb_models/extracted.py,sha256=wnTjMsSPk1iZFtn4eFrBC9fSOZkNTeHQ_B9CRyaL0cA,6444
10
10
  nucliadb_models/file.py,sha256=4pDfQtXaBNB-ExeXC7NIdt33RbJp_u53_x8ACVkHXCM,2174
11
- nucliadb_models/filter.py,sha256=3CxqwhhVBy8a-aFhwxv0DLu1h3--mSz0wgiNCK9YvBU,10984
11
+ nucliadb_models/filters.py,sha256=_umUEUs4QZEaqPaD3-cmxxKPEKVCONJLyFxTF1XDhag,13142
12
12
  nucliadb_models/labels.py,sha256=OUlX-apmFkibEN9bWThRJlbCD84hzJdddN1YYUV2Y3w,4201
13
13
  nucliadb_models/link.py,sha256=NRfsjLQpjZXndkb5o8qnSVPqb2knqk2kk5_iQB4AkaY,2785
14
14
  nucliadb_models/metadata.py,sha256=fiIJfht0Eg5a65ud2FdmHzElZ8VGdrDQ-F65-VJI4IE,8151
@@ -16,7 +16,7 @@ nucliadb_models/notifications.py,sha256=jr2J3zncs880jYf2oZHYt0VFcnlZevsbkyX69ovT
16
16
  nucliadb_models/processing.py,sha256=UeU-VxbBlOzkNxviOS3a0X_k7Ye-jYu3UOdGuu21M8M,971
17
17
  nucliadb_models/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  nucliadb_models/resource.py,sha256=cjYloaRuCJFc3lGIxLZcX959oOq_N1f3V9bpPMYv4WA,9255
19
- nucliadb_models/search.py,sha256=ErfXrZsQe4b2iKrOE5dEzspj_1omHSeL2EpeiAEZEJc,80994
19
+ nucliadb_models/search.py,sha256=nKd1v6enzkLBykUBxDGyChUiEIElmKOQoayFY2UYOxw,81669
20
20
  nucliadb_models/security.py,sha256=RewdzQ55nPZ9V7B0NX9KHeWg6B4Hg_RkeiFv2TQyrjs,1402
21
21
  nucliadb_models/synonyms.py,sha256=qXTPHfspMgw22hCjAOdFOIoUsRZ7Ju3JW-Lw9Nz4VaI,942
22
22
  nucliadb_models/text.py,sha256=RHN55PzQjyC0ghbf0r5GvVjTbFUTWzEDSCCkHkgnfig,3491
@@ -29,7 +29,7 @@ nucliadb_models/agents/ingestion.py,sha256=mV7gV6VpYg4VNpc59K3275TMUJZbUzeUnp3SZ
29
29
  nucliadb_models/internal/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
30
30
  nucliadb_models/internal/predict.py,sha256=5rgUPrH_98gerySOZ-TR2PX_qzCGF1_8VxyOu3bGhis,2281
31
31
  nucliadb_models/internal/shards.py,sha256=uZLsMkYWrJDHq3xy_w7snSeV2X3aDBuht9GC_MG3sKc,1976
32
- nucliadb_models-6.3.0.post3417.dist-info/METADATA,sha256=xsi__yvn3ul5Q10vUvnm0pQY9rDPDm_6Otdxqnpkcs4,759
33
- nucliadb_models-6.3.0.post3417.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
34
- nucliadb_models-6.3.0.post3417.dist-info/top_level.txt,sha256=UrY1I8oeovIRwkXLYplssTrxQdUjhSEFDFbnwaIV3tA,16
35
- nucliadb_models-6.3.0.post3417.dist-info/RECORD,,
32
+ nucliadb_models-6.3.0.post3422.dist-info/METADATA,sha256=PEy_ophFL81ZeCKR6KZtGIHgu9Q6fYH2ANQ6EDQ3EJw,759
33
+ nucliadb_models-6.3.0.post3422.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
34
+ nucliadb_models-6.3.0.post3422.dist-info/top_level.txt,sha256=UrY1I8oeovIRwkXLYplssTrxQdUjhSEFDFbnwaIV3tA,16
35
+ nucliadb_models-6.3.0.post3422.dist-info/RECORD,,