datarobot-genai 0.2.0__tar.gz → 0.2.8__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.
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/PKG-INFO +6 -2
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/pyproject.toml +10 -3
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/utils/auth.py +188 -31
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/config.py +52 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dr_mcp_server.py +45 -8
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/core/dynamic_prompts/dr_lib.py +70 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_prompts/register.py +4 -5
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/mcp_instance.py +41 -2
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/routes.py +4 -1
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/core/tool_config.py +95 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/test_utils/mcp_utils_ete.py +29 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/clients/__init__.py +14 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/clients/atlassian.py +188 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/clients/confluence.py +14 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/clients/jira.py +102 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/clients/s3.py +28 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/confluence/__init__.py +14 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/confluence/tools.py +13 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/jira/__init__.py +14 -0
- datarobot_genai-0.2.8/src/datarobot_genai/drmcp/tools/jira/tools.py +58 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/predict.py +1 -1
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/predict_realtime.py +1 -1
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/nat/agent.py +4 -0
- datarobot_genai-0.2.8/src/datarobot_genai/nat/datarobot_auth_provider.py +110 -0
- datarobot_genai-0.2.8/src/datarobot_genai/nat/datarobot_mcp_client.py +234 -0
- datarobot_genai-0.2.0/src/datarobot_genai/drmcp/core/dynamic_prompts/dr_lib.py +0 -128
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/.gitignore +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/AUTHORS +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/LICENSE +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/README.md +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/agents/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/agents/base.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/chat/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/chat/auth.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/chat/client.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/chat/responses.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/cli/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/cli/agent_environment.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/cli/agent_kernel.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/custom_model.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/mcp/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/mcp/common.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/telemetry_agent.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/utils/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/core/utils/urls.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/crewai/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/crewai/agent.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/crewai/base.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/crewai/events.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/crewai/mcp.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/auth.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/clients.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/config_utils.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/constants.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/credentials.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dr_mcp_server_logo.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_prompts/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_prompts/controllers.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_prompts/utils.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/base.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/default.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/drum.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/config.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/controllers.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/metadata.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/register.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/schemas/drum_agentic_fallback_schema.json +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/schemas/drum_prediction_fallback_schema.json +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/register.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dynamic_tools/schema.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/exceptions.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/logging.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/mcp_server_tools.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/memory_management/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/memory_management/manager.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/memory_management/memory_tools.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/routes_utils.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/server_life_cycle.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/telemetry.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/tool_filter.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/utils.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/server.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/test_utils/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/test_utils/integration_mcp_server.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/test_utils/mcp_utils_integration.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/test_utils/openai_llm_mcp_client.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/test_utils/tool_base_ete.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/test_utils/utils.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/data.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/deployment.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/deployment_info.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/model.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/project.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/tools/predictive/training.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/langgraph/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/langgraph/agent.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/langgraph/mcp.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/llama_index/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/llama_index/agent.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/llama_index/base.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/llama_index/mcp.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/nat/__init__.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/nat/datarobot_llm_clients.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/nat/datarobot_llm_providers.py +0 -0
- {datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datarobot-genai
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Generic helpers for GenAI
|
|
5
5
|
Project-URL: Homepage, https://github.com/datarobot-oss/datarobot-genai
|
|
6
6
|
Author: DataRobot, Inc.
|
|
@@ -11,13 +11,15 @@ Requires-Python: <3.13,>=3.10
|
|
|
11
11
|
Requires-Dist: ag-ui-protocol<0.2.0,>=0.1.9
|
|
12
12
|
Requires-Dist: datarobot-drum<2.0.0,>=1.17.5
|
|
13
13
|
Requires-Dist: datarobot-predict<2.0.0,>=1.13.2
|
|
14
|
-
Requires-Dist: datarobot<4.0.0,>=3.
|
|
14
|
+
Requires-Dist: datarobot<4.0.0,>=3.10.0
|
|
15
15
|
Requires-Dist: openai<2.0.0,>=1.76.2
|
|
16
16
|
Requires-Dist: opentelemetry-instrumentation-aiohttp-client<1.0.0,>=0.43b0
|
|
17
17
|
Requires-Dist: opentelemetry-instrumentation-httpx<1.0.0,>=0.43b0
|
|
18
18
|
Requires-Dist: opentelemetry-instrumentation-openai<1.0.0,>=0.40.5
|
|
19
19
|
Requires-Dist: opentelemetry-instrumentation-requests<1.0.0,>=0.43b0
|
|
20
|
+
Requires-Dist: opentelemetry-instrumentation-threading<1.0.0,>=0.43b0
|
|
20
21
|
Requires-Dist: pandas<3.0.0,>=2.2.3
|
|
22
|
+
Requires-Dist: pyarrow==20.0.0
|
|
21
23
|
Requires-Dist: pyjwt<3.0.0,>=2.10.1
|
|
22
24
|
Requires-Dist: pypdf<7.0.0,>=6.1.3
|
|
23
25
|
Requires-Dist: ragas<0.4.0,>=0.3.8
|
|
@@ -57,9 +59,11 @@ Requires-Dist: llama-index<0.14.0,>=0.13.6; extra == 'llamaindex'
|
|
|
57
59
|
Requires-Dist: opentelemetry-instrumentation-llamaindex<1.0.0,>=0.40.5; extra == 'llamaindex'
|
|
58
60
|
Requires-Dist: pypdf<7.0.0,>=6.0.0; extra == 'llamaindex'
|
|
59
61
|
Provides-Extra: nat
|
|
62
|
+
Requires-Dist: anyio==4.11.0; extra == 'nat'
|
|
60
63
|
Requires-Dist: crewai>=1.1.0; (python_version >= '3.11') and extra == 'nat'
|
|
61
64
|
Requires-Dist: llama-index-llms-litellm<0.7.0,>=0.4.1; extra == 'nat'
|
|
62
65
|
Requires-Dist: nvidia-nat-langchain==1.3.0; (python_version >= '3.11') and extra == 'nat'
|
|
66
|
+
Requires-Dist: nvidia-nat-mcp==1.3.0; (python_version >= '3.11') and extra == 'nat'
|
|
63
67
|
Requires-Dist: nvidia-nat-opentelemetry==1.3.0; (python_version >= '3.11') and extra == 'nat'
|
|
64
68
|
Requires-Dist: nvidia-nat==1.3.0; (python_version >= '3.11') and extra == 'nat'
|
|
65
69
|
Requires-Dist: opentelemetry-instrumentation-crewai<1.0.0,>=0.40.5; extra == 'nat'
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "datarobot-genai"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.8"
|
|
8
8
|
description = "Generic helpers for GenAI"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10, <3.13"
|
|
@@ -12,7 +12,7 @@ license = { text = "Apache-2.0" }
|
|
|
12
12
|
authors = [{ name = "DataRobot, Inc." }]
|
|
13
13
|
dependencies = [
|
|
14
14
|
"requests>=2.32.4,<3.0.0",
|
|
15
|
-
"datarobot>=3.
|
|
15
|
+
"datarobot>=3.10.0,<4.0.0",
|
|
16
16
|
"datarobot-predict>=1.13.2,<2.0.0",
|
|
17
17
|
"openai>=1.76.2,<2.0.0",
|
|
18
18
|
"pandas>=2.2.3,<3.0.0",
|
|
@@ -24,7 +24,9 @@ dependencies = [
|
|
|
24
24
|
"opentelemetry-instrumentation-aiohttp-client>=0.43b0,<1.0.0",
|
|
25
25
|
"opentelemetry-instrumentation-httpx>=0.43b0,<1.0.0",
|
|
26
26
|
"opentelemetry-instrumentation-openai>=0.40.5,<1.0.0",
|
|
27
|
+
"opentelemetry-instrumentation-threading>=0.43b0,<1.0.0",
|
|
27
28
|
"ag-ui-protocol>=0.1.9,<0.2.0",
|
|
29
|
+
"pyarrow==20.0.0",
|
|
28
30
|
]
|
|
29
31
|
|
|
30
32
|
[project.urls]
|
|
@@ -33,6 +35,8 @@ Homepage = "https://github.com/datarobot-oss/datarobot-genai"
|
|
|
33
35
|
[project.entry-points.'nat.plugins']
|
|
34
36
|
datarobot_llm_providers = "datarobot_genai.nat.datarobot_llm_providers"
|
|
35
37
|
datarobot_llm_clients = "datarobot_genai.nat.datarobot_llm_clients"
|
|
38
|
+
datarobot_mcp_client = "datarobot_genai.nat.datarobot_mcp_client"
|
|
39
|
+
datarobot_auth_provider = "datarobot_genai.nat.datarobot_auth_provider"
|
|
36
40
|
|
|
37
41
|
[project.optional-dependencies]
|
|
38
42
|
crewai = [
|
|
@@ -61,11 +65,13 @@ nat = [
|
|
|
61
65
|
"nvidia-nat==1.3.0; python_version >= '3.11'",
|
|
62
66
|
"nvidia-nat-opentelemetry==1.3.0; python_version >= '3.11'",
|
|
63
67
|
"nvidia-nat-langchain==1.3.0; python_version >= '3.11'",
|
|
68
|
+
"nvidia-nat-mcp==1.3.0; python_version >= '3.11'",
|
|
64
69
|
"crewai>=1.1.0; python_version >= '3.11'",
|
|
65
70
|
"llama-index-llms-litellm>=0.4.1,<0.7.0", # Need this to support datarobot-llm plugin
|
|
66
71
|
"opentelemetry-instrumentation-crewai>=0.40.5,<1.0.0",
|
|
67
72
|
"opentelemetry-instrumentation-llamaindex>=0.40.5,<1.0.0",
|
|
68
73
|
"opentelemetry-instrumentation-langchain>=0.40.5,<1.0.0",
|
|
74
|
+
"anyio==4.11.0",
|
|
69
75
|
]
|
|
70
76
|
pydanticai = [
|
|
71
77
|
"logfire>=4.6.0,<5.0.0",
|
|
@@ -105,7 +111,7 @@ include = [
|
|
|
105
111
|
[tool.uv]
|
|
106
112
|
package = true
|
|
107
113
|
override-dependencies = [
|
|
108
|
-
"ragas>=0.3.8",
|
|
114
|
+
"ragas>=0.3.8,<0.4.0",
|
|
109
115
|
]
|
|
110
116
|
exclude-dependencies = [
|
|
111
117
|
"uv",
|
|
@@ -122,6 +128,7 @@ dev = [
|
|
|
122
128
|
"pytest-asyncio>=0.23.5",
|
|
123
129
|
"responses>=0.25.8",
|
|
124
130
|
"ipdb>=0.13.13",
|
|
131
|
+
"aioresponses>=0.7.8",
|
|
125
132
|
]
|
|
126
133
|
|
|
127
134
|
|
|
@@ -12,17 +12,23 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
import logging
|
|
15
|
+
import os
|
|
15
16
|
import warnings
|
|
16
17
|
from typing import Any
|
|
18
|
+
from typing import Protocol
|
|
17
19
|
|
|
20
|
+
import aiohttp
|
|
18
21
|
import jwt
|
|
19
|
-
from datarobot.auth.datarobot.oauth import AsyncOAuth as
|
|
22
|
+
from datarobot.auth.datarobot.oauth import AsyncOAuth as DatarobotOAuthClient
|
|
23
|
+
from datarobot.auth.exceptions import OAuthProviderNotFound
|
|
24
|
+
from datarobot.auth.exceptions import OAuthValidationErr
|
|
20
25
|
from datarobot.auth.identity import Identity
|
|
21
|
-
from datarobot.auth.oauth import
|
|
26
|
+
from datarobot.auth.oauth import OAuthToken
|
|
22
27
|
from datarobot.auth.session import AuthCtx
|
|
23
28
|
from datarobot.core.config import DataRobotAppFrameworkBaseSettings
|
|
24
29
|
from datarobot.models.genai.agent.auth import ToolAuth
|
|
25
30
|
from datarobot.models.genai.agent.auth import get_authorization_context
|
|
31
|
+
from mypyc.ir.ops import Sequence
|
|
26
32
|
from pydantic import BaseModel
|
|
27
33
|
|
|
28
34
|
logger = logging.getLogger(__name__)
|
|
@@ -183,52 +189,203 @@ class AuthContextHeaderHandler:
|
|
|
183
189
|
return None
|
|
184
190
|
|
|
185
191
|
|
|
192
|
+
# --- OAuth Token Provider Implementation ---
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class TokenRetriever(Protocol):
|
|
196
|
+
"""Protocol for OAuth token retrievers."""
|
|
197
|
+
|
|
198
|
+
def filter_identities(self, identities: Sequence[Identity]) -> list[Identity]:
|
|
199
|
+
"""Filter identities to only those valid for this retriever implementation."""
|
|
200
|
+
...
|
|
201
|
+
|
|
202
|
+
async def refresh_access_token(self, identity: Identity) -> OAuthToken:
|
|
203
|
+
"""Refresh the access token for the given identity ID.
|
|
204
|
+
|
|
205
|
+
Parameters
|
|
206
|
+
----------
|
|
207
|
+
identity_id : str
|
|
208
|
+
The provider identity ID to refresh the token for.
|
|
209
|
+
|
|
210
|
+
Returns
|
|
211
|
+
-------
|
|
212
|
+
OAuthToken
|
|
213
|
+
The refreshed OAuth token.
|
|
214
|
+
"""
|
|
215
|
+
...
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
class DatarobotTokenRetriever:
|
|
219
|
+
"""Retrieves OAuth tokens using the DataRobot platform."""
|
|
220
|
+
|
|
221
|
+
def __init__(self) -> None:
|
|
222
|
+
self._client = DatarobotOAuthClient()
|
|
223
|
+
|
|
224
|
+
def filter_identities(self, identities: Sequence[Identity]) -> list[Identity]:
|
|
225
|
+
"""Filter oauth2 identities to only those with provider_identity_id.
|
|
226
|
+
|
|
227
|
+
The `provider_identity_id` is required in order to identify the provider
|
|
228
|
+
and retrieve the access token from DataRobot OAuth Providers service.
|
|
229
|
+
"""
|
|
230
|
+
return [i for i in identities if i.type == "oauth2" and i.provider_identity_id]
|
|
231
|
+
|
|
232
|
+
async def refresh_access_token(self, identity: Identity) -> OAuthToken:
|
|
233
|
+
"""Refresh the access token using DataRobot's OAuth client."""
|
|
234
|
+
return await self._client.refresh_access_token(provider_id=identity.provider_identity_id)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class AuthlibTokenRetriever:
|
|
238
|
+
"""Retrieves OAuth tokens from a generic Authlib-based endpoint."""
|
|
239
|
+
|
|
240
|
+
def __init__(self, application_endpoint: str) -> None:
|
|
241
|
+
if not application_endpoint:
|
|
242
|
+
raise ValueError("AuthlibTokenRetriever requires 'application_endpoint'.")
|
|
243
|
+
self.application_endpoint = application_endpoint.rstrip("/")
|
|
244
|
+
|
|
245
|
+
def filter_identities(self, identities: Sequence[Identity]) -> list[Identity]:
|
|
246
|
+
"""Filter identities to only OAuth2 identities."""
|
|
247
|
+
return [i for i in identities if i.type == "oauth2" and i.provider_identity_id is None]
|
|
248
|
+
|
|
249
|
+
async def refresh_access_token(self, identity: Identity) -> OAuthToken:
|
|
250
|
+
"""Retrieve an OAuth token via an HTTP POST request.
|
|
251
|
+
|
|
252
|
+
Parameters
|
|
253
|
+
----------
|
|
254
|
+
identity : Identity
|
|
255
|
+
The identity to retrieve the token for.
|
|
256
|
+
|
|
257
|
+
Returns
|
|
258
|
+
-------
|
|
259
|
+
OAuthToken
|
|
260
|
+
The retrieved OAuth token.
|
|
261
|
+
"""
|
|
262
|
+
api_token = os.environ.get("DATAROBOT_API_TOKEN")
|
|
263
|
+
if not api_token:
|
|
264
|
+
raise ValueError("DATAROBOT_API_TOKEN environment variable is required but not set.")
|
|
265
|
+
|
|
266
|
+
token_url = f"{self.application_endpoint}/oauth/token/"
|
|
267
|
+
headers = {"Authorization": f"Bearer {api_token}"}
|
|
268
|
+
payload = {"identity_id": identity.id}
|
|
269
|
+
timeout = aiohttp.ClientTimeout(total=30)
|
|
270
|
+
|
|
271
|
+
try:
|
|
272
|
+
async with aiohttp.ClientSession(timeout=timeout) as session:
|
|
273
|
+
async with session.post(token_url, headers=headers, json=payload) as response:
|
|
274
|
+
response.raise_for_status()
|
|
275
|
+
data = await response.json()
|
|
276
|
+
logger.debug(f"Retrieved access token from {token_url}")
|
|
277
|
+
return OAuthToken(**data)
|
|
278
|
+
except aiohttp.ClientError as e:
|
|
279
|
+
logger.error(f"Error retrieving token from {token_url}: {e}")
|
|
280
|
+
raise
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
class OAuthConfig(BaseModel):
|
|
284
|
+
"""Configuration extracted from AuthCtx metadata for OAuth operations."""
|
|
285
|
+
|
|
286
|
+
implementation: str = "datarobot"
|
|
287
|
+
application_endpoint: str | None = None
|
|
288
|
+
|
|
289
|
+
@classmethod
|
|
290
|
+
def from_auth_ctx(cls, auth_ctx: AuthCtx) -> "OAuthConfig":
|
|
291
|
+
metadata = auth_ctx.metadata or {}
|
|
292
|
+
return cls(
|
|
293
|
+
implementation=metadata.get("oauth_implementation", "datarobot"),
|
|
294
|
+
application_endpoint=metadata.get("application_endpoint"),
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def create_token_retriever(config: OAuthConfig) -> TokenRetriever:
|
|
299
|
+
"""Create a token retriever based on the OAuth configuration.
|
|
300
|
+
|
|
301
|
+
Parameters
|
|
302
|
+
----------
|
|
303
|
+
config : OAuthConfig
|
|
304
|
+
The OAuth configuration specifying implementation type and endpoints.
|
|
305
|
+
|
|
306
|
+
Returns
|
|
307
|
+
-------
|
|
308
|
+
TokenRetriever
|
|
309
|
+
The configured token retriever instance.
|
|
310
|
+
"""
|
|
311
|
+
if config.implementation == "datarobot":
|
|
312
|
+
return DatarobotTokenRetriever()
|
|
313
|
+
|
|
314
|
+
if config.implementation == "authlib":
|
|
315
|
+
if not config.application_endpoint:
|
|
316
|
+
raise ValueError("Required 'application_endpoint' not found in metadata.")
|
|
317
|
+
return AuthlibTokenRetriever(config.application_endpoint)
|
|
318
|
+
|
|
319
|
+
raise ValueError(
|
|
320
|
+
f"Unsupported OAuth implementation: '{config.implementation}'. "
|
|
321
|
+
f"Supported values: datarobot, authlib."
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
|
|
186
325
|
class AsyncOAuthTokenProvider:
|
|
187
|
-
"""
|
|
326
|
+
"""Provides OAuth tokens for authorized users.
|
|
327
|
+
|
|
328
|
+
This class manages OAuth token retrieval for users with multiple identity providers.
|
|
329
|
+
It uses either DataRobot or Authlib as the OAuth token storage and refresh backend
|
|
330
|
+
based on the auth context metadata.
|
|
331
|
+
"""
|
|
188
332
|
|
|
189
333
|
def __init__(self, auth_ctx: AuthCtx) -> None:
|
|
334
|
+
"""Initialize the provider with an authorization context.
|
|
335
|
+
|
|
336
|
+
Parameters
|
|
337
|
+
----------
|
|
338
|
+
auth_ctx : AuthCtx
|
|
339
|
+
The authorization context containing user identities and metadata.
|
|
340
|
+
"""
|
|
190
341
|
self.auth_ctx = auth_ctx
|
|
191
|
-
|
|
342
|
+
config = OAuthConfig.from_auth_ctx(auth_ctx)
|
|
343
|
+
self._retriever = create_token_retriever(config)
|
|
192
344
|
|
|
193
345
|
def _get_identity(self, provider_type: str | None) -> Identity:
|
|
194
|
-
"""
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
raise ValueError("No identities found in authorization context.")
|
|
346
|
+
"""Get identity from auth context, filtered by provider_type if specified."""
|
|
347
|
+
oauth_identities = self._retriever.filter_identities(self.auth_ctx.identities)
|
|
348
|
+
if not oauth_identities:
|
|
349
|
+
raise OAuthProviderNotFound("No OAuth provider found.")
|
|
199
350
|
|
|
200
351
|
if provider_type is None:
|
|
201
|
-
if len(
|
|
202
|
-
raise
|
|
203
|
-
"Multiple
|
|
352
|
+
if len(oauth_identities) > 1:
|
|
353
|
+
raise OAuthValidationErr(
|
|
354
|
+
"Multiple OAuth providers found. Specify 'provider_type' parameter."
|
|
204
355
|
)
|
|
205
|
-
return
|
|
206
|
-
|
|
207
|
-
identity = next((id for id in identities if id.provider_type == provider_type), None)
|
|
356
|
+
return oauth_identities[0]
|
|
208
357
|
|
|
358
|
+
identity = next((i for i in oauth_identities if i.provider_type == provider_type), None)
|
|
209
359
|
if identity is None:
|
|
210
|
-
raise
|
|
211
|
-
|
|
360
|
+
raise OAuthValidationErr(f"No identity found for provider '{provider_type}'.")
|
|
212
361
|
return identity
|
|
213
362
|
|
|
214
363
|
async def get_token(self, auth_type: ToolAuth, provider_type: str | None = None) -> str:
|
|
215
|
-
"""Get OAuth access token
|
|
364
|
+
"""Get an OAuth access token for the specified auth type and provider.
|
|
365
|
+
|
|
366
|
+
Parameters
|
|
367
|
+
----------
|
|
368
|
+
auth_type : ToolAuth
|
|
369
|
+
Authentication type (only OBO is supported).
|
|
370
|
+
provider_type : str, optional
|
|
371
|
+
The specific provider to use (e.g., 'google'). Required if multiple
|
|
372
|
+
identities are available.
|
|
373
|
+
|
|
374
|
+
Returns
|
|
375
|
+
-------
|
|
376
|
+
str
|
|
377
|
+
The retrieved OAuth access token.
|
|
378
|
+
|
|
379
|
+
Raises
|
|
380
|
+
------
|
|
381
|
+
ValueError
|
|
382
|
+
If the auth type is unsupported or if a suitable identity cannot be found.
|
|
383
|
+
"""
|
|
216
384
|
if auth_type != ToolAuth.OBO:
|
|
217
385
|
raise ValueError(
|
|
218
|
-
f"Unsupported auth type: {auth_type}. Only
|
|
386
|
+
f"Unsupported auth type: {auth_type}. Only OBO (on-behalf-of) is supported."
|
|
219
387
|
)
|
|
220
388
|
|
|
221
389
|
identity = self._get_identity(provider_type)
|
|
222
|
-
token_data = await self.
|
|
223
|
-
identity_id=identity.provider_identity_id
|
|
224
|
-
)
|
|
390
|
+
token_data = await self._retriever.refresh_access_token(identity)
|
|
225
391
|
return token_data.access_token
|
|
226
|
-
|
|
227
|
-
def _create_oauth_client(self) -> AsyncOAuthComponent:
|
|
228
|
-
"""Create either DataRobot or Authlib OAuth client based on
|
|
229
|
-
authorization context.
|
|
230
|
-
|
|
231
|
-
Note: at the moment, only DataRobot OAuth client is supported.
|
|
232
|
-
"""
|
|
233
|
-
logger.debug("Using DataRobot OAuth client")
|
|
234
|
-
return DatarobotAsyncOAuthClient()
|
|
@@ -197,6 +197,54 @@ class MCPServerConfig(BaseSettings):
|
|
|
197
197
|
description="Enable/disable predictive tools",
|
|
198
198
|
)
|
|
199
199
|
|
|
200
|
+
# Jira tools
|
|
201
|
+
enable_jira_tools: bool = Field(
|
|
202
|
+
default=False,
|
|
203
|
+
validation_alias=AliasChoices(
|
|
204
|
+
RUNTIME_PARAM_ENV_VAR_NAME_PREFIX + "ENABLE_JIRA_TOOLS",
|
|
205
|
+
"ENABLE_JIRA_TOOLS",
|
|
206
|
+
),
|
|
207
|
+
description="Enable/disable Jira tools",
|
|
208
|
+
)
|
|
209
|
+
is_jira_oauth_provider_configured: bool = Field(
|
|
210
|
+
default=False,
|
|
211
|
+
validation_alias=AliasChoices(
|
|
212
|
+
RUNTIME_PARAM_ENV_VAR_NAME_PREFIX + "IS_JIRA_OAUTH_PROVIDER_CONFIGURED",
|
|
213
|
+
"IS_JIRA_OAUTH_PROVIDER_CONFIGURED",
|
|
214
|
+
),
|
|
215
|
+
description="Whether Jira OAuth provider is configured for Jira integration",
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
@property
|
|
219
|
+
def is_jira_oauth_configured(self) -> bool:
|
|
220
|
+
return self.is_jira_oauth_provider_configured or bool(
|
|
221
|
+
os.getenv("JIRA_CLIENT_ID") and os.getenv("JIRA_CLIENT_SECRET")
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
# Confluence tools
|
|
225
|
+
enable_confluence_tools: bool = Field(
|
|
226
|
+
default=False,
|
|
227
|
+
validation_alias=AliasChoices(
|
|
228
|
+
RUNTIME_PARAM_ENV_VAR_NAME_PREFIX + "ENABLE_CONFLUENCE_TOOLS",
|
|
229
|
+
"ENABLE_CONFLUENCE_TOOLS",
|
|
230
|
+
),
|
|
231
|
+
description="Enable/disable Confluence tools",
|
|
232
|
+
)
|
|
233
|
+
is_confluence_oauth_provider_configured: bool = Field(
|
|
234
|
+
default=False,
|
|
235
|
+
validation_alias=AliasChoices(
|
|
236
|
+
RUNTIME_PARAM_ENV_VAR_NAME_PREFIX + "IS_CONFLUENCE_OAUTH_PROVIDER_CONFIGURED",
|
|
237
|
+
"IS_CONFLUENCE_OAUTH_PROVIDER_CONFIGURED",
|
|
238
|
+
),
|
|
239
|
+
description="Whether Confluence OAuth provider is configured for Confluence integration",
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
@property
|
|
243
|
+
def is_confluence_oauth_configured(self) -> bool:
|
|
244
|
+
return self.is_confluence_oauth_provider_configured or bool(
|
|
245
|
+
os.getenv("CONFLUENCE_CLIENT_ID") and os.getenv("CONFLUENCE_CLIENT_SECRET")
|
|
246
|
+
)
|
|
247
|
+
|
|
200
248
|
@field_validator(
|
|
201
249
|
"otel_attributes",
|
|
202
250
|
mode="before",
|
|
@@ -220,6 +268,10 @@ class MCPServerConfig(BaseSettings):
|
|
|
220
268
|
"tool_registration_duplicate_behavior",
|
|
221
269
|
"mcp_server_register_dynamic_prompts_on_startup",
|
|
222
270
|
"enable_predictive_tools",
|
|
271
|
+
"enable_jira_tools",
|
|
272
|
+
"is_jira_oauth_provider_configured",
|
|
273
|
+
"enable_confluence_tools",
|
|
274
|
+
"is_confluence_oauth_provider_configured",
|
|
223
275
|
mode="before",
|
|
224
276
|
)
|
|
225
277
|
@classmethod
|
{datarobot_genai-0.2.0 → datarobot_genai-0.2.8}/src/datarobot_genai/drmcp/core/dr_mcp_server.py
RENAMED
|
@@ -40,6 +40,8 @@ from .routes_utils import prefix_mount_path
|
|
|
40
40
|
from .server_life_cycle import BaseServerLifecycle
|
|
41
41
|
from .telemetry import OtelASGIMiddleware
|
|
42
42
|
from .telemetry import initialize_telemetry
|
|
43
|
+
from .tool_config import TOOL_CONFIGS
|
|
44
|
+
from .tool_config import is_tool_enabled
|
|
43
45
|
|
|
44
46
|
|
|
45
47
|
def _import_modules_from_dir(
|
|
@@ -115,6 +117,9 @@ class DataRobotMCPServer:
|
|
|
115
117
|
self._mcp = mcp
|
|
116
118
|
self._mcp_transport = transport
|
|
117
119
|
|
|
120
|
+
# Configure MCP server capabilities
|
|
121
|
+
self._configure_mcp_capabilities()
|
|
122
|
+
|
|
118
123
|
# Initialize telemetry
|
|
119
124
|
initialize_telemetry(mcp)
|
|
120
125
|
|
|
@@ -139,11 +144,12 @@ class DataRobotMCPServer:
|
|
|
139
144
|
|
|
140
145
|
# Load static tools modules
|
|
141
146
|
base_dir = os.path.dirname(os.path.dirname(__file__))
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
for tool_type, tool_config in TOOL_CONFIGS.items():
|
|
148
|
+
if is_tool_enabled(tool_type, self._config):
|
|
149
|
+
_import_modules_from_dir(
|
|
150
|
+
os.path.join(base_dir, "tools", tool_config["directory"]),
|
|
151
|
+
tool_config["package_prefix"],
|
|
152
|
+
)
|
|
147
153
|
|
|
148
154
|
# Load memory management tools if available
|
|
149
155
|
if self._memory_manager:
|
|
@@ -163,6 +169,37 @@ class DataRobotMCPServer:
|
|
|
163
169
|
if transport == "streamable-http":
|
|
164
170
|
register_routes(self._mcp)
|
|
165
171
|
|
|
172
|
+
def _configure_mcp_capabilities(self) -> None:
|
|
173
|
+
"""Configure MCP capabilities that FastMCP doesn't expose directly.
|
|
174
|
+
|
|
175
|
+
See: https://github.com/modelcontextprotocol/python-sdk/issues/1126
|
|
176
|
+
"""
|
|
177
|
+
server = self._mcp._mcp_server
|
|
178
|
+
|
|
179
|
+
# Declare prompts_changed capability (capabilities.prompts.listChanged: true)
|
|
180
|
+
server.notification_options.prompts_changed = True
|
|
181
|
+
|
|
182
|
+
# Declare experimental capabilities ( experimental.dynamic_prompts: true)
|
|
183
|
+
server.experimental_capabilities = {"dynamic_prompts": {"enabled": True}}
|
|
184
|
+
|
|
185
|
+
# Patch to include experimental_capabilities (FastMCP doesn't expose this)
|
|
186
|
+
original = server.create_initialization_options
|
|
187
|
+
|
|
188
|
+
def patched(
|
|
189
|
+
notification_options: Any = None,
|
|
190
|
+
experimental_capabilities: dict[str, dict[str, Any]] | None = None,
|
|
191
|
+
**kwargs: Any,
|
|
192
|
+
) -> Any:
|
|
193
|
+
if experimental_capabilities is None:
|
|
194
|
+
experimental_capabilities = getattr(server, "experimental_capabilities", None)
|
|
195
|
+
return original(
|
|
196
|
+
notification_options=notification_options,
|
|
197
|
+
experimental_capabilities=experimental_capabilities,
|
|
198
|
+
**kwargs,
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
server.create_initialization_options = patched
|
|
202
|
+
|
|
166
203
|
def run(self, show_banner: bool = False) -> None:
|
|
167
204
|
"""Run the DataRobot MCP server synchronously."""
|
|
168
205
|
try:
|
|
@@ -179,6 +216,9 @@ class DataRobotMCPServer:
|
|
|
179
216
|
self._logger.info("Registering dynamic prompts from prompt management...")
|
|
180
217
|
asyncio.run(register_prompts_from_datarobot_prompt_management())
|
|
181
218
|
|
|
219
|
+
# Execute pre-server start actions
|
|
220
|
+
asyncio.run(self._lifecycle.pre_server_start(self._mcp))
|
|
221
|
+
|
|
182
222
|
# List registered tools, prompts, and resources before starting server
|
|
183
223
|
tools = asyncio.run(self._mcp._list_tools_mcp())
|
|
184
224
|
prompts = asyncio.run(self._mcp._list_prompts_mcp())
|
|
@@ -198,9 +238,6 @@ class DataRobotMCPServer:
|
|
|
198
238
|
for resource in resources:
|
|
199
239
|
self._logger.info(f" > {resource.name}")
|
|
200
240
|
|
|
201
|
-
# Execute pre-server start actions
|
|
202
|
-
asyncio.run(self._lifecycle.pre_server_start(self._mcp))
|
|
203
|
-
|
|
204
241
|
# Create event loop for async operations
|
|
205
242
|
loop = asyncio.new_event_loop()
|
|
206
243
|
asyncio.set_event_loop(loop)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from collections import defaultdict
|
|
15
|
+
|
|
16
|
+
import datarobot as dr
|
|
17
|
+
|
|
18
|
+
from datarobot_genai.drmcp.core.clients import get_api_client
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def get_datarobot_prompt_templates() -> list[dr.genai.PromptTemplate]:
|
|
22
|
+
try:
|
|
23
|
+
return dr.genai.PromptTemplate.list()
|
|
24
|
+
except Exception:
|
|
25
|
+
return []
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_datarobot_prompt_template_versions(
|
|
29
|
+
prompt_template_ids: list[str],
|
|
30
|
+
) -> dict[str, list[dr.genai.PromptTemplateVersion]]:
|
|
31
|
+
# Still missing in SDK
|
|
32
|
+
prompt_template_versions_data = dr.utils.pagination.unpaginate(
|
|
33
|
+
initial_url="genai/promptTemplates/versions/",
|
|
34
|
+
initial_params={
|
|
35
|
+
"promptTemplateIds": prompt_template_ids,
|
|
36
|
+
},
|
|
37
|
+
client=get_api_client(),
|
|
38
|
+
)
|
|
39
|
+
prompt_template_versions = defaultdict(list)
|
|
40
|
+
for prompt_template_version in prompt_template_versions_data:
|
|
41
|
+
prompt_template_versions[prompt_template_version["promptTemplateId"]].append(
|
|
42
|
+
dr.genai.PromptTemplateVersion(
|
|
43
|
+
id=prompt_template_version["id"],
|
|
44
|
+
prompt_template_id=prompt_template_version["promptTemplateId"],
|
|
45
|
+
prompt_text=prompt_template_version["promptText"],
|
|
46
|
+
commit_comment=prompt_template_version["commitComment"],
|
|
47
|
+
version=prompt_template_version["version"],
|
|
48
|
+
variables=prompt_template_version["variables"],
|
|
49
|
+
creation_date=prompt_template_version["creationDate"],
|
|
50
|
+
creation_user_id=prompt_template_version["creationUserId"],
|
|
51
|
+
user_name=prompt_template_version["userName"],
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
return prompt_template_versions
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def get_datarobot_prompt_template(prompt_template_id: str) -> dr.genai.PromptTemplate | None:
|
|
58
|
+
try:
|
|
59
|
+
return dr.genai.PromptTemplate.get(prompt_template_id)
|
|
60
|
+
except Exception:
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def get_datarobot_prompt_template_version(
|
|
65
|
+
prompt_template_id: str, prompt_template_version_id: str
|
|
66
|
+
) -> dr.genai.PromptTemplateVersion | None:
|
|
67
|
+
try:
|
|
68
|
+
return dr.genai.PromptTemplateVersion.get(prompt_template_id, prompt_template_version_id)
|
|
69
|
+
except Exception:
|
|
70
|
+
return None
|
|
@@ -18,15 +18,13 @@ from collections.abc import Callable
|
|
|
18
18
|
from inspect import Parameter
|
|
19
19
|
from inspect import Signature
|
|
20
20
|
|
|
21
|
+
import datarobot as dr
|
|
21
22
|
from fastmcp.prompts.prompt import Prompt
|
|
22
23
|
from pydantic import Field
|
|
23
24
|
|
|
24
25
|
from datarobot_genai.drmcp.core.exceptions import DynamicPromptRegistrationError
|
|
25
26
|
from datarobot_genai.drmcp.core.mcp_instance import register_prompt
|
|
26
27
|
|
|
27
|
-
from .dr_lib import DrPrompt
|
|
28
|
-
from .dr_lib import DrPromptVersion
|
|
29
|
-
from .dr_lib import DrVariable
|
|
30
28
|
from .dr_lib import get_datarobot_prompt_template_versions
|
|
31
29
|
from .dr_lib import get_datarobot_prompt_templates
|
|
32
30
|
|
|
@@ -57,7 +55,8 @@ async def register_prompts_from_datarobot_prompt_management() -> None:
|
|
|
57
55
|
|
|
58
56
|
|
|
59
57
|
async def register_prompt_from_datarobot_prompt_management(
|
|
60
|
-
prompt_template:
|
|
58
|
+
prompt_template: dr.genai.PromptTemplate,
|
|
59
|
+
prompt_template_version: dr.genai.PromptTemplateVersion | None = None,
|
|
61
60
|
) -> Prompt:
|
|
62
61
|
"""Register a single prompt.
|
|
63
62
|
|
|
@@ -173,7 +172,7 @@ def to_valid_mcp_prompt_name(s: str) -> str:
|
|
|
173
172
|
|
|
174
173
|
|
|
175
174
|
def make_prompt_function(
|
|
176
|
-
name: str, description: str, prompt_text: str, variables: list[
|
|
175
|
+
name: str, description: str, prompt_text: str, variables: list[dr.genai.Variable]
|
|
177
176
|
) -> Callable:
|
|
178
177
|
params = []
|
|
179
178
|
for v in variables:
|