nucliadb 6.3.4.post3762__py3-none-any.whl → 6.3.4.post3780__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.
@@ -236,8 +236,6 @@ class ResourceBrain:
236
236
  field_relations = self.brain.field_relations[field_key].relations
237
237
  for relations in metadata.metadata.relations:
238
238
  for relation in relations.relations:
239
- self.brain.relations.append(relation)
240
-
241
239
  index_relation = IndexRelation(relation=relation)
242
240
  if relation.metadata.HasField("data_augmentation_task_id"):
243
241
  index_relation.facets.append(f"/g/da/{relation.metadata.data_augmentation_task_id}")
@@ -421,7 +419,6 @@ class ResourceBrain:
421
419
  source=relationnodedocument,
422
420
  to=relationnodeuser,
423
421
  )
424
- self.brain.relations.append(relation)
425
422
  self.brain.field_relations["a/metadata"].relations.append(
426
423
  IndexRelation(relation=relation)
427
424
  )
@@ -437,12 +434,10 @@ class ResourceBrain:
437
434
  source=relationnodedocument,
438
435
  to=relation_node_label,
439
436
  )
440
- self.brain.relations.append(relation)
441
437
  self.brain.field_relations["a/metadata"].relations.append(IndexRelation(relation=relation))
442
438
 
443
439
  # relations
444
440
  for relation in user_relations.relations:
445
- self.brain.relations.append(relation)
446
441
  self.brain.field_relations["a/metadata"].relations.append(
447
442
  IndexRelation(relation=relation, facets=["/g/u"])
448
443
  )
@@ -522,7 +517,6 @@ class ResourceBrain:
522
517
  relation = Relation()
523
518
  relation.CopyFrom(base_classification_relation)
524
519
  relation.to.value = label
525
- self.brain.relations.append(relation)
526
520
  self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
527
521
 
528
522
  # Data Augmentation + Processor entities
@@ -550,7 +544,6 @@ class ResourceBrain:
550
544
  relation.CopyFrom(base_entity_relation)
551
545
  relation.to.value = entity_text
552
546
  relation.to.subtype = entity_label
553
- self.brain.relations.append(relation)
554
547
  self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
555
548
 
556
549
  # Legacy processor entities
@@ -570,7 +563,6 @@ class ResourceBrain:
570
563
  relation.CopyFrom(base_entity_relation)
571
564
  relation.to.value = entity
572
565
  relation.to.subtype = klass
573
- self.brain.relations.append(relation)
574
566
  self.brain.field_relations[field_key].relations.append(IndexRelation(relation=relation))
575
567
 
576
568
  def apply_field_labels(
@@ -627,7 +619,6 @@ class ResourceBrain:
627
619
  source=relation_node_resource,
628
620
  to=relation_node_entity,
629
621
  )
630
- self.brain.relations.append(rel)
631
622
  self.brain.field_relations[field_key].relations.append(IndexRelation(relation=rel))
632
623
  for paragraph_annotation in basic_user_fieldmetadata.paragraphs:
633
624
  for classification in paragraph_annotation.classifications:
@@ -436,6 +436,9 @@ class NotEnoughContextAskResult(AskResult):
436
436
  return the find results and the messages indicating that there is not enough
437
437
  context in the corpus to answer.
438
438
  """
439
+ status = AnswerStatusCode.NO_RETRIEVAL_DATA
440
+ yield self._ndjson_encode(StatusAskResponseItem(code=status.value, status=status.prettify()))
441
+ yield self._ndjson_encode(AnswerAskResponseItem(text=NOT_ENOUGH_CONTEXT_ANSWER))
439
442
  yield self._ndjson_encode(RetrievalAskResponseItem(results=self.main_results))
440
443
  if self.prequeries_results:
441
444
  yield self._ndjson_encode(
@@ -446,9 +449,6 @@ class NotEnoughContextAskResult(AskResult):
446
449
  }
447
450
  )
448
451
  )
449
- yield self._ndjson_encode(AnswerAskResponseItem(text=NOT_ENOUGH_CONTEXT_ANSWER))
450
- status = AnswerStatusCode.NO_RETRIEVAL_DATA
451
- yield self._ndjson_encode(StatusAskResponseItem(code=status.value, status=status.prettify()))
452
452
 
453
453
  async def json(self) -> str:
454
454
  prequeries = (
@@ -153,9 +153,10 @@ async def _index_node_retrieval(
153
153
  search_results.shards = queried_shards
154
154
  search_results.autofilters = autofilters
155
155
 
156
+ ndb_time = metrics.elapsed("node_query") + metrics.elapsed("results_merge")
156
157
  if metrics.elapsed("node_query") > settings.slow_node_query_log_threshold:
157
158
  logger.warning(
158
- "Slow node query",
159
+ "Slow nidx query",
159
160
  extra={
160
161
  "kbid": kbid,
161
162
  "user": x_nucliadb_user,
@@ -166,7 +167,7 @@ async def _index_node_retrieval(
166
167
  "durations": metrics.steps(),
167
168
  },
168
169
  )
169
- elif search_time > settings.slow_find_log_threshold:
170
+ elif ndb_time > settings.slow_find_log_threshold:
170
171
  logger.info(
171
172
  "Slow find query",
172
173
  extra={
@@ -485,12 +485,17 @@ def _merge_relations_results(
485
485
  relations.entities[entry_point.value] = EntitySubgraph(related_to=[])
486
486
 
487
487
  for relation_response in relations_responses:
488
- for relation in relation_response.subgraph.relations:
488
+ for index_relation in relation_response.subgraph.relations:
489
+ relation = index_relation.relation
489
490
  origin = relation.source
490
491
  destination = relation.to
491
492
  relation_type = RelationTypePbMap[relation.relation] # type: ignore
492
493
  relation_label = relation.relation_label
493
494
  metadata = relation.metadata if relation.HasField("metadata") else None
495
+
496
+ if index_relation.resource_field_id is not None:
497
+ resource_id = index_relation.resource_field_id.split("/")[0]
498
+
494
499
  # If only_with_metadata is True, we check that metadata for the relation is not None
495
500
  # If only_agentic is True, we check that metadata for the relation is not None and that it has a data_augmentation_task_id
496
501
  # TODO: This is suboptimal, we should be able to filter this in the query to the index,
@@ -513,7 +518,7 @@ def _merge_relations_results(
513
518
  relation_label=relation_label,
514
519
  direction=RelationDirection.OUT,
515
520
  metadata=from_proto.relation_metadata(metadata) if metadata else None,
516
- resource_id=relation.resource_id,
521
+ resource_id=resource_id,
517
522
  )
518
523
  )
519
524
  elif destination.value in relations.entities:
@@ -526,7 +531,7 @@ def _merge_relations_results(
526
531
  relation_label=relation_label,
527
532
  direction=RelationDirection.IN,
528
533
  metadata=from_proto.relation_metadata(metadata) if metadata else None,
529
- resource_id=relation.resource_id,
534
+ resource_id=resource_id,
530
535
  )
531
536
  )
532
537
 
@@ -180,9 +180,15 @@ async def set_labelset_endpoint(request: Request, kbid: str, labelset: str, item
180
180
 
181
181
  try:
182
182
  labelsets = await datamanagers.atomic.labelset.get_all(kbid=kbid)
183
- labelset_titles = [ls.title.lower() for (k, ls) in labelsets.labelset.items() if k != labelset]
183
+ labelset_titles = {
184
+ ls.title.lower(): k for (k, ls) in labelsets.labelset.items() if k != labelset
185
+ }
184
186
  if item.title.lower() in labelset_titles:
185
- raise HTTPException(status_code=422, detail="Duplicated labelset titles are not allowed")
187
+ conflict = labelset_titles[item.title.lower()]
188
+ raise HTTPException(
189
+ status_code=422,
190
+ detail=f"Duplicated labelset titles are not allowed. Labelset {conflict} has the same title",
191
+ )
186
192
 
187
193
  await set_labelset(kbid, labelset, item)
188
194
  except KnowledgeBoxNotFound:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.3.4.post3762
3
+ Version: 6.3.4.post3780
4
4
  Summary: NucliaDB
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License: AGPL
@@ -20,11 +20,11 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3 :: Only
21
21
  Requires-Python: <4,>=3.9
22
22
  Description-Content-Type: text/markdown
23
- Requires-Dist: nucliadb-telemetry[all]>=6.3.4.post3762
24
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3762
25
- Requires-Dist: nucliadb-protos>=6.3.4.post3762
26
- Requires-Dist: nucliadb-models>=6.3.4.post3762
27
- Requires-Dist: nidx-protos>=6.3.4.post3762
23
+ Requires-Dist: nucliadb-telemetry[all]>=6.3.4.post3780
24
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.3.4.post3780
25
+ Requires-Dist: nucliadb-protos>=6.3.4.post3780
26
+ Requires-Dist: nucliadb-models>=6.3.4.post3780
27
+ Requires-Dist: nidx-protos>=6.3.4.post3780
28
28
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
29
29
  Requires-Dist: nuclia-models>=0.24.2
30
30
  Requires-Dist: uvicorn
@@ -139,7 +139,7 @@ nucliadb/ingest/fields/generic.py,sha256=elgtqv15aJUq3zY7X_g0bli_2BpcwPArVvzhe54
139
139
  nucliadb/ingest/fields/link.py,sha256=kN_gjRUEEj5cy8K_BwPijYg3TiWhedc24apXYlTbRJs,4172
140
140
  nucliadb/ingest/fields/text.py,sha256=tFvSQJAe0W7ePpp2_WDfLiE2yglR1OTU0Zht9acvOFw,1594
141
141
  nucliadb/ingest/orm/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
142
- nucliadb/ingest/orm/brain.py,sha256=lvO6bF0usfbZ5T7bDPoVALfocvxTFrCE3YhQrz-d1q8,29831
142
+ nucliadb/ingest/orm/brain.py,sha256=A8H1J7Bo95sNzDgYr0_UNoemQhWOFEFz9UlYfs6ug-8,29407
143
143
  nucliadb/ingest/orm/broker_message.py,sha256=XWaiZgDOz94NPOPT-hqbRr5ZkpVimUw6PjUJNftfoVw,7514
144
144
  nucliadb/ingest/orm/entities.py,sha256=3_n6lKhBy2GsdmNmkh0_mvxP8md20OZsbtTNEmfJ8Hg,14888
145
145
  nucliadb/ingest/orm/exceptions.py,sha256=k4Esv4NtL4TrGTcsQpwrSfDhPQpiYcRbB1SpYmBX5MY,1432
@@ -226,13 +226,13 @@ nucliadb/search/search/cut.py,sha256=ytY0_GY7ocNjfxTb4aosxEp4ZfhQNDP--JkhEMGD298
226
226
  nucliadb/search/search/exceptions.py,sha256=klGLgAGGrXcSGix_W6418ZBMqDchAIGjN77ofkOScEI,1039
227
227
  nucliadb/search/search/fetch.py,sha256=XJHIFnZmXM_8Kb37lb4lg1GYG7cZ1plT-qAIb_QziX4,6184
228
228
  nucliadb/search/search/filters.py,sha256=1MkHlJjAQqoRCj7e5cEzK2HvBxGLE17I_omsjiklbtw,6476
229
- nucliadb/search/search/find.py,sha256=p7Odx3hjPwTsHEhQrVYsR_ufq0meMmCnQV0YihfOmlg,10237
229
+ nucliadb/search/search/find.py,sha256=pjc-i55j_p_F1H0La4qc9slZSl_gICoFzl3fy6FLYTM,10314
230
230
  nucliadb/search/search/find_merge.py,sha256=3FnzKFEnVemg6FO_6zveulbAU7klvsiPEBvLrpBBMg8,17450
231
231
  nucliadb/search/search/graph_merge.py,sha256=OiUNiXOWwrUVKqStuRcoUJwvDbDYamqIgiAy_FwPdMI,3405
232
232
  nucliadb/search/search/graph_strategy.py,sha256=gisL2GpbSIa_SucyOwEt7TWdqURyAQqxvD_-PkXQct8,32339
233
233
  nucliadb/search/search/hydrator.py,sha256=-R37gCrGxkyaiHQalnTWHNG_FCx11Zucd7qA1vQCxuw,6985
234
234
  nucliadb/search/search/ingestion_agents.py,sha256=NeJr4EEX-bvFFMGvXOOwLv8uU7NuQ-ntJnnrhnKfMzY,3174
235
- nucliadb/search/search/merge.py,sha256=aNjghwyQDuoIuddFt37_kHAUv4FDYgGtdP3dM1SBUWs,22966
235
+ nucliadb/search/search/merge.py,sha256=bPO51Kc3Ec69UuCbF5ulokd02gWZhp7zlJSuMjGDo9Y,23141
236
236
  nucliadb/search/search/metrics.py,sha256=GGGtXHLhK79_ESV277xkBVjcaMURXHCxYG0EdGamUd8,2886
237
237
  nucliadb/search/search/paragraphs.py,sha256=pNAEiYqJGGUVcEf7xf-PFMVqz0PX4Qb-WNG-_zPGN2o,7799
238
238
  nucliadb/search/search/pgcatalog.py,sha256=s_J98fsX_RuFXwpejpkGqG-tD9ELuzz4YQ6U3ew5h2g,9313
@@ -244,7 +244,7 @@ nucliadb/search/search/shards.py,sha256=OEtN1p9WX_cMX8t-myaafpmFAPTpUEOutR7z1sDu
244
244
  nucliadb/search/search/summarize.py,sha256=ksmYPubEQvAQgfPdZHfzB_rR19B2ci4IYZ6jLdHxZo8,4996
245
245
  nucliadb/search/search/utils.py,sha256=iF2tbBA56gRMJH1TlE2hMrqeXqjoeOPt4KgRdp2m9Ek,3313
246
246
  nucliadb/search/search/chat/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
247
- nucliadb/search/search/chat/ask.py,sha256=olZT08JVo3ZGDsDXkjvI2JTlqQln_o91HJzv0TKFQ7I,37244
247
+ nucliadb/search/search/chat/ask.py,sha256=4Vi4yxnhjToPHZUtdUkFNAEuI85QgkyBXQkcRX-a_vA,37244
248
248
  nucliadb/search/search/chat/exceptions.py,sha256=Siy4GXW2L7oPhIR86H3WHBhE9lkV4A4YaAszuGGUf54,1356
249
249
  nucliadb/search/search/chat/images.py,sha256=PA8VWxT5_HUGfW1ULhKTK46UBsVyINtWWqEM1ulzX1E,3095
250
250
  nucliadb/search/search/chat/prompt.py,sha256=Jnja-Ss7skgnnDY8BymVfdeYsFPnIQFL8tEvcRXTKUE,47356
@@ -335,7 +335,7 @@ nucliadb/writer/api/v1/knowledgebox.py,sha256=MLeIuym4jPrJgfy1NTcN9CpUGwuBiqDHMc
335
335
  nucliadb/writer/api/v1/learning_config.py,sha256=CKBjqcbewkfPwGUPLDWzZSpro6XkmCaVppe5Qtpu5Go,3117
336
336
  nucliadb/writer/api/v1/resource.py,sha256=jV9HM-ID1PPYypfy4Sl4_9aSPF87v7gSJZUSzHjHcQ4,19740
337
337
  nucliadb/writer/api/v1/router.py,sha256=RjuoWLpZer6Kl2BW_wznpNo6XL3BOpdTGqXZCn3QrrQ,1034
338
- nucliadb/writer/api/v1/services.py,sha256=HLQW18AEC5zQp5azpeAtRi7ZTzQSwG6SbmkHlmjTIFA,13165
338
+ nucliadb/writer/api/v1/services.py,sha256=3AUjk-SmvqJx76v7y89DZx6oyasojPliGYeniRQjpcU,13337
339
339
  nucliadb/writer/api/v1/slug.py,sha256=xlVBDBpRi9bNulpBHZwhyftVvulfE0zFm1XZIWl-AKY,2389
340
340
  nucliadb/writer/api/v1/transaction.py,sha256=d2Vbgnkk_-FLGSTt3vfldwiJIUf0XoyD0wP1jQNz_DY,2430
341
341
  nucliadb/writer/api/v1/upload.py,sha256=hLMHXSaqEOE-vjKjhIupgdx8klJc3mVQp_oMwx5N-7o,33800
@@ -354,8 +354,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
354
354
  nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
355
355
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
356
356
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
357
- nucliadb-6.3.4.post3762.dist-info/METADATA,sha256=Zr2XIrUsS85ApCvFMDHlLy5RwSd_sNZjds-dEClJkqg,4291
358
- nucliadb-6.3.4.post3762.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
359
- nucliadb-6.3.4.post3762.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
360
- nucliadb-6.3.4.post3762.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
361
- nucliadb-6.3.4.post3762.dist-info/RECORD,,
357
+ nucliadb-6.3.4.post3780.dist-info/METADATA,sha256=fWU0d62hr5LmRJRO4TGC9prZ4nZ261zU12xkYtDo2ng,4291
358
+ nucliadb-6.3.4.post3780.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
359
+ nucliadb-6.3.4.post3780.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
360
+ nucliadb-6.3.4.post3780.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
361
+ nucliadb-6.3.4.post3780.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (77.0.3)
2
+ Generator: setuptools (78.0.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5