nucliadb 6.2.1.post2949__py3-none-any.whl → 6.2.1.post2954__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.
- nucliadb/search/predict.py +2 -0
- nucliadb/search/search/chat/ask.py +28 -2
- nucliadb/search/search/chat/query.py +3 -3
- {nucliadb-6.2.1.post2949.dist-info → nucliadb-6.2.1.post2954.dist-info}/METADATA +5 -5
- {nucliadb-6.2.1.post2949.dist-info → nucliadb-6.2.1.post2954.dist-info}/RECORD +9 -9
- {nucliadb-6.2.1.post2949.dist-info → nucliadb-6.2.1.post2954.dist-info}/WHEEL +0 -0
- {nucliadb-6.2.1.post2949.dist-info → nucliadb-6.2.1.post2954.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.2.1.post2949.dist-info → nucliadb-6.2.1.post2954.dist-info}/top_level.txt +0 -0
- {nucliadb-6.2.1.post2949.dist-info → nucliadb-6.2.1.post2954.dist-info}/zip-safe +0 -0
nucliadb/search/predict.py
CHANGED
@@ -121,12 +121,14 @@ class AnswerStatusCode(str, Enum):
|
|
121
121
|
SUCCESS = "0"
|
122
122
|
ERROR = "-1"
|
123
123
|
NO_CONTEXT = "-2"
|
124
|
+
NO_RETRIEVAL_DATA = "-3"
|
124
125
|
|
125
126
|
def prettify(self) -> str:
|
126
127
|
return {
|
127
128
|
AnswerStatusCode.SUCCESS: "success",
|
128
129
|
AnswerStatusCode.ERROR: "error",
|
129
130
|
AnswerStatusCode.NO_CONTEXT: "no_context",
|
131
|
+
AnswerStatusCode.NO_RETRIEVAL_DATA: "no_retrieval_data",
|
130
132
|
}[self]
|
131
133
|
|
132
134
|
|
@@ -49,6 +49,7 @@ from nucliadb.search.search.chat.query import (
|
|
49
49
|
ChatAuditor,
|
50
50
|
get_find_results,
|
51
51
|
get_relations_results,
|
52
|
+
maybe_audit_chat,
|
52
53
|
rephrase_query,
|
53
54
|
sorted_prompt_context_list,
|
54
55
|
tokens_to_chars,
|
@@ -433,14 +434,14 @@ class NotEnoughContextAskResult(AskResult):
|
|
433
434
|
"""
|
434
435
|
yield self._ndjson_encode(RetrievalAskResponseItem(results=self.main_results))
|
435
436
|
yield self._ndjson_encode(AnswerAskResponseItem(text=NOT_ENOUGH_CONTEXT_ANSWER))
|
436
|
-
status = AnswerStatusCode.
|
437
|
+
status = AnswerStatusCode.NO_RETRIEVAL_DATA
|
437
438
|
yield self._ndjson_encode(StatusAskResponseItem(code=status.value, status=status.prettify()))
|
438
439
|
|
439
440
|
async def json(self) -> str:
|
440
441
|
return SyncAskResponse(
|
441
442
|
answer=NOT_ENOUGH_CONTEXT_ANSWER,
|
442
443
|
retrieval_results=self.main_results,
|
443
|
-
status=AnswerStatusCode.
|
444
|
+
status=AnswerStatusCode.NO_RETRIEVAL_DATA.prettify(),
|
444
445
|
).model_dump_json()
|
445
446
|
|
446
447
|
|
@@ -487,6 +488,31 @@ async def ask(
|
|
487
488
|
resource=resource,
|
488
489
|
)
|
489
490
|
except NoRetrievalResultsError as err:
|
491
|
+
try:
|
492
|
+
rephrase_time = metrics.elapsed("rephrase")
|
493
|
+
except KeyError:
|
494
|
+
# Not all ask requests have a rephrase step
|
495
|
+
rephrase_time = None
|
496
|
+
|
497
|
+
maybe_audit_chat(
|
498
|
+
kbid=kbid,
|
499
|
+
user_id=user_id,
|
500
|
+
client_type=client_type,
|
501
|
+
origin=origin,
|
502
|
+
generative_answer_time=0,
|
503
|
+
generative_answer_first_chunk_time=0,
|
504
|
+
rephrase_time=rephrase_time,
|
505
|
+
user_query=user_query,
|
506
|
+
rephrased_query=rephrased_query,
|
507
|
+
text_answer=b"",
|
508
|
+
status_code=AnswerStatusCode.NO_RETRIEVAL_DATA,
|
509
|
+
chat_history=chat_history,
|
510
|
+
query_context={},
|
511
|
+
query_context_order={},
|
512
|
+
learning_id=None,
|
513
|
+
model=ask_request.generative_model,
|
514
|
+
)
|
515
|
+
|
490
516
|
# If a retrieval was attempted but no results were found,
|
491
517
|
# early return the ask endpoint without querying the generative model
|
492
518
|
return NotEnoughContextAskResult(
|
@@ -285,8 +285,8 @@ def maybe_audit_chat(
|
|
285
285
|
chat_history: list[ChatContextMessage],
|
286
286
|
query_context: PromptContext,
|
287
287
|
query_context_order: PromptContextOrder,
|
288
|
-
learning_id: str,
|
289
|
-
model: str,
|
288
|
+
learning_id: Optional[str],
|
289
|
+
model: Optional[str],
|
290
290
|
):
|
291
291
|
audit = get_audit()
|
292
292
|
if audit is None:
|
@@ -324,7 +324,7 @@ def maybe_audit_chat(
|
|
324
324
|
|
325
325
|
|
326
326
|
def parse_audit_answer(raw_text_answer: bytes, status_code: AnswerStatusCode) -> Optional[str]:
|
327
|
-
if status_code == AnswerStatusCode.NO_CONTEXT:
|
327
|
+
if status_code == AnswerStatusCode.NO_CONTEXT or status_code == AnswerStatusCode.NO_RETRIEVAL_DATA:
|
328
328
|
# We don't want to audit "Not enough context to answer this." and instead set a None.
|
329
329
|
return None
|
330
330
|
return raw_text_answer.decode()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.2.1.
|
3
|
+
Version: 6.2.1.post2954
|
4
4
|
Home-page: https://docs.nuclia.dev/docs/management/nucliadb/intro
|
5
5
|
Author: NucliaDB Community
|
6
6
|
Author-email: nucliadb@nuclia.com
|
@@ -22,10 +22,10 @@ Classifier: Programming Language :: Python :: 3.12
|
|
22
22
|
Classifier: Programming Language :: Python :: 3 :: Only
|
23
23
|
Requires-Python: >=3.9, <4
|
24
24
|
Description-Content-Type: text/markdown
|
25
|
-
Requires-Dist: nucliadb-telemetry[all]>=6.2.1.
|
26
|
-
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.
|
27
|
-
Requires-Dist: nucliadb-protos>=6.2.1.
|
28
|
-
Requires-Dist: nucliadb-models>=6.2.1.
|
25
|
+
Requires-Dist: nucliadb-telemetry[all]>=6.2.1.post2954
|
26
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post2954
|
27
|
+
Requires-Dist: nucliadb-protos>=6.2.1.post2954
|
28
|
+
Requires-Dist: nucliadb-models>=6.2.1.post2954
|
29
29
|
Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
|
30
30
|
Requires-Dist: nucliadb-node-binding>=2.26.0
|
31
31
|
Requires-Dist: nuclia-models>=0.24.2
|
@@ -189,7 +189,7 @@ nucliadb/search/__init__.py,sha256=tnypbqcH4nBHbGpkINudhKgdLKpwXQCvDtPchUlsyY4,1
|
|
189
189
|
nucliadb/search/app.py,sha256=6UV7rO0f3w5bNFXLdQM8bwUwXayMGnM4hF6GGv7WPv4,4260
|
190
190
|
nucliadb/search/lifecycle.py,sha256=DW8v4WUi4rZqc7xTOi3rE67W7877WG7fH9oTZbolHdE,2099
|
191
191
|
nucliadb/search/openapi.py,sha256=t3Wo_4baTrfPftg2BHsyLWNZ1MYn7ZRdW7ht-wFOgRs,1016
|
192
|
-
nucliadb/search/predict.py,sha256=
|
192
|
+
nucliadb/search/predict.py,sha256=Jan9hMsiIE5WEcyjHMA79Gz8-2pMbHbb8Kb3SgoXw8M,20897
|
193
193
|
nucliadb/search/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
194
194
|
nucliadb/search/run.py,sha256=aFb-CXRi_C8YMpP_ivNj8KW1BYhADj88y8K9Lr_nUPI,1402
|
195
195
|
nucliadb/search/settings.py,sha256=vem3EcyYlTPSim0kEK-xe-erF4BZg0CT_LAb8ZRQAE8,1684
|
@@ -234,11 +234,11 @@ nucliadb/search/search/shards.py,sha256=mM2aCHWhl_gwkCENXDShPukS-_qnB5tFS3UAJuzM
|
|
234
234
|
nucliadb/search/search/summarize.py,sha256=ksmYPubEQvAQgfPdZHfzB_rR19B2ci4IYZ6jLdHxZo8,4996
|
235
235
|
nucliadb/search/search/utils.py,sha256=iF2tbBA56gRMJH1TlE2hMrqeXqjoeOPt4KgRdp2m9Ek,3313
|
236
236
|
nucliadb/search/search/chat/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
237
|
-
nucliadb/search/search/chat/ask.py,sha256=
|
237
|
+
nucliadb/search/search/chat/ask.py,sha256=sopRYv2yyNUr-rSILpRm4rWI6exBQoGTaONhW1VBiVY,36008
|
238
238
|
nucliadb/search/search/chat/exceptions.py,sha256=Siy4GXW2L7oPhIR86H3WHBhE9lkV4A4YaAszuGGUf54,1356
|
239
239
|
nucliadb/search/search/chat/images.py,sha256=PA8VWxT5_HUGfW1ULhKTK46UBsVyINtWWqEM1ulzX1E,3095
|
240
240
|
nucliadb/search/search/chat/prompt.py,sha256=r2JTiRWH3YHPdeRAG5w6gD0g0fWVxdTjYIR86qAVa7k,47106
|
241
|
-
nucliadb/search/search/chat/query.py,sha256=
|
241
|
+
nucliadb/search/search/chat/query.py,sha256=EfZVJ_Nxo2Jwrbl4ICUL61srKv22PCPt1tZDXMZZQq4,15418
|
242
242
|
nucliadb/search/search/query_parser/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
243
243
|
nucliadb/search/search/query_parser/exceptions.py,sha256=tuzl7ZyvVsRz6u0_3zMe60vx39nd3pi641prs-5nC0E,872
|
244
244
|
nucliadb/search/search/query_parser/models.py,sha256=-VlCDXUCgOroAZw1Leqhj2VMgRv_CD2w40PXXOBLaUM,2332
|
@@ -340,9 +340,9 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
340
340
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
341
341
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
342
342
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
343
|
-
nucliadb-6.2.1.
|
344
|
-
nucliadb-6.2.1.
|
345
|
-
nucliadb-6.2.1.
|
346
|
-
nucliadb-6.2.1.
|
347
|
-
nucliadb-6.2.1.
|
348
|
-
nucliadb-6.2.1.
|
343
|
+
nucliadb-6.2.1.post2954.dist-info/METADATA,sha256=uqKCYU8MpuEtw2VE0oX1sX-WQTRD-ACMAf1jRBOO7P0,4689
|
344
|
+
nucliadb-6.2.1.post2954.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
345
|
+
nucliadb-6.2.1.post2954.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
346
|
+
nucliadb-6.2.1.post2954.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
347
|
+
nucliadb-6.2.1.post2954.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
348
|
+
nucliadb-6.2.1.post2954.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|