airia 0.1.26__py3-none-any.whl → 0.1.28__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.
- airia/client/async_client.py +2 -0
- airia/client/models/async_models.py +60 -0
- airia/client/models/base_models.py +34 -0
- airia/client/models/sync_models.py +58 -0
- airia/client/pipelines_config/async_pipelines_config.py +50 -0
- airia/client/pipelines_config/base_pipelines_config.py +37 -0
- airia/client/pipelines_config/sync_pipelines_config.py +50 -0
- airia/client/sync_client.py +2 -0
- airia/client/tools/__init__.py +4 -0
- airia/client/tools/async_tools.py +259 -0
- airia/client/tools/base_tools.py +153 -0
- airia/client/tools/sync_tools.py +245 -0
- airia/types/api/__init__.py +1 -0
- airia/types/api/tools/__init__.py +7 -0
- airia/types/api/tools/_tools.py +245 -0
- {airia-0.1.26.dist-info → airia-0.1.28.dist-info}/METADATA +1 -1
- {airia-0.1.26.dist-info → airia-0.1.28.dist-info}/RECORD +20 -14
- {airia-0.1.26.dist-info → airia-0.1.28.dist-info}/WHEEL +0 -0
- {airia-0.1.26.dist-info → airia-0.1.28.dist-info}/licenses/LICENSE +0 -0
- {airia-0.1.26.dist-info → airia-0.1.28.dist-info}/top_level.txt +0 -0
airia/client/async_client.py
CHANGED
|
@@ -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(
|
|
@@ -94,3 +94,63 @@ class AsyncModels(BaseModels):
|
|
|
94
94
|
return []
|
|
95
95
|
|
|
96
96
|
return [ModelItem(**item) for item in resp["items"]]
|
|
97
|
+
|
|
98
|
+
async def delete_model(
|
|
99
|
+
self,
|
|
100
|
+
model_id: str,
|
|
101
|
+
correlation_id: Optional[str] = None,
|
|
102
|
+
) -> None:
|
|
103
|
+
"""
|
|
104
|
+
Delete a model by its ID.
|
|
105
|
+
|
|
106
|
+
This method permanently deletes a model from the Airia platform. Once deleted,
|
|
107
|
+
the model cannot be recovered. Only models that the authenticated user has
|
|
108
|
+
permission to delete can be removed.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
model_id (str): The unique identifier of the model to delete.
|
|
112
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
113
|
+
and logging. If not provided, one will be automatically generated.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
None
|
|
117
|
+
|
|
118
|
+
Raises:
|
|
119
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
120
|
+
- Model not found (404)
|
|
121
|
+
- Authentication fails (401)
|
|
122
|
+
- Access is forbidden (403)
|
|
123
|
+
- Server errors (5xx)
|
|
124
|
+
|
|
125
|
+
Example:
|
|
126
|
+
```python
|
|
127
|
+
from airia import AiriaAsyncClient
|
|
128
|
+
|
|
129
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
130
|
+
|
|
131
|
+
# Delete a specific model
|
|
132
|
+
await client.models.delete_model(
|
|
133
|
+
model_id="12345678-1234-1234-1234-123456789abc"
|
|
134
|
+
)
|
|
135
|
+
print("Model deleted successfully")
|
|
136
|
+
|
|
137
|
+
# Delete with correlation ID for tracking
|
|
138
|
+
await client.models.delete_model(
|
|
139
|
+
model_id="12345678-1234-1234-1234-123456789abc",
|
|
140
|
+
correlation_id="my-correlation-id"
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Note:
|
|
145
|
+
This operation is irreversible. Ensure you have the correct model ID
|
|
146
|
+
before calling this method. You must have delete permissions for the
|
|
147
|
+
specified model.
|
|
148
|
+
"""
|
|
149
|
+
request_data = self._pre_delete_model(
|
|
150
|
+
model_id=model_id,
|
|
151
|
+
correlation_id=correlation_id,
|
|
152
|
+
api_version=ApiVersion.V1.value,
|
|
153
|
+
)
|
|
154
|
+
await self._request_handler.make_request(
|
|
155
|
+
"DELETE", request_data, return_json=False
|
|
156
|
+
)
|
|
@@ -66,3 +66,37 @@ class BaseModels:
|
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
return request_data
|
|
69
|
+
|
|
70
|
+
def _pre_delete_model(
|
|
71
|
+
self,
|
|
72
|
+
model_id: str,
|
|
73
|
+
correlation_id: Optional[str] = None,
|
|
74
|
+
api_version: str = ApiVersion.V1.value,
|
|
75
|
+
):
|
|
76
|
+
"""
|
|
77
|
+
Prepare request data for deleting a model.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
model_id: The ID of the model to delete
|
|
81
|
+
correlation_id: Optional correlation ID for tracing
|
|
82
|
+
api_version: API version to use for the request
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
RequestData: Prepared request data for the delete endpoint
|
|
86
|
+
|
|
87
|
+
Raises:
|
|
88
|
+
ValueError: If an invalid API version is provided
|
|
89
|
+
"""
|
|
90
|
+
if api_version not in ApiVersion.as_list():
|
|
91
|
+
raise ValueError(
|
|
92
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
url = urljoin(
|
|
96
|
+
self._request_handler.base_url,
|
|
97
|
+
f"{api_version}/Models/{model_id}",
|
|
98
|
+
)
|
|
99
|
+
request_data = self._request_handler.prepare_request(
|
|
100
|
+
url, correlation_id=correlation_id
|
|
101
|
+
)
|
|
102
|
+
return request_data
|
|
@@ -94,3 +94,61 @@ class Models(BaseModels):
|
|
|
94
94
|
return []
|
|
95
95
|
|
|
96
96
|
return [ModelItem(**item) for item in resp["items"]]
|
|
97
|
+
|
|
98
|
+
def delete_model(
|
|
99
|
+
self,
|
|
100
|
+
model_id: str,
|
|
101
|
+
correlation_id: Optional[str] = None,
|
|
102
|
+
) -> None:
|
|
103
|
+
"""
|
|
104
|
+
Delete a model by its ID.
|
|
105
|
+
|
|
106
|
+
This method permanently deletes a model from the Airia platform. Once deleted,
|
|
107
|
+
the model cannot be recovered. Only models that the authenticated user has
|
|
108
|
+
permission to delete can be removed.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
model_id (str): The unique identifier of the model to delete.
|
|
112
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
113
|
+
and logging. If not provided, one will be automatically generated.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
None
|
|
117
|
+
|
|
118
|
+
Raises:
|
|
119
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
120
|
+
- Model not found (404)
|
|
121
|
+
- Authentication fails (401)
|
|
122
|
+
- Access is forbidden (403)
|
|
123
|
+
- Server errors (5xx)
|
|
124
|
+
|
|
125
|
+
Example:
|
|
126
|
+
```python
|
|
127
|
+
from airia import AiriaClient
|
|
128
|
+
|
|
129
|
+
client = AiriaClient(api_key="your_api_key")
|
|
130
|
+
|
|
131
|
+
# Delete a specific model
|
|
132
|
+
client.models.delete_model(
|
|
133
|
+
model_id="12345678-1234-1234-1234-123456789abc"
|
|
134
|
+
)
|
|
135
|
+
print("Model deleted successfully")
|
|
136
|
+
|
|
137
|
+
# Delete with correlation ID for tracking
|
|
138
|
+
client.models.delete_model(
|
|
139
|
+
model_id="12345678-1234-1234-1234-123456789abc",
|
|
140
|
+
correlation_id="my-correlation-id"
|
|
141
|
+
)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Note:
|
|
145
|
+
This operation is irreversible. Ensure you have the correct model ID
|
|
146
|
+
before calling this method. You must have delete permissions for the
|
|
147
|
+
specified model.
|
|
148
|
+
"""
|
|
149
|
+
request_data = self._pre_delete_model(
|
|
150
|
+
model_id=model_id,
|
|
151
|
+
correlation_id=correlation_id,
|
|
152
|
+
api_version=ApiVersion.V1.value,
|
|
153
|
+
)
|
|
154
|
+
self._request_handler.make_request("DELETE", request_data, return_json=False)
|
|
@@ -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)
|
airia/client/sync_client.py
CHANGED
|
@@ -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
|
+
)
|