airia 0.1.26__tar.gz → 0.1.27__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.
- {airia-0.1.26 → airia-0.1.27}/PKG-INFO +1 -1
- {airia-0.1.26 → airia-0.1.27}/airia/client/async_client.py +2 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipelines_config/async_pipelines_config.py +50 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipelines_config/base_pipelines_config.py +37 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipelines_config/sync_pipelines_config.py +50 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/sync_client.py +2 -0
- airia-0.1.27/airia/client/tools/__init__.py +4 -0
- airia-0.1.27/airia/client/tools/async_tools.py +259 -0
- airia-0.1.27/airia/client/tools/base_tools.py +153 -0
- airia-0.1.27/airia/client/tools/sync_tools.py +245 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/__init__.py +1 -0
- airia-0.1.27/airia/types/api/tools/__init__.py +7 -0
- airia-0.1.27/airia/types/api/tools/_tools.py +223 -0
- {airia-0.1.26 → airia-0.1.27}/airia.egg-info/PKG-INFO +1 -1
- {airia-0.1.26 → airia-0.1.27}/airia.egg-info/SOURCES.txt +6 -0
- {airia-0.1.26 → airia-0.1.27}/pyproject.toml +1 -1
- {airia-0.1.26 → airia-0.1.27}/LICENSE +0 -0
- {airia-0.1.26 → airia-0.1.27}/README.md +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/_request_handler/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/_request_handler/async_request_handler.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/_request_handler/base_request_handler.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/_request_handler/sync_request_handler.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/attachments/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/attachments/async_attachments.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/attachments/base_attachments.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/attachments/sync_attachments.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/base_client.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/conversations/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/conversations/async_conversations.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/conversations/base_conversations.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/conversations/sync_conversations.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/data_vector_search/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/data_vector_search/async_data_vector_search.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/data_vector_search/base_data_vector_search.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/data_vector_search/sync_data_vector_search.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/deployments/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/deployments/async_deployments.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/deployments/base_deployments.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/deployments/sync_deployments.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/library/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/library/async_library.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/library/base_library.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/library/sync_library.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/models/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/models/async_models.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/models/base_models.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/models/sync_models.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipeline_execution/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipeline_execution/async_pipeline_execution.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipeline_execution/base_pipeline_execution.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipeline_execution/sync_pipeline_execution.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipeline_import/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipeline_import/async_pipeline_import.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipeline_import/base_pipeline_import.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipeline_import/sync_pipeline_import.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/pipelines_config/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/project/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/project/async_project.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/project/base_project.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/project/sync_project.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/store/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/store/async_store.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/store/base_store.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/client/store/sync_store.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/constants.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/exceptions.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/logs.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/_api_version.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/_request_data.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/attachments/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/attachments/upload_file.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/conversations/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/conversations/_conversations.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/data_vector_search/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/data_vector_search/get_file_chunks.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/deployments/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/deployments/get_deployment.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/deployments/get_deployments.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/library/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/library/_library_models.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/models/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/models/list_models.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/pipeline_execution/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/pipeline_execution/_pipeline_execution.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/pipeline_import/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/pipeline_import/create_agent_from_pipeline_definition.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/pipelines_config/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/pipelines_config/export_pipeline_definition.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/pipelines_config/get_pipeline_config.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/pipelines_config/get_pipelines_config.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/project/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/project/get_projects.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/store/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/store/get_file.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/api/store/get_files.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/sse/__init__.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/types/sse/sse_messages.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia/utils/sse_parser.py +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia.egg-info/dependency_links.txt +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia.egg-info/requires.txt +0 -0
- {airia-0.1.26 → airia-0.1.27}/airia.egg-info/top_level.txt +0 -0
- {airia-0.1.26 → airia-0.1.27}/setup.cfg +0 -0
|
@@ -21,6 +21,7 @@ from .pipeline_import import AsyncPipelineImport
|
|
|
21
21
|
from .pipelines_config import AsyncPipelinesConfig
|
|
22
22
|
from .project import AsyncProject
|
|
23
23
|
from .store import AsyncStore
|
|
24
|
+
from .tools import AsyncTools
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class AiriaAsyncClient(AiriaBaseClient):
|
|
@@ -74,6 +75,7 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
74
75
|
self.data_vector_search = AsyncDataVectorSearch(self._request_handler)
|
|
75
76
|
self.library = AsyncLibrary(self._request_handler)
|
|
76
77
|
self.models = AsyncModels(self._request_handler)
|
|
78
|
+
self.tools = AsyncTools(self._request_handler)
|
|
77
79
|
|
|
78
80
|
@classmethod
|
|
79
81
|
def with_openai_gateway(
|
|
@@ -188,3 +188,53 @@ class AsyncPipelinesConfig(BasePipelinesConfig):
|
|
|
188
188
|
resp = await self._request_handler.make_request("GET", request_data)
|
|
189
189
|
|
|
190
190
|
return GetPipelinesConfigResponse(**resp)
|
|
191
|
+
|
|
192
|
+
async def delete_pipeline(
|
|
193
|
+
self,
|
|
194
|
+
pipeline_id: str,
|
|
195
|
+
correlation_id: Optional[str] = None,
|
|
196
|
+
) -> None:
|
|
197
|
+
"""
|
|
198
|
+
Delete a pipeline by its ID.
|
|
199
|
+
|
|
200
|
+
This method permanently removes a pipeline and all its configuration
|
|
201
|
+
from the Airia platform. This action cannot be undone.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
pipeline_id (str): The unique identifier of the pipeline to delete.
|
|
205
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
206
|
+
and logging. If not provided, one will be automatically generated.
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
None: This method returns nothing upon successful deletion (204 No Content).
|
|
210
|
+
|
|
211
|
+
Raises:
|
|
212
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
213
|
+
- The pipeline_id doesn't exist (404)
|
|
214
|
+
- Authentication fails (401)
|
|
215
|
+
- Access is forbidden (403)
|
|
216
|
+
- Server errors (5xx)
|
|
217
|
+
|
|
218
|
+
Example:
|
|
219
|
+
```python
|
|
220
|
+
from airia import AiriaAsyncClient
|
|
221
|
+
|
|
222
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
223
|
+
|
|
224
|
+
# Delete a pipeline
|
|
225
|
+
await client.pipelines_config.delete_pipeline(
|
|
226
|
+
pipeline_id="your_pipeline_id"
|
|
227
|
+
)
|
|
228
|
+
print("Pipeline deleted successfully")
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Warning:
|
|
232
|
+
This operation is permanent and cannot be reversed. Ensure you have
|
|
233
|
+
the correct pipeline_id before calling this method.
|
|
234
|
+
"""
|
|
235
|
+
request_data = self._pre_delete_pipeline(
|
|
236
|
+
pipeline_id=pipeline_id,
|
|
237
|
+
correlation_id=correlation_id,
|
|
238
|
+
api_version=ApiVersion.V1.value,
|
|
239
|
+
)
|
|
240
|
+
await self._request_handler.make_request("DELETE", request_data, return_json=False)
|
|
@@ -114,3 +114,40 @@ class BasePipelinesConfig:
|
|
|
114
114
|
)
|
|
115
115
|
|
|
116
116
|
return request_data
|
|
117
|
+
|
|
118
|
+
def _pre_delete_pipeline(
|
|
119
|
+
self,
|
|
120
|
+
pipeline_id: str,
|
|
121
|
+
correlation_id: Optional[str] = None,
|
|
122
|
+
api_version: str = ApiVersion.V1.value,
|
|
123
|
+
):
|
|
124
|
+
"""
|
|
125
|
+
Prepare request data for deleting a pipeline by ID.
|
|
126
|
+
|
|
127
|
+
This internal method constructs the URL for pipeline deletion
|
|
128
|
+
requests using the provided pipeline identifier.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
pipeline_id: ID of the pipeline to delete
|
|
132
|
+
correlation_id: Optional correlation ID for tracing
|
|
133
|
+
api_version: API version to use for the request
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
RequestData: Prepared request data for the pipeline deletion endpoint
|
|
137
|
+
|
|
138
|
+
Raises:
|
|
139
|
+
ValueError: If an invalid API version is provided
|
|
140
|
+
"""
|
|
141
|
+
if api_version not in ApiVersion.as_list():
|
|
142
|
+
raise ValueError(
|
|
143
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
144
|
+
)
|
|
145
|
+
url = urljoin(
|
|
146
|
+
self._request_handler.base_url,
|
|
147
|
+
f"{api_version}/PipelinesConfig/{pipeline_id}",
|
|
148
|
+
)
|
|
149
|
+
request_data = self._request_handler.prepare_request(
|
|
150
|
+
url, correlation_id=correlation_id
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return request_data
|
|
@@ -188,3 +188,53 @@ class PipelinesConfig(BasePipelinesConfig):
|
|
|
188
188
|
resp = self._request_handler.make_request("GET", request_data)
|
|
189
189
|
|
|
190
190
|
return GetPipelinesConfigResponse(**resp)
|
|
191
|
+
|
|
192
|
+
def delete_pipeline(
|
|
193
|
+
self,
|
|
194
|
+
pipeline_id: str,
|
|
195
|
+
correlation_id: Optional[str] = None,
|
|
196
|
+
) -> None:
|
|
197
|
+
"""
|
|
198
|
+
Delete a pipeline by its ID.
|
|
199
|
+
|
|
200
|
+
This method permanently removes a pipeline and all its configuration
|
|
201
|
+
from the Airia platform. This action cannot be undone.
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
pipeline_id (str): The unique identifier of the pipeline to delete.
|
|
205
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
206
|
+
and logging. If not provided, one will be automatically generated.
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
None: This method returns nothing upon successful deletion (204 No Content).
|
|
210
|
+
|
|
211
|
+
Raises:
|
|
212
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
213
|
+
- The pipeline_id doesn't exist (404)
|
|
214
|
+
- Authentication fails (401)
|
|
215
|
+
- Access is forbidden (403)
|
|
216
|
+
- Server errors (5xx)
|
|
217
|
+
|
|
218
|
+
Example:
|
|
219
|
+
```python
|
|
220
|
+
from airia import AiriaClient
|
|
221
|
+
|
|
222
|
+
client = AiriaClient(api_key="your_api_key")
|
|
223
|
+
|
|
224
|
+
# Delete a pipeline
|
|
225
|
+
client.pipelines_config.delete_pipeline(
|
|
226
|
+
pipeline_id="your_pipeline_id"
|
|
227
|
+
)
|
|
228
|
+
print("Pipeline deleted successfully")
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Warning:
|
|
232
|
+
This operation is permanent and cannot be reversed. Ensure you have
|
|
233
|
+
the correct pipeline_id before calling this method.
|
|
234
|
+
"""
|
|
235
|
+
request_data = self._pre_delete_pipeline(
|
|
236
|
+
pipeline_id=pipeline_id,
|
|
237
|
+
correlation_id=correlation_id,
|
|
238
|
+
api_version=ApiVersion.V1.value,
|
|
239
|
+
)
|
|
240
|
+
self._request_handler.make_request("DELETE", request_data, return_json=False)
|
|
@@ -21,6 +21,7 @@ from .pipeline_import import PipelineImport
|
|
|
21
21
|
from .pipelines_config import PipelinesConfig
|
|
22
22
|
from .project import Project
|
|
23
23
|
from .store import Store
|
|
24
|
+
from .tools import Tools
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class AiriaClient(AiriaBaseClient):
|
|
@@ -74,6 +75,7 @@ class AiriaClient(AiriaBaseClient):
|
|
|
74
75
|
self.data_vector_search = DataVectorSearch(self._request_handler)
|
|
75
76
|
self.library = Library(self._request_handler)
|
|
76
77
|
self.models = Models(self._request_handler)
|
|
78
|
+
self.tools = Tools(self._request_handler)
|
|
77
79
|
|
|
78
80
|
@classmethod
|
|
79
81
|
def with_openai_gateway(
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Optional, Literal
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.tools import CreateToolResponse
|
|
5
|
+
from .._request_handler import AsyncRequestHandler
|
|
6
|
+
from .base_tools import BaseTools
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncTools(BaseTools):
|
|
10
|
+
def __init__(self, request_handler: AsyncRequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
async def create_tool(
|
|
14
|
+
self,
|
|
15
|
+
name: str,
|
|
16
|
+
description: str,
|
|
17
|
+
purpose: str,
|
|
18
|
+
api_endpoint: str,
|
|
19
|
+
method_type: str,
|
|
20
|
+
body: str,
|
|
21
|
+
tool_credentials: Dict[str, Any],
|
|
22
|
+
headers: List[Dict[str, str]] = [],
|
|
23
|
+
parameters: List[Dict[str, Any]] = [],
|
|
24
|
+
request_timeout: int = 100,
|
|
25
|
+
body_type: Literal["Json", "XFormUrlEncoded", "None"] = "Json",
|
|
26
|
+
category: Literal["Action", "Airia", "Mcp"] = "Airia",
|
|
27
|
+
tool_type: str = "Custom",
|
|
28
|
+
provider: str = "Custom",
|
|
29
|
+
route_through_acc: bool = False,
|
|
30
|
+
should_redirect: bool = True,
|
|
31
|
+
acc_group: Optional[str] = None,
|
|
32
|
+
documentation: Optional[str] = None,
|
|
33
|
+
project_id: Optional[str] = None,
|
|
34
|
+
tags: Optional[List[str]] = None,
|
|
35
|
+
tool_metadata: Optional[List[Dict[str, Any]]] = None,
|
|
36
|
+
correlation_id: Optional[str] = None,
|
|
37
|
+
) -> CreateToolResponse:
|
|
38
|
+
"""
|
|
39
|
+
Create a new tool in the Airia platform.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
name (str): Name of the tool.
|
|
43
|
+
description (str): Brief description of what the tool does.
|
|
44
|
+
Example: "Use this tool to get the current weather in a given location."
|
|
45
|
+
api_endpoint (str): Web API endpoint where the tool sends its requests to
|
|
46
|
+
perform its task.
|
|
47
|
+
method_type (str): HTTP method type. Valid values: "Get", "Post", "Put", "Delete".
|
|
48
|
+
purpose (str): When and why to use this tool.
|
|
49
|
+
Example: "When a user asks about the weather, including current conditions,
|
|
50
|
+
forecasts, or specific weather events."
|
|
51
|
+
body_type (str): Type of the request body. Valid values: "Json", "XFormUrlEncoded", "None".
|
|
52
|
+
category (str): Category of the tool. Valid values: "Action", "Airia", "Mcp".
|
|
53
|
+
provider (str): Provider of the tool.
|
|
54
|
+
tool_type (str): Type of the tool. Valid values: "Custom", "Calculator", "MCP",
|
|
55
|
+
"LoadMemory", "StoreMemory", etc.
|
|
56
|
+
body (str): Body of the request that the tool sends to the API.
|
|
57
|
+
headers (list[dict]): List of headers required when making the API request.
|
|
58
|
+
Each header should be a dictionary with "key" and "value" fields.
|
|
59
|
+
Example: [{"key": "Content-Type", "value": "application/json"}]
|
|
60
|
+
parameters (list[dict]): Collection of parameters required by the tool
|
|
61
|
+
to execute its function.
|
|
62
|
+
request_timeout (int): Request timeout in seconds for tool execution.
|
|
63
|
+
route_through_acc (bool): Flag indicating whether the tool should route
|
|
64
|
+
through the ACC.
|
|
65
|
+
should_redirect (bool): Flag indicating whether the tool should redirect
|
|
66
|
+
with authorization header attached.
|
|
67
|
+
tool_credentials (dict): Tool credentials model.
|
|
68
|
+
acc_group (str, optional): ACC specific group name. If provided, the tool will
|
|
69
|
+
route through this ACC group.
|
|
70
|
+
documentation (str, optional): Documentation for the tool.
|
|
71
|
+
project_id (str, optional): Unique identifier of the project to which the tool
|
|
72
|
+
is associated.
|
|
73
|
+
tags (list[str], optional): List of tags for the tool.
|
|
74
|
+
tool_metadata (list[dict], optional): User provided metadata for the tool definition.
|
|
75
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
76
|
+
and logging. If not provided, one will be automatically generated.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
CreateToolResponse: A response object containing the created tool details
|
|
80
|
+
including its ID, creation timestamp, configuration, credentials,
|
|
81
|
+
parameters, and all provided metadata.
|
|
82
|
+
|
|
83
|
+
Raises:
|
|
84
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
85
|
+
- Invalid parameters are provided (400)
|
|
86
|
+
- Authentication fails (401)
|
|
87
|
+
- Access is forbidden (403)
|
|
88
|
+
- Server errors (5xx)
|
|
89
|
+
|
|
90
|
+
Example:
|
|
91
|
+
```python
|
|
92
|
+
from airia import AiriaAsyncClient
|
|
93
|
+
import asyncio
|
|
94
|
+
|
|
95
|
+
async def main():
|
|
96
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
97
|
+
|
|
98
|
+
# Create a weather tool with all required parameters
|
|
99
|
+
tool = await client.tools.create_tool(
|
|
100
|
+
name="get_weather",
|
|
101
|
+
description="Use this tool to get the current weather in a given location.",
|
|
102
|
+
api_endpoint="https://api.weather.com/v1/current",
|
|
103
|
+
method_type="Get",
|
|
104
|
+
purpose="When a user asks about the weather, including current conditions.",
|
|
105
|
+
body_type="None",
|
|
106
|
+
category="Action",
|
|
107
|
+
provider="WeatherAPI",
|
|
108
|
+
tool_type="Custom",
|
|
109
|
+
body="",
|
|
110
|
+
headers=[],
|
|
111
|
+
parameters=[],
|
|
112
|
+
request_timeout=100,
|
|
113
|
+
route_through_acc=False,
|
|
114
|
+
should_redirect=False,
|
|
115
|
+
tool_credentials={}
|
|
116
|
+
)
|
|
117
|
+
print(f"Created tool: {tool.id}")
|
|
118
|
+
|
|
119
|
+
# Create an email tool with headers and optional parameters
|
|
120
|
+
tool = await client.tools.create_tool(
|
|
121
|
+
name="send_email",
|
|
122
|
+
description="Send an email to a recipient.",
|
|
123
|
+
api_endpoint="https://api.email-service.com/v1/send",
|
|
124
|
+
method_type="Post",
|
|
125
|
+
purpose="When a user wants to send an email message.",
|
|
126
|
+
body_type="Json",
|
|
127
|
+
category="Action",
|
|
128
|
+
provider="EmailService",
|
|
129
|
+
tool_type="Custom",
|
|
130
|
+
body='{"to": "{{recipient}}", "subject": "{{subject}}", "body": "{{message}}"}',
|
|
131
|
+
headers=[
|
|
132
|
+
{"key": "Content-Type", "value": "application/json"},
|
|
133
|
+
{"key": "Authorization", "value": "Bearer {{api_key}}"}
|
|
134
|
+
],
|
|
135
|
+
parameters=[
|
|
136
|
+
{"name": "recipient", "type": "string", "required": True},
|
|
137
|
+
{"name": "subject", "type": "string", "required": True},
|
|
138
|
+
{"name": "message", "type": "string", "required": True}
|
|
139
|
+
],
|
|
140
|
+
request_timeout=120,
|
|
141
|
+
route_through_acc=False,
|
|
142
|
+
should_redirect=False,
|
|
143
|
+
tool_credentials={},
|
|
144
|
+
documentation="This tool sends emails using the Email Service API.",
|
|
145
|
+
tags=["email", "communication"]
|
|
146
|
+
)
|
|
147
|
+
print(f"Created email tool: {tool.id}")
|
|
148
|
+
|
|
149
|
+
await client.close()
|
|
150
|
+
|
|
151
|
+
asyncio.run(main())
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Note:
|
|
155
|
+
- Required parameters: name, description, api_endpoint, method_type, purpose,
|
|
156
|
+
body_type, category, provider, tool_type, body, headers, parameters,
|
|
157
|
+
request_timeout, route_through_acc, should_redirect, and tool_credentials.
|
|
158
|
+
- Optional parameters: acc_group, documentation, project_id, tags, and tool_metadata.
|
|
159
|
+
- The method_type must be one of: "Get", "Post", "Put", "Delete"
|
|
160
|
+
- The body_type must be one of: "Json", "XFormUrlEncoded", "None"
|
|
161
|
+
- The category must be one of: "Action", "Airia", "Mcp"
|
|
162
|
+
- The tool_type must be one of: "Custom", "Calculator", "MCP", "LoadMemory",
|
|
163
|
+
"StoreMemory", etc.
|
|
164
|
+
"""
|
|
165
|
+
request_data = self._pre_create_tool(
|
|
166
|
+
name=name,
|
|
167
|
+
description=description,
|
|
168
|
+
api_endpoint=api_endpoint,
|
|
169
|
+
method_type=method_type,
|
|
170
|
+
purpose=purpose,
|
|
171
|
+
body_type=body_type,
|
|
172
|
+
category=category,
|
|
173
|
+
provider=provider,
|
|
174
|
+
tool_type=tool_type,
|
|
175
|
+
body=body,
|
|
176
|
+
headers=headers,
|
|
177
|
+
parameters=parameters,
|
|
178
|
+
request_timeout=request_timeout,
|
|
179
|
+
route_through_acc=route_through_acc,
|
|
180
|
+
should_redirect=should_redirect,
|
|
181
|
+
tool_credentials=tool_credentials,
|
|
182
|
+
acc_group=acc_group,
|
|
183
|
+
documentation=documentation,
|
|
184
|
+
project_id=project_id,
|
|
185
|
+
tags=tags,
|
|
186
|
+
tool_metadata=tool_metadata,
|
|
187
|
+
correlation_id=correlation_id,
|
|
188
|
+
api_version=ApiVersion.V1.value,
|
|
189
|
+
)
|
|
190
|
+
resp = await self._request_handler.make_request("POST", request_data)
|
|
191
|
+
|
|
192
|
+
return CreateToolResponse(**resp)
|
|
193
|
+
|
|
194
|
+
async def delete_tool(
|
|
195
|
+
self,
|
|
196
|
+
tool_id: str,
|
|
197
|
+
correlation_id: Optional[str] = None,
|
|
198
|
+
) -> None:
|
|
199
|
+
"""
|
|
200
|
+
Delete a tool by its ID.
|
|
201
|
+
|
|
202
|
+
This method permanently removes a tool from the Airia platform.
|
|
203
|
+
This action cannot be undone.
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
tool_id (str): The unique identifier of the tool to delete.
|
|
207
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
208
|
+
and logging. If not provided, one will be automatically generated.
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
None: This method returns nothing upon successful deletion.
|
|
212
|
+
|
|
213
|
+
Raises:
|
|
214
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
215
|
+
- The tool_id doesn't exist (404)
|
|
216
|
+
- Authentication fails (401)
|
|
217
|
+
- Access is forbidden (403)
|
|
218
|
+
- Server errors (5xx)
|
|
219
|
+
|
|
220
|
+
Example:
|
|
221
|
+
```python
|
|
222
|
+
from airia import AiriaAsyncClient
|
|
223
|
+
import asyncio
|
|
224
|
+
|
|
225
|
+
async def main():
|
|
226
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
227
|
+
|
|
228
|
+
# Delete a tool
|
|
229
|
+
await client.tools.delete_tool(tool_id="tool_123")
|
|
230
|
+
print("Tool deleted successfully")
|
|
231
|
+
|
|
232
|
+
# Handle deletion errors
|
|
233
|
+
from airia.exceptions import AiriaAPIError
|
|
234
|
+
|
|
235
|
+
try:
|
|
236
|
+
await client.tools.delete_tool(tool_id="nonexistent_id")
|
|
237
|
+
except AiriaAPIError as e:
|
|
238
|
+
if e.status_code == 404:
|
|
239
|
+
print("Tool not found")
|
|
240
|
+
else:
|
|
241
|
+
print(f"Error deleting tool: {e.message}")
|
|
242
|
+
|
|
243
|
+
await client.close()
|
|
244
|
+
|
|
245
|
+
asyncio.run(main())
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Note:
|
|
249
|
+
This operation is permanent and cannot be undone. Make sure you have
|
|
250
|
+
the correct tool_id before calling this method.
|
|
251
|
+
"""
|
|
252
|
+
request_data = self._pre_delete_tool(
|
|
253
|
+
tool_id=tool_id,
|
|
254
|
+
correlation_id=correlation_id,
|
|
255
|
+
api_version=ApiVersion.V1.value,
|
|
256
|
+
)
|
|
257
|
+
await self._request_handler.make_request(
|
|
258
|
+
"DELETE", request_data, return_json=False
|
|
259
|
+
)
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Optional, Union
|
|
2
|
+
from urllib.parse import urljoin
|
|
3
|
+
|
|
4
|
+
from ...types._api_version import ApiVersion
|
|
5
|
+
from .._request_handler import AsyncRequestHandler, RequestHandler
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BaseTools:
|
|
9
|
+
def __init__(self, request_handler: Union[RequestHandler, AsyncRequestHandler]):
|
|
10
|
+
self._request_handler = request_handler
|
|
11
|
+
|
|
12
|
+
def _pre_create_tool(
|
|
13
|
+
self,
|
|
14
|
+
name: str,
|
|
15
|
+
description: str,
|
|
16
|
+
api_endpoint: str,
|
|
17
|
+
method_type: str,
|
|
18
|
+
purpose: str,
|
|
19
|
+
body_type: str,
|
|
20
|
+
category: str,
|
|
21
|
+
provider: str,
|
|
22
|
+
tool_type: str,
|
|
23
|
+
body: str,
|
|
24
|
+
headers: List[Dict[str, str]],
|
|
25
|
+
parameters: List[Dict[str, Any]],
|
|
26
|
+
request_timeout: int,
|
|
27
|
+
route_through_acc: bool,
|
|
28
|
+
should_redirect: bool,
|
|
29
|
+
tool_credentials: Dict[str, Any],
|
|
30
|
+
acc_group: Optional[str] = None,
|
|
31
|
+
documentation: Optional[str] = None,
|
|
32
|
+
project_id: Optional[str] = None,
|
|
33
|
+
tags: Optional[List[str]] = None,
|
|
34
|
+
tool_metadata: Optional[List[Dict[str, Any]]] = None,
|
|
35
|
+
correlation_id: Optional[str] = None,
|
|
36
|
+
api_version: str = ApiVersion.V1.value,
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
Prepare request data for creating a new tool.
|
|
40
|
+
|
|
41
|
+
This internal method constructs the URL and payload for tool creation
|
|
42
|
+
requests, including all tool configuration and metadata.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
name: Name of the tool
|
|
46
|
+
description: Brief description of what the tool does
|
|
47
|
+
api_endpoint: Web API endpoint where the tool sends its requests
|
|
48
|
+
method_type: HTTP method type (Get, Post, Put, Delete)
|
|
49
|
+
purpose: When and why to use this tool
|
|
50
|
+
body_type: Type of the request body (Json, XFormUrlEncoded, None)
|
|
51
|
+
category: Category of the tool (Action, Airia, Mcp)
|
|
52
|
+
provider: Provider of the tool
|
|
53
|
+
tool_type: Type of the tool (Custom, Calculator, MCP, etc.)
|
|
54
|
+
body: Body of the request that the tool sends to the API
|
|
55
|
+
headers: List of headers required when making the API request
|
|
56
|
+
parameters: Collection of parameters required by the tool
|
|
57
|
+
request_timeout: Request timeout in seconds for tool execution
|
|
58
|
+
route_through_acc: Flag indicating whether the tool should route through the ACC
|
|
59
|
+
should_redirect: Flag indicating whether the tool should redirect with authorization header
|
|
60
|
+
tool_credentials: Tool credentials
|
|
61
|
+
acc_group: Optional ACC specific group name
|
|
62
|
+
documentation: Optional documentation for the tool
|
|
63
|
+
project_id: Optional unique identifier of the project to which the tool is associated
|
|
64
|
+
tags: Optional list of tags for the tool
|
|
65
|
+
tool_metadata: Optional user provided metadata for the tool definition
|
|
66
|
+
correlation_id: Optional correlation ID for tracing
|
|
67
|
+
api_version: API version to use for the request
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
RequestData: Prepared request data for the tool creation endpoint
|
|
71
|
+
|
|
72
|
+
Raises:
|
|
73
|
+
ValueError: If an invalid API version is provided
|
|
74
|
+
"""
|
|
75
|
+
if api_version not in ApiVersion.as_list():
|
|
76
|
+
raise ValueError(
|
|
77
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
78
|
+
)
|
|
79
|
+
url = urljoin(self._request_handler.base_url, f"{api_version}/Tools")
|
|
80
|
+
|
|
81
|
+
payload: Dict[str, Any] = {
|
|
82
|
+
"name": name,
|
|
83
|
+
"description": description,
|
|
84
|
+
"apiEndpoint": api_endpoint,
|
|
85
|
+
"methodType": method_type,
|
|
86
|
+
"purpose": purpose,
|
|
87
|
+
"bodyType": body_type,
|
|
88
|
+
"category": category,
|
|
89
|
+
"provider": provider,
|
|
90
|
+
"toolType": tool_type,
|
|
91
|
+
"body": body,
|
|
92
|
+
"headers": headers,
|
|
93
|
+
"parameters": parameters,
|
|
94
|
+
"requestTimeout": request_timeout,
|
|
95
|
+
"routeThroughACC": route_through_acc,
|
|
96
|
+
"shouldRedirect": should_redirect,
|
|
97
|
+
"toolCredentials": tool_credentials,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# Add optional fields only if they are provided
|
|
101
|
+
if acc_group is not None:
|
|
102
|
+
payload["accGroup"] = acc_group
|
|
103
|
+
if documentation is not None:
|
|
104
|
+
payload["documentation"] = documentation
|
|
105
|
+
if project_id is not None:
|
|
106
|
+
payload["projectId"] = project_id
|
|
107
|
+
if tags is not None:
|
|
108
|
+
payload["tags"] = tags
|
|
109
|
+
if tool_metadata is not None:
|
|
110
|
+
payload["toolMetadata"] = tool_metadata
|
|
111
|
+
|
|
112
|
+
request_data = self._request_handler.prepare_request(
|
|
113
|
+
url=url, payload=payload, correlation_id=correlation_id
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
return request_data
|
|
117
|
+
|
|
118
|
+
def _pre_delete_tool(
|
|
119
|
+
self,
|
|
120
|
+
tool_id: str,
|
|
121
|
+
correlation_id: Optional[str] = None,
|
|
122
|
+
api_version: str = ApiVersion.V1.value,
|
|
123
|
+
):
|
|
124
|
+
"""
|
|
125
|
+
Prepare request data for deleting a tool by ID.
|
|
126
|
+
|
|
127
|
+
This internal method constructs the URL for tool deletion
|
|
128
|
+
requests using the provided tool identifier.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
tool_id: ID of the tool to delete
|
|
132
|
+
correlation_id: Optional correlation ID for tracing
|
|
133
|
+
api_version: API version to use for the request
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
RequestData: Prepared request data for the tool deletion endpoint
|
|
137
|
+
|
|
138
|
+
Raises:
|
|
139
|
+
ValueError: If an invalid API version is provided
|
|
140
|
+
"""
|
|
141
|
+
if api_version not in ApiVersion.as_list():
|
|
142
|
+
raise ValueError(
|
|
143
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
144
|
+
)
|
|
145
|
+
url = urljoin(
|
|
146
|
+
self._request_handler.base_url,
|
|
147
|
+
f"{api_version}/Tools/{tool_id}",
|
|
148
|
+
)
|
|
149
|
+
request_data = self._request_handler.prepare_request(
|
|
150
|
+
url, correlation_id=correlation_id
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
return request_data
|