nucliadb 6.2.1.post2954__py3-none-any.whl → 6.2.1.post2971__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 +4 -4
- nucliadb/search/search/chat/ask.py +18 -11
- nucliadb/search/search/chat/query.py +1 -1
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2971.dist-info}/METADATA +5 -5
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2971.dist-info}/RECORD +9 -9
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2971.dist-info}/WHEEL +0 -0
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2971.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2971.dist-info}/top_level.txt +0 -0
- {nucliadb-6.2.1.post2954.dist-info → nucliadb-6.2.1.post2971.dist-info}/zip-safe +0 -0
nucliadb/search/predict.py
CHANGED
@@ -21,7 +21,7 @@ import json
|
|
21
21
|
import os
|
22
22
|
import random
|
23
23
|
from enum import Enum
|
24
|
-
from typing import Any,
|
24
|
+
from typing import Any, AsyncGenerator, Optional
|
25
25
|
from unittest.mock import AsyncMock, Mock
|
26
26
|
|
27
27
|
import aiohttp
|
@@ -268,7 +268,7 @@ class PredictEngine:
|
|
268
268
|
@predict_observer.wrap({"type": "chat_ndjson"})
|
269
269
|
async def chat_query_ndjson(
|
270
270
|
self, kbid: str, item: ChatModel
|
271
|
-
) -> tuple[str, str,
|
271
|
+
) -> tuple[str, str, AsyncGenerator[GenerativeChunk, None]]:
|
272
272
|
"""
|
273
273
|
Chat query using the new stream format
|
274
274
|
Format specs: https://github.com/ndjson/ndjson-spec
|
@@ -444,7 +444,7 @@ class DummyPredictEngine(PredictEngine):
|
|
444
444
|
|
445
445
|
async def chat_query_ndjson(
|
446
446
|
self, kbid: str, item: ChatModel
|
447
|
-
) -> tuple[str, str,
|
447
|
+
) -> tuple[str, str, AsyncGenerator[GenerativeChunk, None]]:
|
448
448
|
self.calls.append(("chat_query_ndjson", item))
|
449
449
|
|
450
450
|
async def generate():
|
@@ -555,7 +555,7 @@ def get_answer_generator(response: aiohttp.ClientResponse):
|
|
555
555
|
|
556
556
|
def get_chat_ndjson_generator(
|
557
557
|
response: aiohttp.ClientResponse,
|
558
|
-
) ->
|
558
|
+
) -> AsyncGenerator[GenerativeChunk, None]:
|
559
559
|
async def _parse_generative_chunks(gen):
|
560
560
|
async for chunk in gen:
|
561
561
|
try:
|
@@ -129,7 +129,7 @@ class AskResult:
|
|
129
129
|
main_results: KnowledgeboxFindResults,
|
130
130
|
prequeries_results: Optional[list[PreQueryResult]],
|
131
131
|
nuclia_learning_id: Optional[str],
|
132
|
-
predict_answer_stream: AsyncGenerator[GenerativeChunk, None],
|
132
|
+
predict_answer_stream: Optional[AsyncGenerator[GenerativeChunk, None]],
|
133
133
|
prompt_context: PromptContext,
|
134
134
|
prompt_context_order: PromptContextOrder,
|
135
135
|
auditor: ChatAuditor,
|
@@ -396,6 +396,9 @@ class AskResult:
|
|
396
396
|
This method does not assume any order in the stream of items, but it assumes that at least
|
397
397
|
the answer text is streamed in order.
|
398
398
|
"""
|
399
|
+
if self.predict_answer_stream is None:
|
400
|
+
# In some cases, clients may want to skip the answer generation step
|
401
|
+
return
|
399
402
|
async for generative_chunk in self.predict_answer_stream:
|
400
403
|
item = generative_chunk.chunk
|
401
404
|
if isinstance(item, TextGenerativeResponse):
|
@@ -562,14 +565,18 @@ async def ask(
|
|
562
565
|
rerank_context=False,
|
563
566
|
top_k=ask_request.top_k,
|
564
567
|
)
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
568
|
+
|
569
|
+
nuclia_learning_id = None
|
570
|
+
nuclia_learning_model = None
|
571
|
+
predict_answer_stream = None
|
572
|
+
if ask_request.generate_answer:
|
573
|
+
with metrics.time("stream_start"):
|
574
|
+
predict = get_predict()
|
575
|
+
(
|
576
|
+
nuclia_learning_id,
|
577
|
+
nuclia_learning_model,
|
578
|
+
predict_answer_stream,
|
579
|
+
) = await predict.chat_query_ndjson(kbid, chat_model)
|
573
580
|
|
574
581
|
auditor = ChatAuditor(
|
575
582
|
kbid=kbid,
|
@@ -590,13 +597,13 @@ async def ask(
|
|
590
597
|
main_results=retrieval_results.main_query,
|
591
598
|
prequeries_results=retrieval_results.prequeries,
|
592
599
|
nuclia_learning_id=nuclia_learning_id,
|
593
|
-
predict_answer_stream=predict_answer_stream,
|
600
|
+
predict_answer_stream=predict_answer_stream,
|
594
601
|
prompt_context=prompt_context,
|
595
602
|
prompt_context_order=prompt_context_order,
|
596
603
|
auditor=auditor,
|
597
604
|
metrics=metrics,
|
598
605
|
best_matches=retrieval_results.best_matches,
|
599
|
-
debug_chat_model=
|
606
|
+
debug_chat_model=chat_model,
|
600
607
|
)
|
601
608
|
|
602
609
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.2.1.
|
3
|
+
Version: 6.2.1.post2971
|
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.post2971
|
26
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.1.post2971
|
27
|
+
Requires-Dist: nucliadb-protos>=6.2.1.post2971
|
28
|
+
Requires-Dist: nucliadb-models>=6.2.1.post2971
|
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=EWOiWVUX9U_TE19Cl6bpCr6Mjs7hjuvCcG26C7e6KnQ,20919
|
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=tE1Q5V58oLMCo-T9s0N6Kko-1RWn1e4kHfbbPBsD2uU,36266
|
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=y7W5VuKl1XiZuNsxZIcxxHcFXSG6It2W5CoftZ-ekAc,15428
|
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.post2971.dist-info/METADATA,sha256=Ftcrf80Q8tp56jdibzPDOdTJq2jG0aEGuC-bMD-4418,4689
|
344
|
+
nucliadb-6.2.1.post2971.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
345
|
+
nucliadb-6.2.1.post2971.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
346
|
+
nucliadb-6.2.1.post2971.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
347
|
+
nucliadb-6.2.1.post2971.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
348
|
+
nucliadb-6.2.1.post2971.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|