nucliadb 6.2.0.post2628__py3-none-any.whl → 6.2.0.post2641__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 +3 -49
- nucliadb/search/search/chat/ask.py +12 -6
- {nucliadb-6.2.0.post2628.dist-info → nucliadb-6.2.0.post2641.dist-info}/METADATA +6 -5
- {nucliadb-6.2.0.post2628.dist-info → nucliadb-6.2.0.post2641.dist-info}/RECORD +8 -8
- {nucliadb-6.2.0.post2628.dist-info → nucliadb-6.2.0.post2641.dist-info}/WHEEL +0 -0
- {nucliadb-6.2.0.post2628.dist-info → nucliadb-6.2.0.post2641.dist-info}/entry_points.txt +0 -0
- {nucliadb-6.2.0.post2628.dist-info → nucliadb-6.2.0.post2641.dist-info}/top_level.txt +0 -0
- {nucliadb-6.2.0.post2628.dist-info → nucliadb-6.2.0.post2641.dist-info}/zip-safe +0 -0
nucliadb/search/predict.py
CHANGED
@@ -21,12 +21,13 @@ import json
|
|
21
21
|
import os
|
22
22
|
import random
|
23
23
|
from enum import Enum
|
24
|
-
from typing import Any, AsyncIterator,
|
24
|
+
from typing import Any, AsyncIterator, Optional
|
25
25
|
from unittest.mock import AsyncMock, Mock
|
26
26
|
|
27
27
|
import aiohttp
|
28
28
|
import backoff
|
29
|
-
from
|
29
|
+
from nuclia_models.predict.generative_responses import GenerativeChunk
|
30
|
+
from pydantic import ValidationError
|
30
31
|
|
31
32
|
from nucliadb.common import datamanagers
|
32
33
|
from nucliadb.search import logger
|
@@ -129,53 +130,6 @@ class AnswerStatusCode(str, Enum):
|
|
129
130
|
}[self]
|
130
131
|
|
131
132
|
|
132
|
-
class TextGenerativeResponse(BaseModel):
|
133
|
-
type: Literal["text"] = "text"
|
134
|
-
text: str
|
135
|
-
|
136
|
-
|
137
|
-
class JSONGenerativeResponse(BaseModel):
|
138
|
-
type: Literal["object"] = "object"
|
139
|
-
object: Dict[str, Any]
|
140
|
-
|
141
|
-
|
142
|
-
class MetaGenerativeResponse(BaseModel):
|
143
|
-
type: Literal["meta"] = "meta"
|
144
|
-
input_tokens: int
|
145
|
-
output_tokens: int
|
146
|
-
timings: dict[str, float]
|
147
|
-
|
148
|
-
|
149
|
-
class CitationsGenerativeResponse(BaseModel):
|
150
|
-
type: Literal["citations"] = "citations"
|
151
|
-
citations: dict[str, Any]
|
152
|
-
|
153
|
-
|
154
|
-
class RerankGenerativeResponse(BaseModel):
|
155
|
-
type: Literal["rerank"] = "rerank"
|
156
|
-
context_scores: Dict[str, float]
|
157
|
-
|
158
|
-
|
159
|
-
class StatusGenerativeResponse(BaseModel):
|
160
|
-
type: Literal["status"] = "status"
|
161
|
-
code: str
|
162
|
-
details: Optional[str] = None
|
163
|
-
|
164
|
-
|
165
|
-
GenerativeResponse = Union[
|
166
|
-
TextGenerativeResponse,
|
167
|
-
JSONGenerativeResponse,
|
168
|
-
MetaGenerativeResponse,
|
169
|
-
CitationsGenerativeResponse,
|
170
|
-
RerankGenerativeResponse,
|
171
|
-
StatusGenerativeResponse,
|
172
|
-
]
|
173
|
-
|
174
|
-
|
175
|
-
class GenerativeChunk(BaseModel):
|
176
|
-
chunk: GenerativeResponse = Field(..., discriminator="type")
|
177
|
-
|
178
|
-
|
179
133
|
async def start_predict_engine():
|
180
134
|
if nuclia_settings.dummy_predict:
|
181
135
|
predict_util = DummyPredictEngine()
|
@@ -22,6 +22,14 @@ import functools
|
|
22
22
|
import json
|
23
23
|
from typing import AsyncGenerator, Optional, cast
|
24
24
|
|
25
|
+
from nuclia_models.predict.generative_responses import (
|
26
|
+
CitationsGenerativeResponse,
|
27
|
+
GenerativeChunk,
|
28
|
+
JSONGenerativeResponse,
|
29
|
+
MetaGenerativeResponse,
|
30
|
+
StatusGenerativeResponse,
|
31
|
+
TextGenerativeResponse,
|
32
|
+
)
|
25
33
|
from pydantic_core import ValidationError
|
26
34
|
|
27
35
|
from nucliadb.common.datamanagers.exceptions import KnowledgeBoxNotFound
|
@@ -29,13 +37,7 @@ from nucliadb.models.responses import HTTPClientError
|
|
29
37
|
from nucliadb.search import logger, predict
|
30
38
|
from nucliadb.search.predict import (
|
31
39
|
AnswerStatusCode,
|
32
|
-
CitationsGenerativeResponse,
|
33
|
-
GenerativeChunk,
|
34
|
-
JSONGenerativeResponse,
|
35
|
-
MetaGenerativeResponse,
|
36
40
|
RephraseMissingContextError,
|
37
|
-
StatusGenerativeResponse,
|
38
|
-
TextGenerativeResponse,
|
39
41
|
)
|
40
42
|
from nucliadb.search.search.chat.exceptions import (
|
41
43
|
AnswerJsonSchemaTooLong,
|
@@ -277,6 +279,8 @@ class AskResult:
|
|
277
279
|
tokens=AskTokens(
|
278
280
|
input=self._metadata.input_tokens,
|
279
281
|
output=self._metadata.output_tokens,
|
282
|
+
input_nuclia=self._metadata.input_nuclia_tokens,
|
283
|
+
output_nuclia=self._metadata.output_nuclia_tokens,
|
280
284
|
),
|
281
285
|
timings=AskTimings(
|
282
286
|
generative_first_chunk=self._metadata.timings.get("generative_first_chunk"),
|
@@ -317,6 +321,8 @@ class AskResult:
|
|
317
321
|
tokens=AskTokens(
|
318
322
|
input=self._metadata.input_tokens,
|
319
323
|
output=self._metadata.output_tokens,
|
324
|
+
input_nuclia=self._metadata.input_nuclia_tokens,
|
325
|
+
output_nuclia=self._metadata.output_nuclia_tokens,
|
320
326
|
),
|
321
327
|
timings=AskTimings(
|
322
328
|
generative_first_chunk=self._metadata.timings.get("generative_first_chunk"),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nucliadb
|
3
|
-
Version: 6.2.0.
|
3
|
+
Version: 6.2.0.post2641
|
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,12 +22,13 @@ 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.0.
|
26
|
-
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.0.
|
27
|
-
Requires-Dist: nucliadb-protos>=6.2.0.
|
28
|
-
Requires-Dist: nucliadb-models>=6.2.0.
|
25
|
+
Requires-Dist: nucliadb-telemetry[all]>=6.2.0.post2641
|
26
|
+
Requires-Dist: nucliadb-utils[cache,fastapi,storages]>=6.2.0.post2641
|
27
|
+
Requires-Dist: nucliadb-protos>=6.2.0.post2641
|
28
|
+
Requires-Dist: nucliadb-models>=6.2.0.post2641
|
29
29
|
Requires-Dist: nucliadb-admin-assets>=1.0.0.post1224
|
30
30
|
Requires-Dist: nucliadb-node-binding>=2.26.0
|
31
|
+
Requires-Dist: nuclia-models>=0.24.2
|
31
32
|
Requires-Dist: uvicorn
|
32
33
|
Requires-Dist: argdantic
|
33
34
|
Requires-Dist: aiohttp>=3.9.4
|
@@ -184,7 +184,7 @@ nucliadb/search/__init__.py,sha256=tnypbqcH4nBHbGpkINudhKgdLKpwXQCvDtPchUlsyY4,1
|
|
184
184
|
nucliadb/search/app.py,sha256=6UV7rO0f3w5bNFXLdQM8bwUwXayMGnM4hF6GGv7WPv4,4260
|
185
185
|
nucliadb/search/lifecycle.py,sha256=DW8v4WUi4rZqc7xTOi3rE67W7877WG7fH9oTZbolHdE,2099
|
186
186
|
nucliadb/search/openapi.py,sha256=t3Wo_4baTrfPftg2BHsyLWNZ1MYn7ZRdW7ht-wFOgRs,1016
|
187
|
-
nucliadb/search/predict.py,sha256=
|
187
|
+
nucliadb/search/predict.py,sha256=AB8E5epRR_aUsfKYfWw96WsrJUAdalZE4uolkrTor8Q,20799
|
188
188
|
nucliadb/search/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
189
189
|
nucliadb/search/run.py,sha256=aFb-CXRi_C8YMpP_ivNj8KW1BYhADj88y8K9Lr_nUPI,1402
|
190
190
|
nucliadb/search/settings.py,sha256=vem3EcyYlTPSim0kEK-xe-erF4BZg0CT_LAb8ZRQAE8,1684
|
@@ -228,7 +228,7 @@ nucliadb/search/search/shards.py,sha256=mM2aCHWhl_gwkCENXDShPukS-_qnB5tFS3UAJuzM
|
|
228
228
|
nucliadb/search/search/summarize.py,sha256=ksmYPubEQvAQgfPdZHfzB_rR19B2ci4IYZ6jLdHxZo8,4996
|
229
229
|
nucliadb/search/search/utils.py,sha256=iF2tbBA56gRMJH1TlE2hMrqeXqjoeOPt4KgRdp2m9Ek,3313
|
230
230
|
nucliadb/search/search/chat/__init__.py,sha256=cp15ZcFnHvpcu_5-aK2A4uUyvuZVV_MJn4bIXMa20ks,835
|
231
|
-
nucliadb/search/search/chat/ask.py,sha256=
|
231
|
+
nucliadb/search/search/chat/ask.py,sha256=_emhBlraFGsScWOmEbc8MbYi-aES9XZ1NnhSXR_79qQ,34138
|
232
232
|
nucliadb/search/search/chat/exceptions.py,sha256=Siy4GXW2L7oPhIR86H3WHBhE9lkV4A4YaAszuGGUf54,1356
|
233
233
|
nucliadb/search/search/chat/images.py,sha256=PA8VWxT5_HUGfW1ULhKTK46UBsVyINtWWqEM1ulzX1E,3095
|
234
234
|
nucliadb/search/search/chat/prompt.py,sha256=TIzjI_882hJ--KLKCY8rJomtJ_CMJ-MHYtHqivgG8Lk,46819
|
@@ -332,9 +332,9 @@ nucliadb/writer/tus/local.py,sha256=7jYa_w9b-N90jWgN2sQKkNcomqn6JMVBOVeDOVYJHto,
|
|
332
332
|
nucliadb/writer/tus/s3.py,sha256=vF0NkFTXiXhXq3bCVXXVV-ED38ECVoUeeYViP8uMqcU,8357
|
333
333
|
nucliadb/writer/tus/storage.py,sha256=ToqwjoYnjI4oIcwzkhha_MPxi-k4Jk3Lt55zRwaC1SM,2903
|
334
334
|
nucliadb/writer/tus/utils.py,sha256=MSdVbRsRSZVdkaum69_0wku7X3p5wlZf4nr6E0GMKbw,2556
|
335
|
-
nucliadb-6.2.0.
|
336
|
-
nucliadb-6.2.0.
|
337
|
-
nucliadb-6.2.0.
|
338
|
-
nucliadb-6.2.0.
|
339
|
-
nucliadb-6.2.0.
|
340
|
-
nucliadb-6.2.0.
|
335
|
+
nucliadb-6.2.0.post2641.dist-info/METADATA,sha256=hCWziXx2FVVb8yak6nV1LthM7FBdy-XHBR6vQ7wbGh8,4427
|
336
|
+
nucliadb-6.2.0.post2641.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
337
|
+
nucliadb-6.2.0.post2641.dist-info/entry_points.txt,sha256=XqGfgFDuY3zXQc8ewXM2TRVjTModIq851zOsgrmaXx4,1268
|
338
|
+
nucliadb-6.2.0.post2641.dist-info/top_level.txt,sha256=hwYhTVnX7jkQ9gJCkVrbqEG1M4lT2F_iPQND1fCzF80,20
|
339
|
+
nucliadb-6.2.0.post2641.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
340
|
+
nucliadb-6.2.0.post2641.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|