nucliadb-models 6.6.1.post4586__py3-none-any.whl → 6.6.1.post4595__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.
@@ -37,8 +37,8 @@ class And(BaseModel, Generic[F], extra="forbid"):
37
37
  )
38
38
 
39
39
  @pydantic.model_serializer
40
- def serialize_boolean(self) -> dict[str, Any]:
41
- return {"and": [op.model_dump() for op in self.operands]}
40
+ def serialize_boolean(self, info: pydantic.SerializationInfo) -> dict[str, Any]:
41
+ return {"and": [op.model_dump(exclude_unset=info.exclude_unset) for op in self.operands]}
42
42
 
43
43
 
44
44
  class Or(BaseModel, Generic[F], extra="forbid"):
@@ -49,8 +49,8 @@ class Or(BaseModel, Generic[F], extra="forbid"):
49
49
  )
50
50
 
51
51
  @pydantic.model_serializer
52
- def serialize_boolean(self) -> dict[str, Any]:
53
- return {"or": [op.model_dump() for op in self.operands]}
52
+ def serialize_boolean(self, info: pydantic.SerializationInfo) -> dict[str, Any]:
53
+ return {"or": [op.model_dump(exclude_unset=info.exclude_unset) for op in self.operands]}
54
54
 
55
55
 
56
56
  class Not(BaseModel, Generic[F], extra="forbid"):
@@ -61,11 +61,21 @@ class Not(BaseModel, Generic[F], extra="forbid"):
61
61
  )
62
62
 
63
63
  @pydantic.model_serializer
64
- def serialize_boolean(self) -> dict[str, Any]:
65
- return {"not": self.operand.model_dump()}
64
+ def serialize_boolean(self, info: pydantic.SerializationInfo) -> dict[str, Any]:
65
+ return {"not": self.operand.model_dump(exclude_unset=info.exclude_unset)}
66
66
 
67
67
 
68
- class Resource(BaseModel, extra="forbid"):
68
+ class FilterProp(BaseModel):
69
+ prop: str
70
+
71
+ @model_validator(mode="after")
72
+ def set_discriminator(self) -> Self:
73
+ # Ensure discriminator is explicitly set so it's always serialized
74
+ self.prop = self.prop
75
+ return self
76
+
77
+
78
+ class Resource(FilterProp, extra="forbid"):
69
79
  """Matches all fields of a resource given its id or slug"""
70
80
 
71
81
  prop: Literal["resource"] = "resource"
@@ -92,7 +102,7 @@ class Resource(BaseModel, extra="forbid"):
92
102
  return self
93
103
 
94
104
 
95
- class Field(BaseModel, extra="forbid"):
105
+ class Field(FilterProp, extra="forbid"):
96
106
  """Matches a field or set of fields"""
97
107
 
98
108
  prop: Literal["field"] = "field"
@@ -103,14 +113,14 @@ class Field(BaseModel, extra="forbid"):
103
113
  )
104
114
 
105
115
 
106
- class Keyword(BaseModel, extra="forbid"):
116
+ class Keyword(FilterProp, extra="forbid"):
107
117
  """Matches all fields that contain a keyword"""
108
118
 
109
119
  prop: Literal["keyword"] = "keyword"
110
120
  word: str = pydantic.Field(description="Keyword to find")
111
121
 
112
122
 
113
- class DateCreated(BaseModel, extra="forbid"):
123
+ class DateCreated(FilterProp, extra="forbid"):
114
124
  """Matches all fields created in a date range"""
115
125
 
116
126
  prop: Literal["created"] = "created"
@@ -128,7 +138,7 @@ class DateCreated(BaseModel, extra="forbid"):
128
138
  return self
129
139
 
130
140
 
131
- class DateModified(BaseModel, extra="forbid"):
141
+ class DateModified(FilterProp, extra="forbid"):
132
142
  """Matches all fields modified in a date range"""
133
143
 
134
144
  prop: Literal["modified"] = "modified"
@@ -146,7 +156,7 @@ class DateModified(BaseModel, extra="forbid"):
146
156
  return self
147
157
 
148
158
 
149
- class Label(BaseModel, extra="forbid"):
159
+ class Label(FilterProp, extra="forbid"):
150
160
  """Matches fields/paragraphs with a label (or labelset)"""
151
161
 
152
162
  prop: Literal["label"] = "label"
@@ -157,7 +167,7 @@ class Label(BaseModel, extra="forbid"):
157
167
  )
158
168
 
159
169
 
160
- class ResourceMimetype(BaseModel, extra="forbid"):
170
+ class ResourceMimetype(FilterProp, extra="forbid"):
161
171
  """Matches resources with a mimetype.
162
172
 
163
173
  The mimetype of a resource can be assigned independently of the mimetype of its fields.
@@ -176,7 +186,7 @@ class ResourceMimetype(BaseModel, extra="forbid"):
176
186
  )
177
187
 
178
188
 
179
- class FieldMimetype(BaseModel, extra="forbid"):
189
+ class FieldMimetype(FilterProp, extra="forbid"):
180
190
  """Matches fields with a mimetype"""
181
191
 
182
192
  prop: Literal["field_mimetype"] = "field_mimetype"
@@ -192,7 +202,7 @@ class FieldMimetype(BaseModel, extra="forbid"):
192
202
  )
193
203
 
194
204
 
195
- class Entity(BaseModel, extra="forbid"):
205
+ class Entity(FilterProp, extra="forbid"):
196
206
  """Matches fields that contains a detected entity"""
197
207
 
198
208
  prop: Literal["entity"] = "entity"
@@ -203,7 +213,7 @@ class Entity(BaseModel, extra="forbid"):
203
213
  )
204
214
 
205
215
 
206
- class Language(BaseModel, extra="forbid"):
216
+ class Language(FilterProp, extra="forbid"):
207
217
  """Matches the language of the field"""
208
218
 
209
219
  prop: Literal["language"] = "language"
@@ -214,14 +224,14 @@ class Language(BaseModel, extra="forbid"):
214
224
  language: str = pydantic.Field(description="The code of the language to match, e.g: en")
215
225
 
216
226
 
217
- class OriginTag(BaseModel, extra="forbid"):
227
+ class OriginTag(FilterProp, extra="forbid"):
218
228
  """Matches all fields with a given origin tag"""
219
229
 
220
230
  prop: Literal["origin_tag"] = "origin_tag"
221
231
  tag: str = pydantic.Field(description="The tag to match")
222
232
 
223
233
 
224
- class OriginMetadata(BaseModel, extra="forbid"):
234
+ class OriginMetadata(FilterProp, extra="forbid"):
225
235
  """Matches metadata from the origin"""
226
236
 
227
237
  prop: Literal["origin_metadata"] = "origin_metadata"
@@ -232,7 +242,7 @@ class OriginMetadata(BaseModel, extra="forbid"):
232
242
  )
233
243
 
234
244
 
235
- class OriginPath(BaseModel, extra="forbid"):
245
+ class OriginPath(FilterProp, extra="forbid"):
236
246
  """Matches the origin path"""
237
247
 
238
248
  prop: Literal["origin_path"] = "origin_path"
@@ -245,21 +255,21 @@ class OriginPath(BaseModel, extra="forbid"):
245
255
  )
246
256
 
247
257
 
248
- class OriginSource(BaseModel, extra="forbid"):
258
+ class OriginSource(FilterProp, extra="forbid"):
249
259
  """Matches the origin source id"""
250
260
 
251
261
  prop: Literal["origin_source"] = "origin_source"
252
262
  id: Optional[str] = pydantic.Field(default=None, description=("Source ID"))
253
263
 
254
264
 
255
- class OriginCollaborator(BaseModel, extra="forbid"):
265
+ class OriginCollaborator(FilterProp, extra="forbid"):
256
266
  """Matches the origin collaborators"""
257
267
 
258
268
  prop: Literal["origin_collaborator"] = "origin_collaborator"
259
269
  collaborator: str = pydantic.Field(description=("Collaborator"))
260
270
 
261
271
 
262
- class Generated(BaseModel, extra="forbid"):
272
+ class Generated(FilterProp, extra="forbid"):
263
273
  """Matches if the field was generated by the given source"""
264
274
 
265
275
  prop: Literal["generated"] = "generated"
@@ -271,14 +281,14 @@ class Generated(BaseModel, extra="forbid"):
271
281
  )
272
282
 
273
283
 
274
- class Kind(BaseModel, extra="forbid"):
284
+ class Kind(FilterProp, extra="forbid"):
275
285
  """Matches paragraphs of a certain kind"""
276
286
 
277
287
  prop: Literal["kind"] = "kind"
278
288
  kind: Paragraph.TypeParagraph = pydantic.Field(description="The kind of paragraph to match")
279
289
 
280
290
 
281
- class Status(BaseModel, extra="forbid"):
291
+ class Status(FilterProp, extra="forbid"):
282
292
  """Matches resource in a certain processing status"""
283
293
 
284
294
  prop: Literal["status"] = "status"
@@ -25,6 +25,16 @@ from nucliadb_models.security import RequestSecurity
25
25
  ## Models for graph nodes and relations
26
26
 
27
27
 
28
+ class GraphProp(BaseModel):
29
+ prop: str
30
+
31
+ @model_validator(mode="after")
32
+ def set_discriminator(self) -> Self:
33
+ # Ensure discriminator is explicitly set so it's always serialized
34
+ self.prop = self.prop
35
+ return self
36
+
37
+
28
38
  class NodeMatchKindName(str, Enum):
29
39
  EXACT = "exact"
30
40
  FUZZY = "fuzzy"
@@ -57,23 +67,23 @@ class GraphRelation(BaseModel, extra="forbid"):
57
67
  ## Models for query expressions
58
68
 
59
69
 
60
- class AnyNode(GraphNode):
70
+ class AnyNode(GraphNode, GraphProp):
61
71
  prop: Literal["node"] = "node"
62
72
 
63
73
 
64
- class SourceNode(GraphNode):
74
+ class SourceNode(GraphNode, GraphProp):
65
75
  prop: Literal["source_node"] = "source_node"
66
76
 
67
77
 
68
- class DestinationNode(GraphNode):
78
+ class DestinationNode(GraphNode, GraphProp):
69
79
  prop: Literal["destination_node"] = "destination_node"
70
80
 
71
81
 
72
- class Relation(GraphRelation):
82
+ class Relation(GraphRelation, GraphProp):
73
83
  prop: Literal["relation"] = "relation"
74
84
 
75
85
 
76
- class GraphPath(BaseModel, extra="forbid"):
86
+ class GraphPath(GraphProp, extra="forbid"):
77
87
  prop: Literal["path"] = "path"
78
88
  source: Optional[GraphNode] = None
79
89
  relation: Optional[GraphRelation] = None
@@ -87,7 +97,7 @@ class Generator(str, Enum):
87
97
  USER = "user"
88
98
 
89
99
 
90
- class Generated(BaseModel, extra="forbid"):
100
+ class Generated(GraphProp, extra="forbid"):
91
101
  """Matches if the relation was generated by the given source"""
92
102
 
93
103
  prop: Literal["generated"] = "generated"
nucliadb_models/search.py CHANGED
@@ -355,6 +355,12 @@ class RankFusionName(str, Enum):
355
355
  class _BaseRankFusion(BaseModel):
356
356
  name: str
357
357
 
358
+ @model_validator(mode="after")
359
+ def set_discriminator(self) -> Self:
360
+ # Ensure discriminator is explicitly set so it's always serialized
361
+ self.name = self.name
362
+ return self
363
+
358
364
 
359
365
  class ReciprocalRankFusionWeights(BaseModel):
360
366
  keyword: float = 1.0
@@ -415,6 +421,12 @@ class RerankerName(str, Enum):
415
421
  class _BaseReranker(BaseModel):
416
422
  name: str
417
423
 
424
+ @model_validator(mode="after")
425
+ def set_discriminator(self) -> Self:
426
+ # Ensure discriminator is explicitly set so it's always serialized
427
+ self.name = self.name
428
+ return self
429
+
418
430
 
419
431
  class PredictReranker(_BaseReranker):
420
432
  name: Literal[RerankerName.PREDICT_RERANKER] = RerankerName.PREDICT_RERANKER
@@ -1090,10 +1102,22 @@ class ImageRagStrategyName:
1090
1102
  class RagStrategy(BaseModel):
1091
1103
  name: str
1092
1104
 
1105
+ @model_validator(mode="after")
1106
+ def set_discriminator(self) -> Self:
1107
+ # Ensure discriminator is explicitly set so it's always serialized
1108
+ self.name = self.name
1109
+ return self
1110
+
1093
1111
 
1094
1112
  class ImageRagStrategy(BaseModel):
1095
1113
  name: str
1096
1114
 
1115
+ @model_validator(mode="after")
1116
+ def set_discriminator(self) -> Self:
1117
+ # Ensure discriminator is explicitly set so it's always serialized
1118
+ self.name = self.name
1119
+ return self
1120
+
1097
1121
 
1098
1122
  ALLOWED_FIELD_TYPES: dict[str, str] = {
1099
1123
  "t": "text",
@@ -1697,8 +1721,6 @@ Using this feature also disables the `citations` parameter. For maximal accuracy
1697
1721
  obj = strategy
1698
1722
  elif isinstance(strategy, BaseModel):
1699
1723
  obj = strategy.model_dump()
1700
- # Explicitly mark the name field as set, so it's always included (even with exclude_unset=True)
1701
- strategy.name = strategy.name
1702
1724
  else:
1703
1725
  raise ValueError(
1704
1726
  "RAG strategies must be defined using a valid RagStrategy object or a dictionary"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb_models
3
- Version: 6.6.1.post4586
3
+ Version: 6.6.1.post4595
4
4
  Author-email: Nuclia <nucliadb@nuclia.com>
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Homepage, https://nuclia.com
@@ -8,7 +8,7 @@ nucliadb_models/export_import.py,sha256=mNm9IArOLnC6TLupkwqVFhxD5d08mpIVOVFneECv
8
8
  nucliadb_models/external_index_providers.py,sha256=IIKjJjLixWQC1zrbzam2FDcAo5UUxShZfueZSxqZu8Y,1535
9
9
  nucliadb_models/extracted.py,sha256=Zh79jrOcqedVYc36qM4D5qrOn5RutTuJAHusEeyIDiU,6245
10
10
  nucliadb_models/file.py,sha256=U66oSmywTWqE48mpNv9KG4X--XZtNI9i4Kl3EcYSLLM,1740
11
- nucliadb_models/filters.py,sha256=KZwVTcqtY2HoGn_MuK5gBPTJSjL-lwoAXsnsLS6HdCA,14296
11
+ nucliadb_models/filters.py,sha256=1Y1HwO6KBxIgQNg9MyJ3aJKnK_p6d1Y5-ZlUbX1WbvE,14759
12
12
  nucliadb_models/labels.py,sha256=9zqRgkpZuX3kUPwsTTgCH7JyOWK7dM5pwyuHJR86YdU,3949
13
13
  nucliadb_models/link.py,sha256=cfMOwaKDnaYSMxD5QClBu2Ab1orGfuTurFqNozp3KFk,2010
14
14
  nucliadb_models/metadata.py,sha256=7rCIpeWjvqDk4ytIVP3azR9Qmm5PTGVI1BNkNLXfHVo,8348
@@ -16,7 +16,7 @@ nucliadb_models/notifications.py,sha256=3w1HeX9F8nuA7WupHdpXIksX7d0bHO9ofmemYp4R
16
16
  nucliadb_models/processing.py,sha256=nhKuHQjqCdb9zJVkYGPTLub23tK9e_lwL5OCDVymZjY,719
17
17
  nucliadb_models/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  nucliadb_models/resource.py,sha256=FkhwmbjoqQBGyKQIqa40WK2Vq3wtryZeIVWmJ4b-84g,9003
19
- nucliadb_models/search.py,sha256=eV3XKS4XbR8iw0Rnw3S3OTRLvjB_iHgWqezGnDrXIIU,90829
19
+ nucliadb_models/search.py,sha256=eIJBJecl3A8a4pREi7c6kmDlGK9g1VsaVi00GncPbiA,91479
20
20
  nucliadb_models/security.py,sha256=opxaDLfvk3aU0sjesK0jGrYLx5h4YCwlKKN0moYs_ig,1150
21
21
  nucliadb_models/synonyms.py,sha256=afbaVqSQSxGLwi2PusVaLSRpkOtA5AZmWOKd1f4nl2E,690
22
22
  nucliadb_models/text.py,sha256=kY2ub7AaGm-4vNaLX3Ju2VvRw-eKZ2LRdM9z7XCNaG0,2898
@@ -27,12 +27,12 @@ nucliadb_models/vectorsets.py,sha256=XAgg9DfdfLYpfLh9OepJ_KPH0_RqRQNpVZJr74UnNh0
27
27
  nucliadb_models/writer.py,sha256=diwrarp6DxjSUoRmdEljZb68z_ghNvpOgPUGZeKg328,8220
28
28
  nucliadb_models/agents/ingestion.py,sha256=W9cJ0dQT_1vPcjeJ4_Fjb8DylnhQ6qqZrY4v8x1RqUs,3093
29
29
  nucliadb_models/graph/__init__.py,sha256=X538kZPZnndmQeEtnzzPv1hYVGUTDe9U1O7UmAqqxXU,645
30
- nucliadb_models/graph/requests.py,sha256=_J7iocrnb6o4Kgf30O8XmXiGuD7-2_t_obPa6S3TJcE,6874
30
+ nucliadb_models/graph/requests.py,sha256=qkIOTL1lP6tstvnbrqIt6IFhlOPZbjShds_HbSgAK-8,7164
31
31
  nucliadb_models/graph/responses.py,sha256=Sdq8OgFAL1YT-1lJyLLrkqcScvj7YTEqAUwQ-kFAk9M,1399
32
32
  nucliadb_models/internal/__init__.py,sha256=zG33bUz1rHFPtvqQPWn4rDwBJt3FJodGuQYD45quiQg,583
33
33
  nucliadb_models/internal/predict.py,sha256=Pnx6MmLfK65eExe1XnVxqmSlvMwdowewwks9BOEoqMw,2029
34
34
  nucliadb_models/internal/shards.py,sha256=__y1OZtWGiNcPQEWfSFOj8yw458WGi7mM4vZe0K-L1Y,1691
35
- nucliadb_models-6.6.1.post4586.dist-info/METADATA,sha256=k9chkzpXBLCRde27pub9bPdo846397ZeekljDfyPmtM,794
36
- nucliadb_models-6.6.1.post4586.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- nucliadb_models-6.6.1.post4586.dist-info/top_level.txt,sha256=UrY1I8oeovIRwkXLYplssTrxQdUjhSEFDFbnwaIV3tA,16
38
- nucliadb_models-6.6.1.post4586.dist-info/RECORD,,
35
+ nucliadb_models-6.6.1.post4595.dist-info/METADATA,sha256=4SL8SFwCKQQMIpIfvIG_GLBVCSG5YwJlr1mUouctGCI,794
36
+ nucliadb_models-6.6.1.post4595.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
+ nucliadb_models-6.6.1.post4595.dist-info/top_level.txt,sha256=UrY1I8oeovIRwkXLYplssTrxQdUjhSEFDFbnwaIV3tA,16
38
+ nucliadb_models-6.6.1.post4595.dist-info/RECORD,,