nuclia 4.8.6__py3-none-any.whl → 4.8.8__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.
- nuclia/cli/run.py +4 -5
- nuclia/lib/nua.py +34 -4
- nuclia/lib/nua_responses.py +3 -3
- nuclia/tests/test_kb/test_search.py +1 -1
- {nuclia-4.8.6.dist-info → nuclia-4.8.8.dist-info}/METADATA +2 -2
- {nuclia-4.8.6.dist-info → nuclia-4.8.8.dist-info}/RECORD +10 -10
- {nuclia-4.8.6.dist-info → nuclia-4.8.8.dist-info}/WHEEL +0 -0
- {nuclia-4.8.6.dist-info → nuclia-4.8.8.dist-info}/entry_points.txt +0 -0
- {nuclia-4.8.6.dist-info → nuclia-4.8.8.dist-info}/licenses/LICENSE +0 -0
- {nuclia-4.8.6.dist-info → nuclia-4.8.8.dist-info}/top_level.txt +0 -0
nuclia/cli/run.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import logging
|
2
2
|
import sys
|
3
|
-
from
|
3
|
+
from importlib.metadata import version
|
4
4
|
|
5
5
|
import fire # type: ignore
|
6
6
|
from nucliadb_sdk import exceptions
|
@@ -9,12 +9,13 @@ from nuclia.data import get_auth
|
|
9
9
|
from nuclia.exceptions import NeedUserToken, UserTokenExpired
|
10
10
|
from nuclia.lib.utils import serialize
|
11
11
|
from nuclia.sdk.accounts import NucliaAccounts
|
12
|
+
from nuclia.sdk.backup import NucliaBackup
|
12
13
|
from nuclia.sdk.kb import NucliaKB
|
13
14
|
from nuclia.sdk.kbs import NucliaKBS
|
14
|
-
from nuclia.sdk.backup import NucliaBackup
|
15
15
|
from nuclia.sdk.logger import logger
|
16
16
|
from nuclia.sdk.nua import NucliaNUA
|
17
17
|
from nuclia.sdk.zones import NucliaZones
|
18
|
+
|
18
19
|
from .utils import CustomFormatter
|
19
20
|
|
20
21
|
|
@@ -30,9 +31,7 @@ class NucliaCLI(object):
|
|
30
31
|
|
31
32
|
def version(self):
|
32
33
|
"""Print the version of the CLI"""
|
33
|
-
|
34
|
-
VERSION = _dir.joinpath("VERSION").open().read().strip()
|
35
|
-
return VERSION
|
34
|
+
return version("nuclia")
|
36
35
|
|
37
36
|
|
38
37
|
def run():
|
nuclia/lib/nua.py
CHANGED
@@ -26,6 +26,7 @@ from nuclia_models.predict.generative_responses import (
|
|
26
26
|
CitationsGenerativeResponse,
|
27
27
|
MetaGenerativeResponse,
|
28
28
|
StatusGenerativeResponse,
|
29
|
+
ToolsGenerativeResponse,
|
29
30
|
)
|
30
31
|
from nuclia.lib.nua_responses import (
|
31
32
|
ChatModel,
|
@@ -55,6 +56,8 @@ import os
|
|
55
56
|
from tqdm import tqdm
|
56
57
|
import asyncio
|
57
58
|
from nuclia.lib.utils import build_httpx_client, build_httpx_async_client
|
59
|
+
from pydantic import ValidationError
|
60
|
+
|
58
61
|
|
59
62
|
if TYPE_CHECKING:
|
60
63
|
from nucliadb_protos.writer_pb2 import BrokerMessage
|
@@ -146,8 +149,19 @@ class NuaClient:
|
|
146
149
|
json=payload,
|
147
150
|
timeout=timeout,
|
148
151
|
) as response:
|
149
|
-
|
150
|
-
|
152
|
+
if response.headers.get("content-type") == "application/x-ndjson":
|
153
|
+
for json_body in response.iter_lines():
|
154
|
+
try:
|
155
|
+
yield GenerativeChunk.model_validate_json(json_body) # type: ignore
|
156
|
+
except ValidationError as e:
|
157
|
+
raise RuntimeError(f"Invalid stream chunk: {json_body}") from e
|
158
|
+
|
159
|
+
else:
|
160
|
+
# Read the full error body and raise an appropriate exception
|
161
|
+
error_content = response.content
|
162
|
+
raise RuntimeError(
|
163
|
+
f"Stream request failed with status {response.status_code}: {error_content.decode('utf-8')}"
|
164
|
+
)
|
151
165
|
|
152
166
|
def add_config_predict(self, kbid: str, config: LearningConfigurationCreation):
|
153
167
|
endpoint = f"{self.url}{CONFIG}/{kbid}"
|
@@ -233,6 +247,8 @@ class NuaClient:
|
|
233
247
|
result.citations = chunk.chunk.citations
|
234
248
|
elif isinstance(chunk.chunk, StatusGenerativeResponse):
|
235
249
|
result.code = chunk.chunk.code
|
250
|
+
elif isinstance(chunk.chunk, ToolsGenerativeResponse):
|
251
|
+
result.tools = chunk.chunk.tools
|
236
252
|
return result
|
237
253
|
|
238
254
|
def generate_stream(
|
@@ -453,8 +469,19 @@ class AsyncNuaClient:
|
|
453
469
|
json=payload,
|
454
470
|
timeout=timeout,
|
455
471
|
) as response:
|
456
|
-
|
457
|
-
|
472
|
+
if response.headers.get("content-type") == "application/x-ndjson":
|
473
|
+
async for json_body in response.aiter_lines():
|
474
|
+
try:
|
475
|
+
yield GenerativeChunk.model_validate_json(json_body) # type: ignore
|
476
|
+
except ValidationError as e:
|
477
|
+
raise RuntimeError(f"Invalid stream chunk: {json_body}") from e
|
478
|
+
|
479
|
+
else:
|
480
|
+
# Read the full error body and raise an appropriate exception
|
481
|
+
error_content = await response.aread()
|
482
|
+
raise RuntimeError(
|
483
|
+
f"Stream request failed with status {response.status_code}: {error_content.decode('utf-8')}"
|
484
|
+
)
|
458
485
|
|
459
486
|
async def add_config_predict(
|
460
487
|
self, kbid: str, config: LearningConfigurationCreation
|
@@ -564,6 +591,9 @@ class AsyncNuaClient:
|
|
564
591
|
result.citations = chunk.chunk.citations
|
565
592
|
elif isinstance(chunk.chunk, StatusGenerativeResponse):
|
566
593
|
result.code = chunk.chunk.code
|
594
|
+
elif isinstance(chunk.chunk, ToolsGenerativeResponse):
|
595
|
+
result.tools = chunk.chunk.tools
|
596
|
+
|
567
597
|
return result
|
568
598
|
|
569
599
|
async def generate_stream(
|
nuclia/lib/nua_responses.py
CHANGED
@@ -120,10 +120,10 @@ class ChatModel(BaseModel):
|
|
120
120
|
raise ValueError("Can not setup markdown and JSON Schema at the same time")
|
121
121
|
if self.citations is True and self.json_schema is not None:
|
122
122
|
raise ValueError("Can not setup citations and JSON Schema at the same time")
|
123
|
-
if self.citations is True and self.tools
|
123
|
+
if self.citations is True and len(self.tools) > 0:
|
124
124
|
raise ValueError("Can not setup citations and Tools at the same time")
|
125
|
-
if self.tools
|
126
|
-
raise ValueError("Can not setup
|
125
|
+
if len(self.tools) > 0 and self.json_schema is not None:
|
126
|
+
raise ValueError("Can not setup Tools and JSON Schema at the same time")
|
127
127
|
return self
|
128
128
|
|
129
129
|
|
@@ -69,7 +69,7 @@ def test_search(testing_config):
|
|
69
69
|
def test_catalog(testing_config):
|
70
70
|
search = NucliaSearch()
|
71
71
|
results = search.catalog()
|
72
|
-
assert len(results.resources.keys())
|
72
|
+
assert len(results.resources.keys()) >= 2
|
73
73
|
|
74
74
|
|
75
75
|
def test_search_object(testing_config):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nuclia
|
3
|
-
Version: 4.8.
|
3
|
+
Version: 4.8.8
|
4
4
|
Summary: Nuclia Python SDK
|
5
5
|
Author-email: Nuclia <info@nuclia.com>
|
6
6
|
License-Expression: MIT
|
@@ -26,7 +26,7 @@ Requires-Dist: httpcore>=1.0.0
|
|
26
26
|
Requires-Dist: prompt_toolkit
|
27
27
|
Requires-Dist: nucliadb_sdk<7,>=6.4
|
28
28
|
Requires-Dist: nucliadb_models<7,>=6.4
|
29
|
-
Requires-Dist: nuclia-models>=0.
|
29
|
+
Requires-Dist: nuclia-models>=0.38.1
|
30
30
|
Requires-Dist: tqdm
|
31
31
|
Requires-Dist: aiofiles
|
32
32
|
Requires-Dist: backoff
|
@@ -5,15 +5,15 @@ nuclia/decorators.py,sha256=GUhGDSrNtQ3DHpgsFArVJXpjykbDpi-Y8XRV5Vm4r6I,9879
|
|
5
5
|
nuclia/exceptions.py,sha256=5nuWelyxjV7-oDJUnYRgIw_gnDnRUzJxvtXrAknV7So,748
|
6
6
|
nuclia/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
nuclia/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
nuclia/cli/run.py,sha256=
|
8
|
+
nuclia/cli/run.py,sha256=B1hP0upSbSCqqT89WAwsd93ZxkAoF6ajVyLOdYmo8fU,1560
|
9
9
|
nuclia/cli/utils.py,sha256=iZ3P8juBdAGvaRUd2BGz7bpUXNDHdPrC5p876yyZ2Cs,1223
|
10
10
|
nuclia/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
nuclia/lib/conversations.py,sha256=M6qhL9NPEKroYF767S-Q2XWokRrjX02kpYTzRvZKwUE,149
|
12
12
|
nuclia/lib/kb.py,sha256=98zpJ8Dp4rQYMNKm4nhpOms3PY-PFOd8acNgDmBud-o,31819
|
13
13
|
nuclia/lib/models.py,sha256=lO3TZa4jTQ6C8ptGO1oX-5pxDgv8ocO13z7j5jXOC0Y,1554
|
14
|
-
nuclia/lib/nua.py,sha256=
|
14
|
+
nuclia/lib/nua.py,sha256=sUVFdCjvLigTqUUhILywdHpiC0qKCtKPABn5kUXfuxQ,27064
|
15
15
|
nuclia/lib/nua_chat.py,sha256=ApL1Y1FWvAVUt-Y9a_8TUSJIhg8-UmBSy8TlDPn6tD8,3874
|
16
|
-
nuclia/lib/nua_responses.py,sha256=
|
16
|
+
nuclia/lib/nua_responses.py,sha256=9WRGpvvhA2ZOyOv9kzX1zI7C3ypM8ySqciVYCSibUjo,12724
|
17
17
|
nuclia/lib/utils.py,sha256=XAVRRICPem-qOIEcssqDuv-vqD-9PICk6Iuj6DK5GKk,4808
|
18
18
|
nuclia/sdk/__init__.py,sha256=-nAw8i53XBdmbfTa1FJZ0FNRMNakimDVpD6W4OdES-c,1374
|
19
19
|
nuclia/sdk/accounts.py,sha256=7XQ3K9_jlSuk2Cez868FtazZ05xSGab6h3Mt1qMMwIE,647
|
@@ -47,7 +47,7 @@ nuclia/tests/test_kb/test_labels.py,sha256=IUdTq4mzv0OrOkwBWWy4UwKGKyJybtoHrgvXr
|
|
47
47
|
nuclia/tests/test_kb/test_logs.py,sha256=Iw0v-R5QLlfHKxL8roPeOQKjTylgpYgot0wG4vsXQTE,2609
|
48
48
|
nuclia/tests/test_kb/test_remi.py,sha256=OX5N-MHbgcwpLg6fBjrAK_KhqkMspJo_VKQHCBCayZ8,2080
|
49
49
|
nuclia/tests/test_kb/test_resource.py,sha256=05Xgmg5fwcPW2PZKnUSSjr6MPXp5w8XDgx8plfNcR68,1102
|
50
|
-
nuclia/tests/test_kb/test_search.py,sha256=
|
50
|
+
nuclia/tests/test_kb/test_search.py,sha256=bsQhfB6-NYFwY3gqkrVJJnru153UgZqEhV22ho4VeWM,4660
|
51
51
|
nuclia/tests/test_kb/test_tasks.py,sha256=tfJl1js2o0_dKyXdOxiwdj929kbzMkfl5XjO8HVMInQ,3456
|
52
52
|
nuclia/tests/test_manage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
53
|
nuclia/tests/test_manage/test_account.py,sha256=u9NhRK8gJLS7BEY618aGoYoV2rgDLHZUeSsWWYkDhF8,289
|
@@ -61,9 +61,9 @@ nuclia/tests/test_nucliadb/test_crud.py,sha256=GuY76HRvt2DFaNgioKm5n0Aco1HnG7zzV
|
|
61
61
|
nuclia/tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
62
62
|
nuclia/tests/unit/test_export_import.py,sha256=xo_wVbjUnNlVV65ZGH7LtZ38qy39EkJp2hjOuTHC1nU,980
|
63
63
|
nuclia/tests/unit/test_nua_responses.py,sha256=t_hIdVztTi27RWvpfTJUYcCL0lpKdZFegZIwLdaPNh8,319
|
64
|
-
nuclia-4.8.
|
65
|
-
nuclia-4.8.
|
66
|
-
nuclia-4.8.
|
67
|
-
nuclia-4.8.
|
68
|
-
nuclia-4.8.
|
69
|
-
nuclia-4.8.
|
64
|
+
nuclia-4.8.8.dist-info/licenses/LICENSE,sha256=Ops2LTti_HJtpmWcanuUTdTY3vKDR1myJ0gmGBKC0FA,1063
|
65
|
+
nuclia-4.8.8.dist-info/METADATA,sha256=EI0YpmuSdlgl0IM4hDq9C0DJSW7mgmFoIzYz2KQh-Qo,2337
|
66
|
+
nuclia-4.8.8.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
67
|
+
nuclia-4.8.8.dist-info/entry_points.txt,sha256=iZHOyXPNS54r3eQmdi5So20xO1gudI9K2oP4sQsCJRw,46
|
68
|
+
nuclia-4.8.8.dist-info/top_level.txt,sha256=cqn_EitXOoXOSUvZnd4q6QGrhm04pg8tLAZtem-Zfdo,7
|
69
|
+
nuclia-4.8.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|