nucliadb-models 6.4.0.post4158__py3-none-any.whl → 6.4.0.post4167__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.
@@ -23,6 +23,7 @@ from typing import Annotated, Literal, Optional, Union
23
23
 
24
24
  from pydantic import BaseModel, Field, create_model
25
25
 
26
+ from .graph.requests import GraphPathQuery # noqa # we need this import for pydantic magic
26
27
  from .search import AskRequest, FindRequest
27
28
 
28
29
 
@@ -79,3 +80,7 @@ class AskSearchConfiguration(BaseModel):
79
80
  SearchConfiguration = Annotated[
80
81
  Union[FindSearchConfiguration, AskSearchConfiguration], Field(discriminator="kind")
81
82
  ]
83
+
84
+ # We need this to avoid issues with pydantic and generic types defined in another module
85
+ FindConfig.model_rebuild()
86
+ AskConfig.model_rebuild()
@@ -25,7 +25,6 @@ from typing_extensions import Self
25
25
 
26
26
  from nucliadb_models.filters import And, FieldFilterExpression, Not, Or, filter_discriminator
27
27
  from nucliadb_models.metadata import RelationNodeType, RelationType
28
- from nucliadb_models.search import SearchParamDefaults
29
28
  from nucliadb_models.security import RequestSecurity
30
29
 
31
30
  ## Models for graph nodes and relations
@@ -161,8 +160,16 @@ class GraphSearchRequest(BaseGraphSearchRequest):
161
160
  "Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters "
162
161
  ),
163
162
  )
164
- security: Optional[RequestSecurity] = SearchParamDefaults.security.to_pydantic_field()
165
- show_hidden: bool = SearchParamDefaults.show_hidden.to_pydantic_field()
163
+ security: Optional[RequestSecurity] = Field(
164
+ default=None,
165
+ title="Security",
166
+ description="Security metadata for the request. If not provided, the search request is done without the security lookup phase.", # noqa: E501
167
+ )
168
+ show_hidden: bool = Field(
169
+ default=False,
170
+ title="Show hidden resources",
171
+ description="If set to false (default), excludes hidden resources from search",
172
+ )
166
173
 
167
174
 
168
175
  # Nodes search
@@ -189,8 +196,16 @@ class GraphNodesSearchRequest(BaseGraphSearchRequest):
189
196
  "Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters "
190
197
  ),
191
198
  )
192
- security: Optional[RequestSecurity] = SearchParamDefaults.security.to_pydantic_field()
193
- show_hidden: bool = SearchParamDefaults.show_hidden.to_pydantic_field()
199
+ security: Optional[RequestSecurity] = Field(
200
+ default=None,
201
+ title="Security",
202
+ description="Security metadata for the request. If not provided, the search request is done without the security lookup phase.", # noqa: E501
203
+ )
204
+ show_hidden: bool = Field(
205
+ default=False,
206
+ title="Show hidden resources",
207
+ description="If set to false (default), excludes hidden resources from search",
208
+ )
194
209
 
195
210
 
196
211
  # Relations search
@@ -217,8 +232,16 @@ class GraphRelationsSearchRequest(BaseGraphSearchRequest):
217
232
  "Filtering examples can be found here: https://docs.nuclia.dev/docs/rag/advanced/search-filters "
218
233
  ),
219
234
  )
220
- security: Optional[RequestSecurity] = SearchParamDefaults.security.to_pydantic_field()
221
- show_hidden: bool = SearchParamDefaults.show_hidden.to_pydantic_field()
235
+ security: Optional[RequestSecurity] = Field(
236
+ default=None,
237
+ title="Security",
238
+ description="Security metadata for the request. If not provided, the search request is done without the security lookup phase.", # noqa: E501
239
+ )
240
+ show_hidden: bool = Field(
241
+ default=False,
242
+ title="Show hidden resources",
243
+ description="If set to false (default), excludes hidden resources from search",
244
+ )
222
245
 
223
246
 
224
247
  # We need this to avoid issues with pydantic and generic types defined in another module
nucliadb_models/search.py CHANGED
@@ -27,6 +27,7 @@ from typing_extensions import Annotated, Self
27
27
 
28
28
  from nucliadb_models import RelationMetadata
29
29
  from nucliadb_models.common import FieldTypeName, ParamDefault
30
+ from nucliadb_models.graph.requests import GraphPathQuery
30
31
 
31
32
  # Bw/c import to avoid breaking users
32
33
  # noqa isort: skip
@@ -104,9 +105,10 @@ class SearchOptions(str, Enum):
104
105
 
105
106
 
106
107
  class FindOptions(str, Enum):
107
- RELATIONS = "relations"
108
108
  KEYWORD = "keyword"
109
109
  SEMANTIC = "semantic"
110
+ RELATIONS = "relations"
111
+ GRAPH = "graph"
110
112
 
111
113
 
112
114
  class ChatOptions(str, Enum):
@@ -359,6 +361,7 @@ class _BaseRankFusion(BaseModel):
359
361
  class ReciprocalRankFusionWeights(BaseModel):
360
362
  keyword: float = 1.0
361
363
  semantic: float = 1.0
364
+ graph: SkipJsonSchema[float] = 1.0
362
365
 
363
366
 
364
367
  class ReciprocalRankFusion(_BaseRankFusion):
@@ -1724,6 +1727,11 @@ class FindRequest(BaseSearchRequest):
1724
1727
  query_entities: SkipJsonSchema[Optional[list[KnowledgeGraphEntity]]] = Field(
1725
1728
  default=None, title="Query entities", description="Entities to use in a knowledge graph search"
1726
1729
  )
1730
+ graph_query: SkipJsonSchema[Optional[GraphPathQuery]] = Field(
1731
+ default=None,
1732
+ title="Graph query",
1733
+ description="Query for the knowledge graph. Paths (node-relation-node) extracted from a paragraph_id will be used to extend the results",
1734
+ )
1727
1735
  features: list[FindOptions] = SearchParamDefaults.search_features.to_pydantic_field(
1728
1736
  default=[
1729
1737
  FindOptions.KEYWORD,
@@ -1769,6 +1777,13 @@ class FindRequest(BaseSearchRequest):
1769
1777
  values["rank_fusion"] = RankFusionName.RECIPROCAL_RANK_FUSION
1770
1778
  return values
1771
1779
 
1780
+ @field_validator("features")
1781
+ @classmethod
1782
+ def incompatible_features(cls, features: list[FindOptions]):
1783
+ if FindOptions.RELATIONS in features and FindOptions.GRAPH in features:
1784
+ raise ValueError("Relations and graph are incompatible features, please, use only one")
1785
+ return features
1786
+
1772
1787
 
1773
1788
  class SCORE_TYPE(str, Enum):
1774
1789
  VECTOR = "VECTOR"
@@ -2139,3 +2154,7 @@ def parse_custom_prompt(item: AskRequest) -> CustomPrompt:
2139
2154
  def parse_rephrase_prompt(item: AskRequest) -> Optional[str]:
2140
2155
  prompt = parse_custom_prompt(item)
2141
2156
  return prompt.rephrase
2157
+
2158
+
2159
+ # We need this to avoid issues with pydantic and generic types defined in another module
2160
+ FindRequest.model_rebuild()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb_models
3
- Version: 6.4.0.post4158
3
+ Version: 6.4.0.post4167
4
4
  Author-email: Nuclia <nucliadb@nuclia.com>
5
5
  License: AGPL
6
6
  Project-URL: Homepage, https://nuclia.com
@@ -1,6 +1,6 @@
1
1
  nucliadb_models/__init__.py,sha256=qSmhNKACMwdbU1rklMWlmJKmlRaWvrSksTtwEVkiydQ,1331
2
2
  nucliadb_models/common.py,sha256=JEEY7_AxRCBPHUF6J8XptR_QnGEjRBd02Kqm5WOySYc,7828
3
- nucliadb_models/configuration.py,sha256=7iUgSCkmFinu6clCfT54P5tuz5Lvf6eJVmahYjwI7qk,2525
3
+ nucliadb_models/configuration.py,sha256=dogTdIJ7lmlT2JwIFs2e18JvNKiwzsGlD_UJp8Fna3Q,2760
4
4
  nucliadb_models/content_types.py,sha256=2B3TJpPYJqd-9xGiNiHJFngSIrVyNsZlN4PeB-HafIk,3682
5
5
  nucliadb_models/conversation.py,sha256=nUXvcH3J_xk4HB7raI38dGtZebc_G6TZZWjicjyAa7g,3635
6
6
  nucliadb_models/entities.py,sha256=IqsbF0dSCWkp222sd_R2Ste0iG1eoBPNh1Fh6mNVcu0,2608
@@ -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=HfXBMzRlRBKeFWmzsA4pWQmtR3Pt-EGLdp-rySqwWN8,82075
19
+ nucliadb_models/search.py,sha256=zuTZ8g3Rbkjx0Y99cFm8SYZBVMt17ubkw6EToW1q3DI,82901
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=dr-ckEIK0a8c5u-7uO1wpund_8KKb_4T79Au4Lfv-Bo,3150
@@ -27,12 +27,12 @@ nucliadb_models/vectorsets.py,sha256=avxwO9JPX2k5sCniuNhh2MSsP7aRNvf1eB1-h3-Ju1o
27
27
  nucliadb_models/writer.py,sha256=OLtCGmicpVf56pXi2_myTAvStpnaBKKOVNtZzHkKKtw,8472
28
28
  nucliadb_models/agents/ingestion.py,sha256=mV7gV6VpYg4VNpc59K3275TMUJZbUzeUnp3SZzO5uxY,3137
29
29
  nucliadb_models/graph/__init__.py,sha256=eu_1UK7GlBQRg5IRUqJkxVMcBxkXeqX4SZL6fuvwjDg,897
30
- nucliadb_models/graph/requests.py,sha256=W0Dy1AV2H1JJiweoCRqzsvMReNksNZDd4QXzKWNScH4,7544
30
+ nucliadb_models/graph/requests.py,sha256=w63Put4SvIHE-b0StA4MHqSt2vQkymfMlv5YPycpibA,8311
31
31
  nucliadb_models/graph/responses.py,sha256=3aimAHrd3YW1BXHU_ZXRoidlccRtkCcREkfCNotqgIQ,1651
32
32
  nucliadb_models/internal/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
33
33
  nucliadb_models/internal/predict.py,sha256=5rgUPrH_98gerySOZ-TR2PX_qzCGF1_8VxyOu3bGhis,2281
34
34
  nucliadb_models/internal/shards.py,sha256=bcnkxF_zViHZfT6WTAMBcWgY3UV-OAV65cVdSqGkcHY,1943
35
- nucliadb_models-6.4.0.post4158.dist-info/METADATA,sha256=ojRL69H57YQwa9UP6naBdyh_bmBRQH1cD4nXHh44mh4,759
36
- nucliadb_models-6.4.0.post4158.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
37
- nucliadb_models-6.4.0.post4158.dist-info/top_level.txt,sha256=UrY1I8oeovIRwkXLYplssTrxQdUjhSEFDFbnwaIV3tA,16
38
- nucliadb_models-6.4.0.post4158.dist-info/RECORD,,
35
+ nucliadb_models-6.4.0.post4167.dist-info/METADATA,sha256=vyirv173inFMKSCjcCO_eUZeXDpKgTLcAnQbCWZpfGE,759
36
+ nucliadb_models-6.4.0.post4167.dist-info/WHEEL,sha256=ooBFpIzZCPdw3uqIQsOo4qqbA4ZRPxHnOH7peeONza0,91
37
+ nucliadb_models-6.4.0.post4167.dist-info/top_level.txt,sha256=UrY1I8oeovIRwkXLYplssTrxQdUjhSEFDFbnwaIV3tA,16
38
+ nucliadb_models-6.4.0.post4167.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5