datarobot-genai 0.2.11__py3-none-any.whl → 0.2.13__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.
@@ -107,6 +107,11 @@ class JiraClient:
107
107
  self._cloud_id = await get_atlassian_cloud_id(self._client, service_type="jira")
108
108
  return self._cloud_id
109
109
 
110
+ async def _get_full_url(self, url: str) -> str:
111
+ """Return URL for Jira API."""
112
+ cloud_id = await self._get_cloud_id()
113
+ return f"{ATLASSIAN_API_BASE}/ex/jira/{cloud_id}/rest/api/3/{url}"
114
+
110
115
  async def get_jira_issue(self, issue_key: str) -> Issue:
111
116
  """
112
117
  Get a Jira issue by its key.
@@ -122,9 +127,7 @@ class JiraClient:
122
127
  ------
123
128
  httpx.HTTPStatusError: If the API request fails
124
129
  """
125
- cloud_id = await self._get_cloud_id()
126
- url = f"{ATLASSIAN_API_BASE}/ex/jira/{cloud_id}/rest/api/3/issue/{issue_key}"
127
-
130
+ url = await self._get_full_url(f"issue/{issue_key}")
128
131
  response = await self._client.get(
129
132
  url, params={"fields": "id,key,summary,status,reporter,assignee,created,updated"}
130
133
  )
@@ -136,6 +139,76 @@ class JiraClient:
136
139
  issue = Issue(**response.json())
137
140
  return issue
138
141
 
142
+ async def get_jira_issue_types(self, project_key: str) -> dict[str, str]:
143
+ """
144
+ Get Jira issue types possible for given project.
145
+
146
+ Args:
147
+ project_key: The key of the Jira project, e.g., 'PROJ'
148
+
149
+ Returns
150
+ -------
151
+ Dictionary where key is the issue type name and value is the issue type ID
152
+
153
+ Raises
154
+ ------
155
+ httpx.HTTPStatusError: If the API request fails
156
+ """
157
+ url = await self._get_full_url(f"issue/createmeta/{project_key}/issuetypes")
158
+ response = await self._client.get(url)
159
+
160
+ response.raise_for_status()
161
+ jsoned = response.json()
162
+ issue_types = {
163
+ issue_type["untranslatedName"]: issue_type["id"]
164
+ for issue_type in jsoned.get("issueTypes", [])
165
+ }
166
+ return issue_types
167
+
168
+ async def create_jira_issue(
169
+ self, project_key: str, summary: str, issue_type_id: str, description: str | None
170
+ ) -> str:
171
+ """
172
+ Create Jira issue.
173
+
174
+ Args:
175
+ project_key: The key of the Jira project, e.g., 'PROJ'
176
+ summary: Summary of Jira issue (title), e.g., 'Fix bug abc'
177
+ issue_type_id: ID type of Jira issue, e.g., "1"
178
+ description: Optional description of Jira issue
179
+
180
+ Returns
181
+ -------
182
+ Jira issue key
183
+
184
+ Raises
185
+ ------
186
+ httpx.HTTPStatusError: If the API request fails
187
+ """
188
+ url = await self._get_full_url("issue")
189
+ payload = {
190
+ "fields": {
191
+ "project": {"key": project_key},
192
+ "summary": summary,
193
+ "issuetype": {"id": issue_type_id},
194
+ }
195
+ }
196
+
197
+ if description:
198
+ payload["fields"]["description"] = {
199
+ "content": [
200
+ {"content": [{"text": description, "type": "text"}], "type": "paragraph"}
201
+ ],
202
+ "type": "doc",
203
+ "version": 1,
204
+ }
205
+
206
+ response = await self._client.post(url, json=payload)
207
+
208
+ response.raise_for_status()
209
+ jsoned = response.json()
210
+ return jsoned["key"]
211
+
139
212
  async def __aenter__(self) -> "JiraClient":
140
213
  """Async context manager entry."""
141
214
  return self
@@ -41,7 +41,7 @@ async def jira_get_issue(
41
41
  async with JiraClient(access_token) as client:
42
42
  issue = await client.get_jira_issue(issue_key)
43
43
  except Exception as e:
44
- logger.error(f"Unexpected error getting Jira issue: {e}")
44
+ logger.error(f"Unexpected error while getting Jira issue: {e}")
45
45
  raise ToolError(
46
46
  f"An unexpected error occurred while getting Jira issue '{issue_key}': {str(e)}"
47
47
  )
@@ -50,3 +50,52 @@ async def jira_get_issue(
50
50
  content=f"Successfully retrieved details for issue '{issue_key}'.",
51
51
  structured_content=issue.as_flat_dict(),
52
52
  )
53
+
54
+
55
+ @dr_mcp_tool(tags={"jira", "create", "add", "issue"})
56
+ async def jira_create_issue(
57
+ *,
58
+ project_key: Annotated[str, "The key of the project where the issue should be created."],
59
+ summary: Annotated[str, "A brief summary or title for the new issue."],
60
+ issue_type: Annotated[str, "The type of issue to create (e.g., 'Task', 'Bug', 'Story')."],
61
+ description: Annotated[str | None, "Detailed description of the issue."] = None,
62
+ ) -> ToolResult:
63
+ """Create a new Jira issue with mandatory project, summary, and type information."""
64
+ if not all([project_key, summary, issue_type]):
65
+ raise ToolError(
66
+ "Argument validation error: project_key, summary, and issue_type are required fields."
67
+ )
68
+
69
+ access_token = await get_atlassian_access_token()
70
+ if isinstance(access_token, ToolError):
71
+ raise access_token
72
+
73
+ async with JiraClient(access_token) as client:
74
+ # Maybe we should cache it somehow?
75
+ # It'll be probably constant through whole mcp server lifecycle...
76
+ issue_types = await client.get_jira_issue_types(project_key=project_key)
77
+
78
+ try:
79
+ issue_type_id = issue_types[issue_type]
80
+ except KeyError:
81
+ possible_issue_types = ",".join(issue_types)
82
+ raise ToolError(
83
+ f"Unexpected issue type `{issue_type}`. Possible values are {possible_issue_types}."
84
+ )
85
+
86
+ try:
87
+ async with JiraClient(access_token) as client:
88
+ issue_key = await client.create_jira_issue(
89
+ project_key=project_key,
90
+ summary=summary,
91
+ issue_type_id=issue_type_id,
92
+ description=description,
93
+ )
94
+ except Exception as e:
95
+ logger.error(f"Unexpected error while creating Jira issue: {e}")
96
+ raise ToolError(f"An unexpected error occurred while creating Jira issue: {str(e)}")
97
+
98
+ return ToolResult(
99
+ content=f"Successfully created issue '{issue_key}'.",
100
+ structured_content={"newIssueKey": issue_key, "projectKey": project_key},
101
+ )
@@ -14,6 +14,7 @@
14
14
 
15
15
  from collections.abc import AsyncGenerator
16
16
  from typing import Any
17
+ from typing import TypeVar
17
18
 
18
19
  from crewai import LLM
19
20
  from langchain_openai import ChatOpenAI
@@ -22,12 +23,32 @@ from llama_index.llms.litellm import LiteLLM
22
23
  from nat.builder.builder import Builder
23
24
  from nat.builder.framework_enum import LLMFrameworkEnum
24
25
  from nat.cli.register_workflow import register_llm_client
26
+ from nat.data_models.llm import LLMBaseConfig
27
+ from nat.data_models.retry_mixin import RetryMixin
28
+ from nat.plugins.langchain.llm import (
29
+ _patch_llm_based_on_config as langchain_patch_llm_based_on_config,
30
+ )
31
+ from nat.utils.exception_handlers.automatic_retries import patch_with_retry
25
32
 
26
33
  from ..nat.datarobot_llm_providers import DataRobotLLMComponentModelConfig
27
34
  from ..nat.datarobot_llm_providers import DataRobotLLMDeploymentModelConfig
28
35
  from ..nat.datarobot_llm_providers import DataRobotLLMGatewayModelConfig
29
36
  from ..nat.datarobot_llm_providers import DataRobotNIMModelConfig
30
37
 
38
+ ModelType = TypeVar("ModelType")
39
+
40
+
41
+ def _patch_llm_based_on_config(client: ModelType, llm_config: LLMBaseConfig) -> ModelType:
42
+ if isinstance(llm_config, RetryMixin):
43
+ client = patch_with_retry(
44
+ client,
45
+ retries=llm_config.num_retries,
46
+ retry_codes=llm_config.retry_on_status_codes,
47
+ retry_on_messages=llm_config.retry_on_errors,
48
+ )
49
+
50
+ return client
51
+
31
52
 
32
53
  class DataRobotChatOpenAI(ChatOpenAI):
33
54
  def _get_request_payload(
@@ -77,7 +98,8 @@ async def datarobot_llm_gateway_langchain(
77
98
  config["base_url"] = config["base_url"] + "/genai/llmgw"
78
99
  config["stream_options"] = {"include_usage": True}
79
100
  config["model"] = config["model"].removeprefix("datarobot/")
80
- yield DataRobotChatOpenAI(**config)
101
+ client = DataRobotChatOpenAI(**config)
102
+ yield langchain_patch_llm_based_on_config(client, config)
81
103
 
82
104
 
83
105
  @register_llm_client(
@@ -90,7 +112,8 @@ async def datarobot_llm_gateway_crewai(
90
112
  if not config["model"].startswith("datarobot/"):
91
113
  config["model"] = "datarobot/" + config["model"]
92
114
  config["base_url"] = config["base_url"].removesuffix("/api/v2")
93
- yield LLM(**config)
115
+ client = LLM(**config)
116
+ yield _patch_llm_based_on_config(client, config)
94
117
 
95
118
 
96
119
  @register_llm_client(
@@ -103,7 +126,8 @@ async def datarobot_llm_gateway_llamaindex(
103
126
  if not config["model"].startswith("datarobot/"):
104
127
  config["model"] = "datarobot/" + config["model"]
105
128
  config["api_base"] = config.pop("base_url").removesuffix("/api/v2")
106
- yield DataRobotLiteLLM(**config)
129
+ client = DataRobotLiteLLM(**config)
130
+ yield _patch_llm_based_on_config(client, config)
107
131
 
108
132
 
109
133
  @register_llm_client(
@@ -119,7 +143,8 @@ async def datarobot_llm_deployment_langchain(
119
143
  )
120
144
  config["stream_options"] = {"include_usage": True}
121
145
  config["model"] = config["model"].removeprefix("datarobot/")
122
- yield DataRobotChatOpenAI(**config)
146
+ client = DataRobotChatOpenAI(**config)
147
+ yield langchain_patch_llm_based_on_config(client, config)
123
148
 
124
149
 
125
150
  @register_llm_client(
@@ -136,7 +161,8 @@ async def datarobot_llm_deployment_crewai(
136
161
  if not config["model"].startswith("datarobot/"):
137
162
  config["model"] = "datarobot/" + config["model"]
138
163
  config["api_base"] = config.pop("base_url") + "/chat/completions"
139
- yield LLM(**config)
164
+ client = LLM(**config)
165
+ yield _patch_llm_based_on_config(client, config)
140
166
 
141
167
 
142
168
  @register_llm_client(
@@ -153,7 +179,8 @@ async def datarobot_llm_deployment_llamaindex(
153
179
  if not config["model"].startswith("datarobot/"):
154
180
  config["model"] = "datarobot/" + config["model"]
155
181
  config["api_base"] = config.pop("base_url") + "/chat/completions"
156
- yield DataRobotLiteLLM(**config)
182
+ client = DataRobotLiteLLM(**config)
183
+ yield _patch_llm_based_on_config(client, config)
157
184
 
158
185
 
159
186
  @register_llm_client(config_type=DataRobotNIMModelConfig, wrapper_type=LLMFrameworkEnum.LANGCHAIN)
@@ -167,7 +194,8 @@ async def datarobot_nim_langchain(
167
194
  )
168
195
  config["stream_options"] = {"include_usage": True}
169
196
  config["model"] = config["model"].removeprefix("datarobot/")
170
- yield DataRobotChatOpenAI(**config)
197
+ client = DataRobotChatOpenAI(**config)
198
+ yield langchain_patch_llm_based_on_config(client, config)
171
199
 
172
200
 
173
201
  @register_llm_client(config_type=DataRobotNIMModelConfig, wrapper_type=LLMFrameworkEnum.CREWAI)
@@ -182,7 +210,8 @@ async def datarobot_nim_crewai(
182
210
  if not config["model"].startswith("datarobot/"):
183
211
  config["model"] = "datarobot/" + config["model"]
184
212
  config["api_base"] = config.pop("base_url") + "/chat/completions"
185
- yield LLM(**config)
213
+ client = LLM(**config)
214
+ yield _patch_llm_based_on_config(client, config)
186
215
 
187
216
 
188
217
  @register_llm_client(config_type=DataRobotNIMModelConfig, wrapper_type=LLMFrameworkEnum.LLAMA_INDEX)
@@ -197,7 +226,8 @@ async def datarobot_nim_llamaindex(
197
226
  if not config["model"].startswith("datarobot/"):
198
227
  config["model"] = "datarobot/" + config["model"]
199
228
  config["api_base"] = config.pop("base_url") + "/chat/completions"
200
- yield DataRobotLiteLLM(**config)
229
+ client = DataRobotLiteLLM(**config)
230
+ yield _patch_llm_based_on_config(client, config)
201
231
 
202
232
 
203
233
  @register_llm_client(
@@ -212,7 +242,8 @@ async def datarobot_llm_component_langchain(
212
242
  config["stream_options"] = {"include_usage": True}
213
243
  config["model"] = config["model"].removeprefix("datarobot/")
214
244
  config.pop("use_datarobot_llm_gateway")
215
- yield DataRobotChatOpenAI(**config)
245
+ client = DataRobotChatOpenAI(**config)
246
+ yield langchain_patch_llm_based_on_config(client, config)
216
247
 
217
248
 
218
249
  @register_llm_client(
@@ -229,7 +260,8 @@ async def datarobot_llm_component_crewai(
229
260
  else:
230
261
  config["api_base"] = config.pop("base_url") + "/chat/completions"
231
262
  config.pop("use_datarobot_llm_gateway")
232
- yield LLM(**config)
263
+ client = LLM(**config)
264
+ yield _patch_llm_based_on_config(client, config)
233
265
 
234
266
 
235
267
  @register_llm_client(
@@ -246,4 +278,5 @@ async def datarobot_llm_component_llamaindex(
246
278
  else:
247
279
  config["api_base"] = config.pop("base_url") + "/chat/completions"
248
280
  config.pop("use_datarobot_llm_gateway")
249
- yield DataRobotLiteLLM(**config)
281
+ client = DataRobotLiteLLM(**config)
282
+ yield _patch_llm_based_on_config(client, config)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datarobot-genai
3
- Version: 0.2.11
3
+ Version: 0.2.13
4
4
  Summary: Generic helpers for GenAI
5
5
  Project-URL: Homepage, https://github.com/datarobot-oss/datarobot-genai
6
6
  Author: DataRobot, Inc.
@@ -77,12 +77,12 @@ datarobot_genai/drmcp/tools/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosH
77
77
  datarobot_genai/drmcp/tools/clients/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosHbZ5k-V9a5g,578
78
78
  datarobot_genai/drmcp/tools/clients/atlassian.py,sha256=__M_uz7FrcbKCYRzeMn24DCEYD6OmFx_LuywHCxgXsA,6472
79
79
  datarobot_genai/drmcp/tools/clients/confluence.py,sha256=gbVxeBe7RDEEQt5UMGGW6GoAXsYLhL009dOejYIaIiQ,6325
80
- datarobot_genai/drmcp/tools/clients/jira.py,sha256=r-sShBRTuc6nnqeFJBDu5zSU1C3mQyGnBMz9ymBSVLc,4201
80
+ datarobot_genai/drmcp/tools/clients/jira.py,sha256=aSDmw07SqpoE5fMQchb_y3Ggn4WcTUZU_1M8TwvZ3-E,6498
81
81
  datarobot_genai/drmcp/tools/clients/s3.py,sha256=GmwzvurFdNfvxOooA8g5S4osRysHYU0S9ypg_177Glg,953
82
82
  datarobot_genai/drmcp/tools/confluence/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosHbZ5k-V9a5g,578
83
83
  datarobot_genai/drmcp/tools/confluence/tools.py,sha256=t5OqXIhUm6y9bAWymyqwEMElwTxGw1xRnkW2MgJrNF8,3106
84
84
  datarobot_genai/drmcp/tools/jira/__init__.py,sha256=0kq9vMkF7EBsS6lkEdiLibmUrghTQqosHbZ5k-V9a5g,578
85
- datarobot_genai/drmcp/tools/jira/tools.py,sha256=53SYttMWriJ-9_tByE3G_ctuMvV6iHPms6La6llF9R0,1962
85
+ datarobot_genai/drmcp/tools/jira/tools.py,sha256=LBJkK9yjgRNZJHaqgJ3bknNnvLKpr2RLLtQYAs-O-oA,4034
86
86
  datarobot_genai/drmcp/tools/predictive/__init__.py,sha256=WuOHlNNEpEmcF7gVnhckruJRKU2qtmJLE3E7zoCGLDo,1030
87
87
  datarobot_genai/drmcp/tools/predictive/data.py,sha256=k4EJxJrl8DYVGVfJ0DM4YTfnZlC_K3OUHZ0eRUzfluI,3165
88
88
  datarobot_genai/drmcp/tools/predictive/deployment.py,sha256=lm02Ayuo11L1hP41fgi3QpR1Eyty-Wc16rM0c8SgliM,3277
@@ -102,12 +102,12 @@ datarobot_genai/llama_index/mcp.py,sha256=leXqF1C4zhuYEKFwNEfZHY4dsUuGZk3W7KArY-
102
102
  datarobot_genai/nat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
103
  datarobot_genai/nat/agent.py,sha256=jDeIS9f-8vGbeLy5gQkSjeuHINx5Fh_4BvXYERsgIIk,10516
104
104
  datarobot_genai/nat/datarobot_auth_provider.py,sha256=Z4NSsrHxK8hUeiqtK_lryHsUuZC74ziNo_FHbsZgtiM,4230
105
- datarobot_genai/nat/datarobot_llm_clients.py,sha256=STzAZ4OF8U-Y_cUTywxmKBGVotwsnbGP6vTojnu6q0g,9921
105
+ datarobot_genai/nat/datarobot_llm_clients.py,sha256=Yu208Ed_p_4P3HdpuM7fYnKcXtimORHpKlWVPyijpU8,11356
106
106
  datarobot_genai/nat/datarobot_llm_providers.py,sha256=aDoQcTeGI-odqydPXEX9OGGNFbzAtpqzTvHHEkmJuEQ,4963
107
107
  datarobot_genai/nat/datarobot_mcp_client.py,sha256=35FzilxNp4VqwBYI0NsOc91-xZm1C-AzWqrOdDy962A,9612
108
- datarobot_genai-0.2.11.dist-info/METADATA,sha256=1PyKkEq0poyLVzakstjxt-wgJ4un02i0vFthu3qbv9Q,6301
109
- datarobot_genai-0.2.11.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
110
- datarobot_genai-0.2.11.dist-info/entry_points.txt,sha256=jEW3WxDZ8XIK9-ISmTyt5DbmBb047rFlzQuhY09rGrM,284
111
- datarobot_genai-0.2.11.dist-info/licenses/AUTHORS,sha256=isJGUXdjq1U7XZ_B_9AH8Qf0u4eX0XyQifJZ_Sxm4sA,80
112
- datarobot_genai-0.2.11.dist-info/licenses/LICENSE,sha256=U2_VkLIktQoa60Nf6Tbt7E4RMlfhFSjWjcJJfVC-YCE,11341
113
- datarobot_genai-0.2.11.dist-info/RECORD,,
108
+ datarobot_genai-0.2.13.dist-info/METADATA,sha256=RJZ6ozRm3L6oreEu4D9gGKZLzlf3xoC7tZ3RrppBc_U,6301
109
+ datarobot_genai-0.2.13.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
110
+ datarobot_genai-0.2.13.dist-info/entry_points.txt,sha256=jEW3WxDZ8XIK9-ISmTyt5DbmBb047rFlzQuhY09rGrM,284
111
+ datarobot_genai-0.2.13.dist-info/licenses/AUTHORS,sha256=isJGUXdjq1U7XZ_B_9AH8Qf0u4eX0XyQifJZ_Sxm4sA,80
112
+ datarobot_genai-0.2.13.dist-info/licenses/LICENSE,sha256=U2_VkLIktQoa60Nf6Tbt7E4RMlfhFSjWjcJJfVC-YCE,11341
113
+ datarobot_genai-0.2.13.dist-info/RECORD,,