nucliadb-agentic-api 1.0.0.post216__tar.gz → 1.0.0.post226__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.
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/PKG-INFO +1 -1
- nucliadb_agentic_api-1.0.0.post226/VERSION +1 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/pyproject.toml +3 -3
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/pyproject.toml.orig +3 -3
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/agentic/ask_handler.py +3 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/agentic/ask_result.py +5 -2
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/app.py +21 -7
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/db/transform.py +7 -6
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/models.py +4 -4
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/server/server.py +0 -3
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/server/session.py +6 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/ask.py +6 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/mcp_nucliadb.py +7 -1
- nucliadb_agentic_api-1.0.0.post216/VERSION +0 -1
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/README.md +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/alembic/README +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/alembic/env.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/alembic/script.py.mako +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/alembic/versions/7f3b2f92a8c1_add_agentic_config_table.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/alembic/versions/b3c4d5e6f7a8_add_sources_table.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/alembic/versions/c4d5e6f7a8b9_add_agentic_config_soft_deletion.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/alembic.ini +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/VERSION +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/__init__.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/agentic/__init__.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/agentic/ask_transform_to_interaction.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/commands.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/db/__init__.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/db/agentic_configs.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/db/settings.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/db/sources.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/exceptions.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/logging.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/py.typed +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/server/__init__.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/server/settings.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/settings.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/utils.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/__init__.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/agentic_configs.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/ask_websocket.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/mcp_content.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/oauth.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/router.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/sources.py +0 -0
- {nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/src/nucliadb_agentic_api/v1/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.0.post226
|
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "nucliadb_agentic_api"
|
|
7
|
-
version = "1.0.0.
|
|
7
|
+
version = "1.0.0.post226"
|
|
8
8
|
description = "NucliaDB Agentic API for Hyperforge"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -66,13 +66,13 @@ server = [
|
|
|
66
66
|
"aiohttp<3.14.0",
|
|
67
67
|
"backoff",
|
|
68
68
|
"nats-py",
|
|
69
|
-
"nuclia>=4.
|
|
69
|
+
"nuclia>=4.14.0",
|
|
70
70
|
"nuclia-models>=0.59.0",
|
|
71
71
|
"nucliadb-protos",
|
|
72
72
|
"nucliadb-sdk>=6.14.0.post6532",
|
|
73
73
|
"nucliadb-telemetry[otel]>=6.14.0.post6534",
|
|
74
74
|
"nucliadb-utils[storages,fastapi]>=6.15.0.post6671",
|
|
75
|
-
"hyperforge>=1.0.0.
|
|
75
|
+
"hyperforge>=1.0.0.post237",
|
|
76
76
|
"hyperforge_conditional>=1.0.0.post27",
|
|
77
77
|
"hyperforge_mcp>=1.0.0.post41",
|
|
78
78
|
"hyperforge_nucliadb>=1.0.0.post46",
|
{nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/pyproject.toml.orig
RENAMED
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "nucliadb_agentic_api"
|
|
7
|
-
version = "1.0.0.
|
|
7
|
+
version = "1.0.0.post226"
|
|
8
8
|
authors = [{ name = "AI Data Team", email = "learning@nuclia.com" }]
|
|
9
9
|
description = "NucliaDB Agentic API for Hyperforge"
|
|
10
10
|
readme = "README.md"
|
|
@@ -61,13 +61,13 @@ server = [
|
|
|
61
61
|
"aiohttp<3.14.0",
|
|
62
62
|
"backoff",
|
|
63
63
|
"nats-py",
|
|
64
|
-
"nuclia>=4.
|
|
64
|
+
"nuclia>=4.14.0",
|
|
65
65
|
"nuclia-models>=0.59.0",
|
|
66
66
|
"nucliadb-protos",
|
|
67
67
|
"nucliadb-sdk>=6.14.0.post6532",
|
|
68
68
|
"nucliadb-telemetry[otel]>=6.14.0.post6534",
|
|
69
69
|
"nucliadb-utils[storages,fastapi]>=6.15.0.post6671",
|
|
70
|
-
"hyperforge>=1.0.0.
|
|
70
|
+
"hyperforge>=1.0.0.post237",
|
|
71
71
|
"hyperforge_conditional>=1.0.0.post27",
|
|
72
72
|
"hyperforge_mcp>=1.0.0.post41",
|
|
73
73
|
"hyperforge_nucliadb>=1.0.0.post46",
|
|
@@ -8,6 +8,7 @@ from hyperforge_nucliadb_agentic.ask.model import (
|
|
|
8
8
|
from hyperforge_nucliadb_agentic.ask.search.ask import (
|
|
9
9
|
handled_ask_exceptions,
|
|
10
10
|
)
|
|
11
|
+
from nuclia.lib.nua_responses import CitationsType
|
|
11
12
|
from nucliadb_models.search import (
|
|
12
13
|
NucliaDBClientType,
|
|
13
14
|
)
|
|
@@ -34,6 +35,8 @@ async def create_agentic_response(
|
|
|
34
35
|
extra_predict_headers: dict[str, str] | None = None,
|
|
35
36
|
) -> Response:
|
|
36
37
|
ask_request.max_tokens = parse_max_tokens(ask_request.max_tokens)
|
|
38
|
+
if ask_request.citations is None:
|
|
39
|
+
ask_request.citations = CitationsType.LLM_FOOTNOTES
|
|
37
40
|
ask_result = AgenticAskResult(
|
|
38
41
|
app=app,
|
|
39
42
|
kbid=kbid,
|
|
@@ -27,8 +27,11 @@ from hyperforge_nucliadb_agentic.ask.model import (
|
|
|
27
27
|
StatusAskResponseItem,
|
|
28
28
|
TokensDetail,
|
|
29
29
|
)
|
|
30
|
-
from hyperforge_nucliadb_agentic.ask.
|
|
31
|
-
|
|
30
|
+
from hyperforge_nucliadb_agentic.ask.search.ask import (
|
|
31
|
+
AnswerStatusCode,
|
|
32
|
+
AskResult,
|
|
33
|
+
RetrievalMatch,
|
|
34
|
+
)
|
|
32
35
|
from hyperforge_nucliadb_agentic.ask.search.metrics import (
|
|
33
36
|
AskMetrics,
|
|
34
37
|
)
|
|
@@ -8,23 +8,21 @@ from hyperforge.api.authentication import RaoAuthenticationBackend
|
|
|
8
8
|
from hyperforge.broker import Broker
|
|
9
9
|
from hyperforge.broker.redis import RedisBroker
|
|
10
10
|
from hyperforge.driver import Driver
|
|
11
|
+
from hyperforge.manager import Manager
|
|
11
12
|
from hyperforge_nucliadb_agentic.ask.audit import (
|
|
12
13
|
AuditMiddleware,
|
|
13
14
|
start_audit_utility,
|
|
14
15
|
stop_audit_utility,
|
|
15
16
|
)
|
|
16
|
-
from hyperforge_nucliadb_agentic.ask.predict import (
|
|
17
|
-
start_predict_engine,
|
|
18
|
-
stop_predict_engine,
|
|
19
|
-
)
|
|
20
17
|
from lru import LRU
|
|
21
18
|
from mcp.server.lowlevel.server import Server as MCPServer
|
|
22
19
|
from mcp.server.streamable_http import (
|
|
23
20
|
StreamableHTTPServerTransport,
|
|
24
21
|
)
|
|
22
|
+
from nuclia.lib.nua import AsyncNuaClient
|
|
25
23
|
from nucliadb_sdk import NucliaDBAsync
|
|
26
24
|
from nucliadb_telemetry.utils import clean_telemetry, setup_telemetry
|
|
27
|
-
from nucliadb_utils.settings import AuditSettings
|
|
25
|
+
from nucliadb_utils.settings import AuditSettings, nuclia_settings
|
|
28
26
|
from prometheus_client import CONTENT_TYPE_LATEST
|
|
29
27
|
from starlette.middleware.authentication import AuthenticationMiddleware
|
|
30
28
|
from starlette.responses import PlainTextResponse
|
|
@@ -61,6 +59,7 @@ class HTTPApplication(FastAPI):
|
|
|
61
59
|
source_manager: Sources
|
|
62
60
|
broker: Broker
|
|
63
61
|
hyperforge_drivers: dict[str, "Driver"]
|
|
62
|
+
predict_manager: Manager
|
|
64
63
|
|
|
65
64
|
def __init__(
|
|
66
65
|
self,
|
|
@@ -105,9 +104,24 @@ class HTTPApplication(FastAPI):
|
|
|
105
104
|
async def startup(self) -> None:
|
|
106
105
|
await setup_telemetry(SERVICE_NAME)
|
|
107
106
|
|
|
108
|
-
await start_predict_engine()
|
|
109
107
|
await start_audit_utility(SERVICE_NAME, self.audit_settings)
|
|
110
108
|
|
|
109
|
+
if nuclia_settings.onprem:
|
|
110
|
+
nua = AsyncNuaClient.onprem(
|
|
111
|
+
nuclia_settings.nuclia_public_url,
|
|
112
|
+
service_account=nuclia_settings.nuclia_service_account,
|
|
113
|
+
zone=nuclia_settings.nuclia_zone,
|
|
114
|
+
local_predict=nuclia_settings.local_predict,
|
|
115
|
+
local_predict_headers=nuclia_settings.local_predict_headers,
|
|
116
|
+
)
|
|
117
|
+
else:
|
|
118
|
+
nua = AsyncNuaClient.internal(nuclia_settings.nuclia_inner_predict_url)
|
|
119
|
+
self.predict_manager = await Manager.from_config(
|
|
120
|
+
drivers=[],
|
|
121
|
+
nua=nua,
|
|
122
|
+
send_rao_origin=False,
|
|
123
|
+
)
|
|
124
|
+
|
|
111
125
|
self.broker = RedisBroker.from_url(
|
|
112
126
|
url=self.settings.valkey_url,
|
|
113
127
|
activate_subject=self.settings.activate_subject,
|
|
@@ -163,5 +177,5 @@ class HTTPApplication(FastAPI):
|
|
|
163
177
|
await self.source_manager.finalize()
|
|
164
178
|
await self.broker.finalize()
|
|
165
179
|
await stop_audit_utility()
|
|
166
|
-
await
|
|
180
|
+
await self.predict_manager.aclose()
|
|
167
181
|
await clean_telemetry(SERVICE_NAME)
|
|
@@ -55,7 +55,7 @@ async def transform_agentic_config(
|
|
|
55
55
|
if agentic_config.rephrase.ask_to:
|
|
56
56
|
# Same KB with different layers
|
|
57
57
|
config["kbid"] = agentic_config.rephrase.ask_to
|
|
58
|
-
if agentic_config.rephrase.history:
|
|
58
|
+
if agentic_config.rephrase.history is not None:
|
|
59
59
|
config["history"] = agentic_config.rephrase.history
|
|
60
60
|
|
|
61
61
|
config["module"] = "rephrase"
|
|
@@ -78,10 +78,10 @@ async def transform_agentic_config(
|
|
|
78
78
|
config["planner_model"] = agentic_config.smart_agent.models.planner
|
|
79
79
|
if agentic_config.smart_agent.models.executor:
|
|
80
80
|
config["executor_model"] = agentic_config.smart_agent.models.executor
|
|
81
|
-
if agentic_config.smart_agent.history:
|
|
82
|
-
config["history"] = agentic_config.smart_agent.history
|
|
83
81
|
if agentic_config.smart_agent.extra_prompt:
|
|
84
82
|
config["extra_prompt"] = agentic_config.smart_agent.extra_prompt
|
|
83
|
+
if agentic_config.smart_agent.history is not None:
|
|
84
|
+
config["history"] = agentic_config.smart_agent.history
|
|
85
85
|
registered_agents = []
|
|
86
86
|
for source in agentic_config.smart_agent.sources:
|
|
87
87
|
source_obj = await source_manager.get_source(account, kbid, source)
|
|
@@ -186,9 +186,10 @@ async def transform_agentic_config(
|
|
|
186
186
|
config["user_prompt"] = agentic_config.summarize.user_prompt
|
|
187
187
|
if agentic_config.summarize.system_prompt:
|
|
188
188
|
config["system_prompt"] = agentic_config.summarize.system_prompt
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
config["conversational"] = agentic_config.summarize.conversational
|
|
190
|
+
config["citations"] = True
|
|
191
|
+
config["force_chunk_level_citations"] = False
|
|
192
|
+
if agentic_config.summarize.history is not None:
|
|
192
193
|
config["history"] = agentic_config.summarize.history
|
|
193
194
|
|
|
194
195
|
config["module"] = "summarize"
|
|
@@ -133,7 +133,7 @@ class AgenticRephraseConfiguration(BaseModel):
|
|
|
133
133
|
ask_to: Optional[str] = None
|
|
134
134
|
prompt: Optional[str] = None
|
|
135
135
|
model: Optional[str] = None
|
|
136
|
-
history: Optional[bool] =
|
|
136
|
+
history: Optional[bool] = True
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
class AgenticSmartAgentMode(str, Enum):
|
|
@@ -218,15 +218,15 @@ class AgenticSmartAgentConfiguration(BaseModel):
|
|
|
218
218
|
extra_prompt: Optional[str] = None
|
|
219
219
|
models: Optional[AgenticSmartAgentModels] = None
|
|
220
220
|
sources: List[str] = Field(default_factory=list)
|
|
221
|
-
history: Optional[bool] =
|
|
221
|
+
history: Optional[bool] = True
|
|
222
222
|
|
|
223
223
|
|
|
224
224
|
class AgenticSummarizeConfiguration(BaseModel):
|
|
225
225
|
user_prompt: Optional[str] = None
|
|
226
226
|
system_prompt: Optional[str] = None
|
|
227
|
-
conversational: bool =
|
|
227
|
+
conversational: bool = True
|
|
228
228
|
model: Optional[str] = None
|
|
229
|
-
history: Optional[bool] =
|
|
229
|
+
history: Optional[bool] = True
|
|
230
230
|
|
|
231
231
|
|
|
232
232
|
class AgenticConfigSchema(BaseModel):
|
|
@@ -7,7 +7,6 @@ from hyperforge.broker.redis import RedisBroker
|
|
|
7
7
|
from hyperforge.feature_flag import get_flag_service
|
|
8
8
|
from hyperforge.server.cache import ValkeyCache
|
|
9
9
|
from hyperforge.server.run import run_metrics_server
|
|
10
|
-
from hyperforge_nucliadb_agentic.ask.predict import start_predict_engine
|
|
11
10
|
from nucliadb_telemetry.logs import setup_logging
|
|
12
11
|
from nucliadb_telemetry.settings import LogFormatType, LogLevel, LogSettings
|
|
13
12
|
from nucliadb_telemetry.utils import setup_telemetry
|
|
@@ -40,8 +39,6 @@ async def run_server(
|
|
|
40
39
|
if tracer:
|
|
41
40
|
await setup_telemetry(SERVICE_NAME)
|
|
42
41
|
|
|
43
|
-
await start_predict_engine()
|
|
44
|
-
|
|
45
42
|
audit_settings: AuditSettings = AuditSettings()
|
|
46
43
|
# Connect to Valkey
|
|
47
44
|
broker = RedisBroker.from_url(
|
|
@@ -255,6 +255,12 @@ class NucliaDBAgenticSessionManager(SessionManager):
|
|
|
255
255
|
errors.capture_exception(e)
|
|
256
256
|
error = ARAGException(detail=str(e))
|
|
257
257
|
observation.set_status("error")
|
|
258
|
+
finally:
|
|
259
|
+
try:
|
|
260
|
+
await state.manager.aclose()
|
|
261
|
+
except Exception as e:
|
|
262
|
+
logger.exception("Error closing Manager")
|
|
263
|
+
errors.capture_exception(e)
|
|
258
264
|
|
|
259
265
|
observation.end()
|
|
260
266
|
answer_running.dec()
|
|
@@ -2,6 +2,7 @@ import json
|
|
|
2
2
|
from uuid import UUID
|
|
3
3
|
|
|
4
4
|
from fastapi import Header, Request, Response
|
|
5
|
+
from hyperforge.manager import Manager
|
|
5
6
|
from hyperforge_nucliadb_agentic.ask.exceptions import (
|
|
6
7
|
AnswerJsonSchemaTooLong,
|
|
7
8
|
)
|
|
@@ -108,6 +109,7 @@ async def ask_knowledgebox_endpoint(
|
|
|
108
109
|
)
|
|
109
110
|
|
|
110
111
|
return await create_ask_response(
|
|
112
|
+
predict_manager=request.app.predict_manager,
|
|
111
113
|
kbid=kbid,
|
|
112
114
|
ask_request=item,
|
|
113
115
|
user_id=x_nucliadb_user,
|
|
@@ -169,6 +171,7 @@ async def resource_ask_endpoint_by_uuid(
|
|
|
169
171
|
)
|
|
170
172
|
|
|
171
173
|
return await create_ask_response(
|
|
174
|
+
predict_manager=request.app.predict_manager,
|
|
172
175
|
kbid=kbid,
|
|
173
176
|
ask_request=item,
|
|
174
177
|
user_id=x_nucliadb_user,
|
|
@@ -238,6 +241,7 @@ async def resource_ask_endpoint_by_slug(
|
|
|
238
241
|
)
|
|
239
242
|
|
|
240
243
|
return await create_ask_response(
|
|
244
|
+
predict_manager=request.app.predict_manager,
|
|
241
245
|
kbid=kbid,
|
|
242
246
|
ask_request=item,
|
|
243
247
|
user_id=x_nucliadb_user,
|
|
@@ -251,6 +255,7 @@ async def resource_ask_endpoint_by_slug(
|
|
|
251
255
|
|
|
252
256
|
@handled_ask_exceptions
|
|
253
257
|
async def create_ask_response(
|
|
258
|
+
predict_manager: Manager,
|
|
254
259
|
kbid: str,
|
|
255
260
|
ask_request: AskRequest,
|
|
256
261
|
user_id: str,
|
|
@@ -266,6 +271,7 @@ async def create_ask_response(
|
|
|
266
271
|
search_sdk=rpc.get_sdk("search"),
|
|
267
272
|
reader_sdk=rpc.get_sdk("reader"),
|
|
268
273
|
kbid=kbid,
|
|
274
|
+
predict_manager=predict_manager,
|
|
269
275
|
ask_request=ask_request,
|
|
270
276
|
user_id=user_id,
|
|
271
277
|
client_type=client_type,
|
|
@@ -10,6 +10,7 @@ import anyio
|
|
|
10
10
|
import pydantic_core
|
|
11
11
|
from fastapi import Header
|
|
12
12
|
from hyperforge.api.authentication import requires_one
|
|
13
|
+
from hyperforge.manager import Manager
|
|
13
14
|
from mcp.server.fastmcp.exceptions import ResourceError
|
|
14
15
|
from mcp.server.fastmcp.utilities.types import Image
|
|
15
16
|
from mcp.server.lowlevel.helper_types import ReadResourceContents
|
|
@@ -34,7 +35,7 @@ from starlette.responses import Response
|
|
|
34
35
|
from nucliadb_agentic_api import logger
|
|
35
36
|
|
|
36
37
|
if TYPE_CHECKING:
|
|
37
|
-
from
|
|
38
|
+
from nucliadb_agentic_api.app import HTTPApplication
|
|
38
39
|
|
|
39
40
|
from anyio.abc import TaskStatus
|
|
40
41
|
from hyperforge_nucliadb_agentic.ask.exceptions import (
|
|
@@ -80,6 +81,7 @@ BATCH_GET_DOCUMENTS_MAX = 20
|
|
|
80
81
|
|
|
81
82
|
@dataclass
|
|
82
83
|
class MCPContext:
|
|
84
|
+
predict_manager: Manager
|
|
83
85
|
ndb_reader: NucliaDBAsync
|
|
84
86
|
ndb_search: NucliaDBAsync
|
|
85
87
|
kbid: str
|
|
@@ -249,6 +251,7 @@ async def _tool_search_documents(
|
|
|
249
251
|
search_sdk=context.ndb_search,
|
|
250
252
|
reader_sdk=context.ndb_reader,
|
|
251
253
|
kbid=context.kbid,
|
|
254
|
+
predict_manager=context.predict_manager,
|
|
252
255
|
ask_request=ask_request,
|
|
253
256
|
user_id=context.x_nucliadb_user,
|
|
254
257
|
client_type=context.x_ndb_client,
|
|
@@ -469,6 +472,7 @@ async def list_tools(description: str) -> list[Tool]:
|
|
|
469
472
|
|
|
470
473
|
|
|
471
474
|
async def call_tool(
|
|
475
|
+
predict_manager: Manager,
|
|
472
476
|
x_stf_account: str,
|
|
473
477
|
x_nucliadb_user: str,
|
|
474
478
|
x_ndb_client: NucliaDBClientType,
|
|
@@ -492,6 +496,7 @@ async def call_tool(
|
|
|
492
496
|
)
|
|
493
497
|
raise ResourceError(f"Invalid arguments for '{name}': {error_details}") from e
|
|
494
498
|
context = MCPContext(
|
|
499
|
+
predict_manager=predict_manager,
|
|
495
500
|
ndb_reader=ndb_reader,
|
|
496
501
|
ndb_search=ndb_search,
|
|
497
502
|
kbid=kbid,
|
|
@@ -678,6 +683,7 @@ async def mcp_handler(
|
|
|
678
683
|
list_resources_partial = partial(list_resources, ndb_reader, kbid)
|
|
679
684
|
call_tool_partial = partial(
|
|
680
685
|
call_tool,
|
|
686
|
+
app.predict_manager,
|
|
681
687
|
x_stf_account,
|
|
682
688
|
x_nucliadb_user,
|
|
683
689
|
x_ndb_client,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.0.0.post216
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nucliadb_agentic_api-1.0.0.post216 → nucliadb_agentic_api-1.0.0.post226}/alembic/script.py.mako
RENAMED
|
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
|