nucliadb 6.9.2.post5275__py3-none-any.whl → 6.9.2.post5276__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.

Potentially problematic release.


This version of nucliadb might be problematic. Click here for more details.

@@ -88,6 +88,7 @@ class resources:
88
88
  get_resource_uuid_from_slug = ro_txn_wrap(resources_dm.get_resource_uuid_from_slug)
89
89
  resource_exists = ro_txn_wrap(resources_dm.resource_exists)
90
90
  slug_exists = ro_txn_wrap(resources_dm.slug_exists)
91
+ get_all_field_ids = ro_txn_wrap(resources_dm.get_all_field_ids)
91
92
 
92
93
 
93
94
  class labelset:
@@ -26,6 +26,7 @@ from typing import Deque, Dict, List, Optional, Sequence, Tuple, Union, cast
26
26
  import yaml
27
27
  from pydantic import BaseModel
28
28
 
29
+ from nucliadb.common import datamanagers
29
30
  from nucliadb.common.ids import FIELD_TYPE_STR_TO_PB, FieldId, ParagraphId
30
31
  from nucliadb.common.maindb.utils import get_driver
31
32
  from nucliadb.common.models_utils import from_proto
@@ -589,18 +590,7 @@ async def field_extension_prompt_context(
589
590
  if resource_uuid not in ordered_resources:
590
591
  ordered_resources.append(resource_uuid)
591
592
 
592
- # Fetch the extracted texts of the specified fields for each resource
593
- extend_fields = strategy.fields
594
- extend_field_ids = []
595
- for resource_uuid in ordered_resources:
596
- for field_id in extend_fields:
597
- try:
598
- fid = FieldId.from_string(f"{resource_uuid}/{field_id.strip('/')}")
599
- extend_field_ids.append(fid)
600
- except ValueError: # pragma: no cover
601
- # Invalid field id, skiping
602
- continue
603
-
593
+ extend_field_ids = await get_matching_field_ids(kbid, ordered_resources, strategy)
604
594
  tasks = [hydrate_field_text(kbid, fid) for fid in extend_field_ids]
605
595
  field_extracted_texts = await run_concurrently(tasks)
606
596
 
@@ -630,6 +620,43 @@ async def field_extension_prompt_context(
630
620
  context[paragraph.id] = _clean_paragraph_text(paragraph)
631
621
 
632
622
 
623
+ async def get_matching_field_ids(
624
+ kbid: str, ordered_resources: list[str], strategy: FieldExtensionStrategy
625
+ ) -> list[FieldId]:
626
+ extend_field_ids: list[FieldId] = []
627
+ # Fetch the extracted texts of the specified fields for each resource
628
+ for resource_uuid in ordered_resources:
629
+ for field_id in strategy.fields:
630
+ try:
631
+ fid = FieldId.from_string(f"{resource_uuid}/{field_id.strip('/')}")
632
+ extend_field_ids.append(fid)
633
+ except ValueError: # pragma: no cover
634
+ # Invalid field id, skiping
635
+ continue
636
+ if len(strategy.data_augmentation_field_prefixes) > 0:
637
+ for resource_uuid in ordered_resources:
638
+ all_field_ids = await datamanagers.atomic.resources.get_all_field_ids(
639
+ kbid=kbid, rid=resource_uuid, for_update=False
640
+ )
641
+ if all_field_ids is None:
642
+ continue
643
+ for fieldid in all_field_ids.fields:
644
+ # Generated fields are always text fields starting with "da-"
645
+ if any(
646
+ (
647
+ fieldid.field_type == resources_pb2.FieldType.TEXT
648
+ and fieldid.field.startswith(f"da-{prefix}-")
649
+ )
650
+ for prefix in strategy.data_augmentation_field_prefixes
651
+ ):
652
+ extend_field_ids.append(
653
+ FieldId.from_pb(
654
+ rid=resource_uuid, field_type=fieldid.field_type, key=fieldid.field
655
+ )
656
+ )
657
+ return extend_field_ids
658
+
659
+
633
660
  async def get_orm_field(kbid: str, field_id: FieldId) -> Optional[Field]:
634
661
  resource = await cache.get_resource(kbid, field_id.rid)
635
662
  if resource is None: # pragma: no cover
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nucliadb
3
- Version: 6.9.2.post5275
3
+ Version: 6.9.2.post5276
4
4
  Summary: NucliaDB
5
5
  Author-email: Nuclia <nucliadb@nuclia.com>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -18,11 +18,11 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3 :: Only
19
19
  Requires-Python: <4,>=3.10
20
20
  Description-Content-Type: text/markdown
21
- Requires-Dist: nucliadb-telemetry[all]>=6.9.2.post5275
22
- Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.9.2.post5275
23
- Requires-Dist: nucliadb-protos>=6.9.2.post5275
24
- Requires-Dist: nucliadb-models>=6.9.2.post5275
25
- Requires-Dist: nidx-protos>=6.9.2.post5275
21
+ Requires-Dist: nucliadb-telemetry[all]>=6.9.2.post5276
22
+ Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.9.2.post5276
23
+ Requires-Dist: nucliadb-protos>=6.9.2.post5276
24
+ Requires-Dist: nucliadb-models>=6.9.2.post5276
25
+ Requires-Dist: nidx-protos>=6.9.2.post5276
26
26
  Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
27
27
  Requires-Dist: nuclia-models>=0.50.0
28
28
  Requires-Dist: uvicorn[standard]
@@ -95,7 +95,7 @@ nucliadb/common/cluster/standalone/utils.py,sha256=af3r-x_GF7A6dwIAhZLR-r-SZQEVx
95
95
  nucliadb/common/context/__init__.py,sha256=IKAHuiCjbOEsqfLozWwJ6mRFzFncsZMyxNC5E_XZ5EM,6016
96
96
  nucliadb/common/context/fastapi.py,sha256=mH_8n5t7quNSPivNM2JS5EQf2sTVJsdzXW6LaY7EHAA,1629
97
97
  nucliadb/common/datamanagers/__init__.py,sha256=xKc6ZMqKUs20R90jJT4xkQ8TFMNwQnhhuWnBBqVnKdM,2084
98
- nucliadb/common/datamanagers/atomic.py,sha256=-3T2--A0_qFWmy573t-DS29EHFcMTyjGvcvky6J9tAM,3341
98
+ nucliadb/common/datamanagers/atomic.py,sha256=tZEOUqrbUjNKEgxNn8IpukK0BuBQMtf-rKUq0KuT_YY,3409
99
99
  nucliadb/common/datamanagers/cluster.py,sha256=iU0b7AESm1Yi8Wp3pIKgqixZGNMjeBrxSpvEKsaZKgY,1831
100
100
  nucliadb/common/datamanagers/entities.py,sha256=gI-0mbMlqrr9FiyhexEh6czhgYcMxE2s9m4o866EK9o,5340
101
101
  nucliadb/common/datamanagers/exceptions.py,sha256=Atz_PP_GGq4jgJaWcAkcRbHBoBaGcC9yJvFteylKtTE,883
@@ -271,7 +271,7 @@ nucliadb/search/search/chat/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn
271
271
  nucliadb/search/search/chat/ask.py,sha256=siMKgXEuAOUPa9oxi72idEOhN9BXZ-NVvWY3rqMMM3I,41610
272
272
  nucliadb/search/search/chat/exceptions.py,sha256=Siy4GXW2L7oPhIR86H3WHBhE9lkV4A4YaAszuGGUf54,1356
273
273
  nucliadb/search/search/chat/images.py,sha256=PA8VWxT5_HUGfW1ULhKTK46UBsVyINtWWqEM1ulzX1E,3095
274
- nucliadb/search/search/chat/prompt.py,sha256=dqk6969zEymfGuDl0S1uAGM_Ii5kgdcCgNkuVrM0_8c,54406
274
+ nucliadb/search/search/chat/prompt.py,sha256=Ti0dO8RDY9YeRPowwiWbojjd-IgpAKkHEat79jGFidk,55671
275
275
  nucliadb/search/search/chat/query.py,sha256=Ds_0vYfCdbfTZerSM0AykkfKYYJj88j_M2XA87FfjJQ,17101
276
276
  nucliadb/search/search/hydrator/__init__.py,sha256=3Pc-rcax4TI174qcrllnReE728DoJTaA8tpvBUFf98g,7005
277
277
  nucliadb/search/search/hydrator/fields.py,sha256=LhKw-aNU5eJqfZADtq3iB7AGXm0l_QabAAoSHJTk8Is,5962
@@ -385,8 +385,8 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
385
385
  nucliadb/writer/tus/s3.py,sha256=vu1BGg4VqJ_x2P1u2BxqPKlSfw5orT_a3R-Ln5oPUpU,8483
386
386
  nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
387
387
  nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
388
- nucliadb-6.9.2.post5275.dist-info/METADATA,sha256=Rw1v7kl_32369UkLp0l5JKfZ8ipe5j0wd1hNBDFTxiw,4118
389
- nucliadb-6.9.2.post5275.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
390
- nucliadb-6.9.2.post5275.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
391
- nucliadb-6.9.2.post5275.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
392
- nucliadb-6.9.2.post5275.dist-info/RECORD,,
388
+ nucliadb-6.9.2.post5276.dist-info/METADATA,sha256=92ehiGl-d963I9_9rxJo1lyNxd7om9lcGXMtunuwhc8,4118
389
+ nucliadb-6.9.2.post5276.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
390
+ nucliadb-6.9.2.post5276.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
391
+ nucliadb-6.9.2.post5276.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
392
+ nucliadb-6.9.2.post5276.dist-info/RECORD,,