alita-sdk 0.3.123__py3-none-any.whl → 0.3.125__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.
- alita_sdk/clients/client.py +12 -0
- alita_sdk/toolkits/tools.py +49 -0
- alita_sdk/tools/mcp_server_tool.py +58 -0
- {alita_sdk-0.3.123.dist-info → alita_sdk-0.3.125.dist-info}/METADATA +1 -1
- {alita_sdk-0.3.123.dist-info → alita_sdk-0.3.125.dist-info}/RECORD +8 -7
- {alita_sdk-0.3.123.dist-info → alita_sdk-0.3.125.dist-info}/WHEEL +0 -0
- {alita_sdk-0.3.123.dist-info → alita_sdk-0.3.125.dist-info}/licenses/LICENSE +0 -0
- {alita_sdk-0.3.123.dist-info → alita_sdk-0.3.125.dist-info}/top_level.txt +0 -0
alita_sdk/clients/client.py
CHANGED
@@ -50,6 +50,8 @@ class AlitaClient:
|
|
50
50
|
self.datasources_predict = f"{self.base_url}{self.api_path}/datasources/predict/prompt_lib/{self.project_id}"
|
51
51
|
self.datasources_search = f"{self.base_url}{self.api_path}/datasources/search/prompt_lib/{self.project_id}"
|
52
52
|
self.app = f"{self.base_url}{self.api_path}/applications/application/prompt_lib/{self.project_id}"
|
53
|
+
self.mcp_tools_list = f"{self.base_url}{self.api_path}/mcp_sse/tools_list/{self.project_id}"
|
54
|
+
self.mcp_tools_call = f"{self.base_url}{self.api_path}/mcp_sse/tools_call/{self.project_id}"
|
53
55
|
self.application_versions = f"{self.base_url}{self.api_path}/applications/version/prompt_lib/{self.project_id}"
|
54
56
|
self.list_apps_url = f"{self.base_url}{self.api_path}/applications/applications/prompt_lib/{self.project_id}"
|
55
57
|
self.integration_details = f"{self.base_url}{self.api_path}/integrations/integration/{self.project_id}"
|
@@ -61,6 +63,16 @@ class AlitaClient:
|
|
61
63
|
self.ai_section_url = f'{self.base_url}{self.api_path}/integrations/integrations/default/{self.project_id}?section=ai'
|
62
64
|
self.configurations: list = configurations or []
|
63
65
|
|
66
|
+
def get_mcp_toolkits(self):
|
67
|
+
url = self.mcp_tools_list
|
68
|
+
data = requests.get(url, headers=self.headers, verify=False).json()
|
69
|
+
return data
|
70
|
+
|
71
|
+
def mcp_tool_call(self, params: dict[str, Any]):
|
72
|
+
url = self.mcp_tools_call
|
73
|
+
data = requests.post(url, headers=self.headers, json=params, verify=False).json()
|
74
|
+
return data
|
75
|
+
|
64
76
|
def prompt(self, prompt_id, prompt_version_id, chat_history=None, return_tool=False):
|
65
77
|
url = f"{self.prompt_versions}/{prompt_id}/{prompt_version_id}"
|
66
78
|
data = requests.get(url, headers=self.headers, verify=False).json()
|
alita_sdk/toolkits/tools.py
CHANGED
@@ -13,6 +13,8 @@ from .vectorstore import VectorStoreToolkit
|
|
13
13
|
from ..community.analysis.jira_analyse import AnalyseJira
|
14
14
|
from ..community.browseruse import BrowserUseToolkit
|
15
15
|
|
16
|
+
from ..tools.mcp_server_tool import McpServerTool
|
17
|
+
|
16
18
|
logger = logging.getLogger(__name__)
|
17
19
|
|
18
20
|
|
@@ -36,6 +38,7 @@ def get_toolkits():
|
|
36
38
|
def get_tools(tools_list: list, alita: 'AlitaClient', llm: 'LLMLikeObject') -> list:
|
37
39
|
prompts = []
|
38
40
|
tools = []
|
41
|
+
|
39
42
|
for tool in tools_list:
|
40
43
|
if tool['type'] == 'prompt':
|
41
44
|
prompts.append([
|
@@ -82,4 +85,50 @@ def get_tools(tools_list: list, alita: 'AlitaClient', llm: 'LLMLikeObject') -> l
|
|
82
85
|
if len(prompts) > 0:
|
83
86
|
tools += PromptToolkit.get_toolkit(alita, prompts).get_tools()
|
84
87
|
tools += alita_tools(tools_list, alita, llm)
|
88
|
+
tools += _mcp_tools(tools_list, alita)
|
85
89
|
return tools
|
90
|
+
|
91
|
+
|
92
|
+
def _mcp_tools(tools_list, alita):
|
93
|
+
try:
|
94
|
+
all_available_toolkits = alita.get_mcp_toolkits()
|
95
|
+
toolkit_lookup = {tk["name"].lower(): tk for tk in all_available_toolkits}
|
96
|
+
tools = []
|
97
|
+
#
|
98
|
+
for selected_toolkit in tools_list:
|
99
|
+
toolkit_name = selected_toolkit['type'].lower()
|
100
|
+
toolkit_conf = toolkit_lookup.get(toolkit_name)
|
101
|
+
#
|
102
|
+
if not toolkit_conf:
|
103
|
+
logger.warning(f"Toolkit '{toolkit_name}' not found in available toolkits.")
|
104
|
+
continue
|
105
|
+
#
|
106
|
+
available_tools = toolkit_conf.get("tools", [])
|
107
|
+
selected_tools = [name.lower() for name in selected_toolkit['settings'].get('selected_tools', [])]
|
108
|
+
for available_tool in available_tools:
|
109
|
+
tool_name = available_tool.get("name", "").lower()
|
110
|
+
if not selected_tools or tool_name in selected_tools:
|
111
|
+
if server_tool := _init_single_mcp_tool(toolkit_name, available_tool, alita, selected_toolkit['settings']):
|
112
|
+
tools.append(server_tool)
|
113
|
+
return tools
|
114
|
+
except Exception:
|
115
|
+
logger.error("Error while fetching MCP tools", exc_info=True)
|
116
|
+
return []
|
117
|
+
|
118
|
+
|
119
|
+
def _init_single_mcp_tool(toolkit_name, available_tool, alita, toolkit_settings):
|
120
|
+
try:
|
121
|
+
tool_name = available_tool["name"]
|
122
|
+
return McpServerTool(
|
123
|
+
name=tool_name,
|
124
|
+
description=available_tool.get("description", ""),
|
125
|
+
args_schema=McpServerTool.create_pydantic_model_from_schema(
|
126
|
+
available_tool.get("inputSchema", {})
|
127
|
+
),
|
128
|
+
client=alita,
|
129
|
+
server=toolkit_name,
|
130
|
+
tool_timeout_sec=toolkit_settings["timeout"]
|
131
|
+
)
|
132
|
+
except Exception as e:
|
133
|
+
logger.error(f"Failed to create McpServerTool for '{toolkit_name}.{tool_name}': {e}")
|
134
|
+
return None
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import uuid
|
2
|
+
from logging import getLogger
|
3
|
+
from typing import Any, Type, Literal, Optional
|
4
|
+
|
5
|
+
from langchain_core.tools import BaseTool
|
6
|
+
from pydantic import BaseModel, Field, create_model
|
7
|
+
|
8
|
+
logger = getLogger(__name__)
|
9
|
+
|
10
|
+
|
11
|
+
class McpServerTool(BaseTool):
|
12
|
+
name: str
|
13
|
+
description: str
|
14
|
+
args_schema: Optional[Type[BaseModel]] = None
|
15
|
+
return_type: str = "str"
|
16
|
+
client: Any
|
17
|
+
server: str
|
18
|
+
tool_timeout_sec: int = 60
|
19
|
+
|
20
|
+
|
21
|
+
@staticmethod
|
22
|
+
def create_pydantic_model_from_schema(schema: dict):
|
23
|
+
fields = {}
|
24
|
+
for field_name, field_info in schema['properties'].items():
|
25
|
+
field_type = field_info['type']
|
26
|
+
field_description = field_info.get('description', '')
|
27
|
+
if field_type == 'string':
|
28
|
+
if 'enum' in field_info:
|
29
|
+
field_type = Literal[tuple(field_info['enum'])]
|
30
|
+
else:
|
31
|
+
field_type = str
|
32
|
+
elif field_type == 'integer':
|
33
|
+
field_type = int
|
34
|
+
elif field_type == 'number':
|
35
|
+
field_type = float
|
36
|
+
elif field_type == 'boolean':
|
37
|
+
field_type = bool
|
38
|
+
else:
|
39
|
+
raise ValueError(f"Unsupported field type: {field_type}")
|
40
|
+
|
41
|
+
if field_name in schema.get('required', []):
|
42
|
+
fields[field_name] = (field_type, Field(..., description=field_description))
|
43
|
+
else:
|
44
|
+
fields[field_name] = (Optional[field_type], Field(None, description=field_description))
|
45
|
+
return create_model('DynamicModel', **fields)
|
46
|
+
|
47
|
+
def _run(self, *args, **kwargs):
|
48
|
+
call_data = {
|
49
|
+
"server": self.server,
|
50
|
+
"tool_timeout_sec": self.tool_timeout_sec,
|
51
|
+
"tool_call_id": str(uuid.uuid4()),
|
52
|
+
"params": {
|
53
|
+
"name": self.name,
|
54
|
+
"arguments": kwargs
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
return self.client.mcp_tool_call(call_data)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: alita_sdk
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.125
|
4
4
|
Summary: SDK for building langchain agents using resouces from Alita
|
5
5
|
Author-email: Artem Rozumenko <artyom.rozumenko@gmail.com>, Mikalai Biazruchka <mikalai_biazruchka@epam.com>, Roman Mitusov <roman_mitusov@epam.com>, Ivan Krakhmaliuk <lifedjik@gmail.com>
|
6
6
|
Project-URL: Homepage, https://projectalita.ai
|
@@ -4,7 +4,7 @@ alita_sdk/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
4
4
|
alita_sdk/agents/llamaAgentParser.py,sha256=N_Nw6WJ8xrNX3fr_JFwjUIg_Urai9lLU3poMgZz0Cyk,1701
|
5
5
|
alita_sdk/clients/__init__.py,sha256=5O_7WsZmvg5z5uZf_Jkx-f8j5C6yKIuSwQR6AQ-TM84,31
|
6
6
|
alita_sdk/clients/artifact.py,sha256=W6oLlthtsUHfUWjhihaDdhLZdRVqj1D2j7oHHELxJfs,2639
|
7
|
-
alita_sdk/clients/client.py,sha256=
|
7
|
+
alita_sdk/clients/client.py,sha256=aBVoT9rX5D9vF2iGPywmjAi2CPM0m43NnHiKmKlTmPA,18475
|
8
8
|
alita_sdk/clients/datasource.py,sha256=HAZovoQN9jBg0_-lIlGBQzb4FJdczPhkHehAiVG3Wx0,1020
|
9
9
|
alita_sdk/clients/prompt.py,sha256=li1RG9eBwgNK_Qf0qUaZ8QNTmsncFrAL2pv3kbxZRZg,1447
|
10
10
|
alita_sdk/community/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -68,7 +68,7 @@ alita_sdk/toolkits/application.py,sha256=LrxbBV05lkRP3_WtKGBKtMdoQHXVY-_AtFr1cUu
|
|
68
68
|
alita_sdk/toolkits/artifact.py,sha256=7zb17vhJ3CigeTqvzQ4VNBsU5UOCJqAwz7fOJGMYqXw,2348
|
69
69
|
alita_sdk/toolkits/datasource.py,sha256=v3FQu8Gmvq7gAGAnFEbA8qofyUhh98rxgIjY6GHBfyI,2494
|
70
70
|
alita_sdk/toolkits/prompt.py,sha256=WIpTkkVYWqIqOWR_LlSWz3ug8uO9tm5jJ7aZYdiGRn0,1192
|
71
|
-
alita_sdk/toolkits/tools.py,sha256=
|
71
|
+
alita_sdk/toolkits/tools.py,sha256=RFMJ2bYNotPNmz6-clUdAakuIyrunSA16nFZ1gDFSF0,5273
|
72
72
|
alita_sdk/toolkits/vectorstore.py,sha256=di08-CRl0KJ9xSZ8_24VVnPZy58iLqHtXW8vuF29P64,2893
|
73
73
|
alita_sdk/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
74
74
|
alita_sdk/tools/application.py,sha256=UJlYd3Sub10LpAoKkKEpvd4miWyrS-yYE5NKyqx-H4Q,2194
|
@@ -80,6 +80,7 @@ alita_sdk/tools/indexer_tool.py,sha256=P9S_omk5TZkizb6UXyxMO87Pzj4UCaye0CuXBgCnh
|
|
80
80
|
alita_sdk/tools/llm.py,sha256=JA0OnSU13CLdkS5NFv6iRk8P7k-B47L-oPjk8xrzk48,3223
|
81
81
|
alita_sdk/tools/loop.py,sha256=uds0WhZvwMxDVFI6MZHrcmMle637cQfBNg682iLxoJA,8335
|
82
82
|
alita_sdk/tools/loop_output.py,sha256=NoGIGYc42wY3NNcWRijYzRnUVXcCn5cRVd8QmuIpoHU,8068
|
83
|
+
alita_sdk/tools/mcp_server_tool.py,sha256=xcH9AiqfR2TYrwJ3Ixw-_A7XDodtJCnwmq1SsikXpYk,1930
|
83
84
|
alita_sdk/tools/pgvector_search.py,sha256=NN2BGAnq4SsDHIhUcFZ8d_dbEOM8QwB0UwpsWCYruXU,11692
|
84
85
|
alita_sdk/tools/prompt.py,sha256=nJafb_e5aOM1Rr3qGFCR-SKziU9uCsiP2okIMs9PppM,741
|
85
86
|
alita_sdk/tools/router.py,sha256=wCvZjVkdXK9dMMeEerrgKf5M790RudH68pDortnHSz0,1517
|
@@ -91,10 +92,10 @@ alita_sdk/utils/evaluate.py,sha256=iM1P8gzBLHTuSCe85_Ng_h30m52hFuGuhNXJ7kB1tgI,1
|
|
91
92
|
alita_sdk/utils/logging.py,sha256=hBE3qAzmcLMdamMp2YRXwOOK9P4lmNaNhM76kntVljs,3124
|
92
93
|
alita_sdk/utils/streamlit.py,sha256=zp8owZwHI3HZplhcExJf6R3-APtWx-z6s5jznT2hY_k,29124
|
93
94
|
alita_sdk/utils/utils.py,sha256=dM8whOJAuFJFe19qJ69-FLzrUp6d2G-G6L7d4ss2XqM,346
|
94
|
-
alita_sdk-0.3.
|
95
|
+
alita_sdk-0.3.125.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
95
96
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
96
97
|
tests/test_jira_analysis.py,sha256=I0cErH5R_dHVyutpXrM1QEo7jfBuKWTmDQvJBPjx18I,3281
|
97
|
-
alita_sdk-0.3.
|
98
|
-
alita_sdk-0.3.
|
99
|
-
alita_sdk-0.3.
|
100
|
-
alita_sdk-0.3.
|
98
|
+
alita_sdk-0.3.125.dist-info/METADATA,sha256=raIYIJIfySOwIA5jp0DHo4UlVizFOhLpWwLwx9AhQi8,7075
|
99
|
+
alita_sdk-0.3.125.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
100
|
+
alita_sdk-0.3.125.dist-info/top_level.txt,sha256=SWRhxB7Et3cOy3RkE5hR7OIRnHoo3K8EXzoiNlkfOmc,25
|
101
|
+
alita_sdk-0.3.125.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|