nuclia 4.9.2__tar.gz → 4.9.3__tar.gz

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.
Files changed (96) hide show
  1. {nuclia-4.9.2 → nuclia-4.9.3}/CHANGELOG.md +6 -0
  2. {nuclia-4.9.2 → nuclia-4.9.3}/PKG-INFO +1 -1
  3. nuclia-4.9.3/VERSION +1 -0
  4. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/lib/nua.py +15 -0
  5. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/lib/nua_responses.py +12 -0
  6. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/predict.py +24 -0
  7. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_nua/test_predict.py +16 -1
  8. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia.egg-info/PKG-INFO +1 -1
  9. nuclia-4.9.2/VERSION +0 -1
  10. {nuclia-4.9.2 → nuclia-4.9.3}/.gitignore +0 -0
  11. {nuclia-4.9.2 → nuclia-4.9.3}/LICENSE +0 -0
  12. {nuclia-4.9.2 → nuclia-4.9.3}/MANIFEST.in +0 -0
  13. {nuclia-4.9.2 → nuclia-4.9.3}/Makefile +0 -0
  14. {nuclia-4.9.2 → nuclia-4.9.3}/README.md +0 -0
  15. {nuclia-4.9.2 → nuclia-4.9.3}/docs/01-README.md +0 -0
  16. {nuclia-4.9.2 → nuclia-4.9.3}/docs/02-auth.md +0 -0
  17. {nuclia-4.9.2 → nuclia-4.9.3}/docs/03-kb.md +0 -0
  18. {nuclia-4.9.2 → nuclia-4.9.3}/docs/04-upload.md +0 -0
  19. {nuclia-4.9.2 → nuclia-4.9.3}/docs/05-search.md +0 -0
  20. {nuclia-4.9.2 → nuclia-4.9.3}/docs/06-read.md +0 -0
  21. {nuclia-4.9.2 → nuclia-4.9.3}/docs/07-nua.md +0 -0
  22. {nuclia-4.9.2 → nuclia-4.9.3}/docs/08-import-export.md +0 -0
  23. {nuclia-4.9.2 → nuclia-4.9.3}/docs/09-kb-backup.md +0 -0
  24. {nuclia-4.9.2 → nuclia-4.9.3}/docs/10-manage.md +0 -0
  25. {nuclia-4.9.2 → nuclia-4.9.3}/docs/11-activity-log.md +0 -0
  26. {nuclia-4.9.2 → nuclia-4.9.3}/docs/12-da-agents.md +0 -0
  27. {nuclia-4.9.2 → nuclia-4.9.3}/docs/13-ai-agents.md +0 -0
  28. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/__init__.py +0 -0
  29. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/cli/__init__.py +0 -0
  30. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/cli/run.py +0 -0
  31. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/cli/utils.py +0 -0
  32. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/config.py +0 -0
  33. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/data.py +0 -0
  34. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/decorators.py +0 -0
  35. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/exceptions.py +0 -0
  36. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/lib/__init__.py +0 -0
  37. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/lib/conversations.py +0 -0
  38. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/lib/kb.py +0 -0
  39. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/lib/models.py +0 -0
  40. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/lib/nua_chat.py +0 -0
  41. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/lib/utils.py +0 -0
  42. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/py.typed +0 -0
  43. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/__init__.py +0 -0
  44. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/accounts.py +0 -0
  45. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/agent.py +0 -0
  46. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/auth.py +0 -0
  47. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/backup.py +0 -0
  48. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/export_import.py +0 -0
  49. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/extract_strategy.py +0 -0
  50. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/kb.py +0 -0
  51. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/kbs.py +0 -0
  52. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/logger.py +0 -0
  53. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/logs.py +0 -0
  54. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/nua.py +0 -0
  55. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/nucliadb.py +0 -0
  56. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/process.py +0 -0
  57. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/remi.py +0 -0
  58. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/resource.py +0 -0
  59. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/search.py +0 -0
  60. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/task.py +0 -0
  61. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/upload.py +0 -0
  62. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/sdk/zones.py +0 -0
  63. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/__init__.py +0 -0
  64. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/assets/conversation.json +0 -0
  65. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/conftest.py +0 -0
  66. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/fixtures.py +0 -0
  67. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_backup.py +0 -0
  68. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_conversation.py +0 -0
  69. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_export_import.py +0 -0
  70. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_extract_strategies.py +0 -0
  71. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_graph.py +0 -0
  72. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_labels.py +0 -0
  73. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_logs.py +0 -0
  74. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_remi.py +0 -0
  75. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_resource.py +0 -0
  76. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_search.py +0 -0
  77. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_kb/test_tasks.py +0 -0
  78. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_manage/__init__.py +0 -0
  79. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_manage/test_account.py +0 -0
  80. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_manage/test_auth.py +0 -0
  81. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_manage/test_kb.py +0 -0
  82. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_nua/__init__.py +0 -0
  83. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_nua/test_agent.py +0 -0
  84. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_nucliadb/__init__.py +0 -0
  85. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/test_nucliadb/test_crud.py +0 -0
  86. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/unit/__init__.py +0 -0
  87. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/unit/test_export_import.py +0 -0
  88. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia/tests/unit/test_nua_responses.py +0 -0
  89. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia.egg-info/SOURCES.txt +0 -0
  90. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia.egg-info/dependency_links.txt +0 -0
  91. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia.egg-info/entry_points.txt +0 -0
  92. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia.egg-info/requires.txt +0 -0
  93. {nuclia-4.9.2 → nuclia-4.9.3}/nuclia.egg-info/top_level.txt +0 -0
  94. {nuclia-4.9.2 → nuclia-4.9.3}/pyproject.toml +0 -0
  95. {nuclia-4.9.2 → nuclia-4.9.3}/setup.cfg +0 -0
  96. {nuclia-4.9.2 → nuclia-4.9.3}/uv.lock +0 -0
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## 4.9.3 (2025-06-16)
5
+
6
+
7
+ - Add rerank funcion
8
+
9
+
4
10
  ## 4.9.2 (2025-06-12)
5
11
 
6
12
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nuclia
3
- Version: 4.9.2
3
+ Version: 4.9.3
4
4
  Summary: Nuclia Python SDK
5
5
  Author-email: Nuclia <info@nuclia.com>
6
6
  License-Expression: MIT
nuclia-4.9.3/VERSION ADDED
@@ -0,0 +1 @@
1
+ 4.9.3
@@ -42,6 +42,8 @@ from nuclia.lib.nua_responses import (
42
42
  PushResponseV2,
43
43
  QueryInfo,
44
44
  RephraseModel,
45
+ RerankModel,
46
+ RerankResponse,
45
47
  RestrictedIDString,
46
48
  Sentence,
47
49
  Source,
@@ -77,6 +79,7 @@ PUSH_PROCESS = "/api/v2/processing/push"
77
79
  SCHEMA = "/api/v1/learning/configuration/schema"
78
80
  SCHEMA_KBID = "/api/v1/schema"
79
81
  CONFIG = "/api/v1/config"
82
+ RERANK = "/api/v1/predict/rerank"
80
83
 
81
84
  ConvertType = TypeVar("ConvertType", bound=BaseModel)
82
85
 
@@ -410,6 +413,12 @@ class NuaClient:
410
413
  activity_endpoint = f"{self.url}{STATUS_PROCESS}/{process_id}"
411
414
  return self._request("GET", activity_endpoint, ProcessRequestStatus)
412
415
 
416
+ def rerank(self, model: RerankModel) -> RerankResponse:
417
+ endpoint = f"{self.url}{RERANK}"
418
+ return self._request(
419
+ "POST", endpoint, payload=model.model_dump(), output=RerankResponse
420
+ )
421
+
413
422
 
414
423
  class AsyncNuaClient:
415
424
  def __init__(
@@ -792,3 +801,9 @@ class AsyncNuaClient:
792
801
  return await self._request(
793
802
  "GET", activity_endpoint, output=ProcessRequestStatus
794
803
  )
804
+
805
+ async def rerank(self, model: RerankModel) -> RerankResponse:
806
+ endpoint = f"{self.url}{RERANK}"
807
+ return await self._request(
808
+ "POST", endpoint, payload=model.model_dump(), output=RerankResponse
809
+ )
@@ -557,3 +557,15 @@ class QueryInfo(BaseModel):
557
557
  max_context: int
558
558
  entities: Optional[TokenSearch]
559
559
  sentence: Optional[SentenceSearch]
560
+
561
+
562
+ class RerankModel(BaseModel):
563
+ question: str
564
+ user_id: str
565
+ context: dict[str, str] = {}
566
+
567
+
568
+ class RerankResponse(BaseModel):
569
+ context_scores: dict[str, float] = Field(
570
+ description="Scores for each context given by the reranker"
571
+ )
@@ -13,6 +13,8 @@ from nuclia.lib.nua_responses import (
13
13
  ConfigSchema,
14
14
  LearningConfigurationCreation,
15
15
  QueryInfo,
16
+ RerankModel,
17
+ RerankResponse,
16
18
  Sentence,
17
19
  StoredLearningConfiguration,
18
20
  SummarizedModel,
@@ -162,6 +164,17 @@ class NucliaPredict:
162
164
  nc: NuaClient = kwargs["nc"]
163
165
  return nc.remi(request)
164
166
 
167
+ @nua
168
+ def rerank(self, request: RerankModel, **kwargs) -> RerankResponse:
169
+ """
170
+ Perform a reranking of the results based on the question and context provided.
171
+
172
+ :param request: RerankModel
173
+ :return: RerankResponse
174
+ """
175
+ nc: NuaClient = kwargs["nc"]
176
+ return nc.rerank(request)
177
+
165
178
 
166
179
  class AsyncNucliaPredict:
167
180
  @property
@@ -299,3 +312,14 @@ class AsyncNucliaPredict:
299
312
 
300
313
  nc: AsyncNuaClient = kwargs["nc"]
301
314
  return await nc.remi(request)
315
+
316
+ @nua
317
+ async def rerank(self, request: RerankModel, **kwargs) -> RerankResponse:
318
+ """
319
+ Perform a reranking of the results based on the question and context provided.
320
+
321
+ :param request: RerankModel
322
+ :return: RerankResponse
323
+ """
324
+ nc: AsyncNuaClient = kwargs["nc"]
325
+ return await nc.rerank(request)
@@ -1,6 +1,6 @@
1
1
  from nuclia_models.predict.generative_responses import TextGenerativeResponse
2
2
 
3
- from nuclia.lib.nua_responses import ChatModel, UserPrompt
3
+ from nuclia.lib.nua_responses import ChatModel, RerankModel, UserPrompt
4
4
  from nuclia.sdk.predict import AsyncNucliaPredict, NucliaPredict
5
5
  import pytest
6
6
  from nuclia_models.predict.remi import RemiRequest
@@ -170,3 +170,18 @@ async def test_nua_async_remi(testing_config):
170
170
 
171
171
  assert results.context_relevance[1] < 2
172
172
  assert results.groundedness[1] < 2
173
+
174
+
175
+ def test_nua_rerank(testing_config):
176
+ np = NucliaPredict()
177
+ results = np.rerank(
178
+ RerankModel(
179
+ user_id="Nuclia PY CLI",
180
+ question="What is the capital of France?",
181
+ context={
182
+ "1": "Paris is the capital of France.",
183
+ "2": "Berlin is the capital of Germany.",
184
+ },
185
+ )
186
+ )
187
+ assert results.context_scores["1"] > results.context_scores["2"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nuclia
3
- Version: 4.9.2
3
+ Version: 4.9.3
4
4
  Summary: Nuclia Python SDK
5
5
  Author-email: Nuclia <info@nuclia.com>
6
6
  License-Expression: MIT
nuclia-4.9.2/VERSION DELETED
@@ -1 +0,0 @@
1
- 4.9.2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes