airia 0.1.26__tar.gz → 0.1.28__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.
Files changed (105) hide show
  1. {airia-0.1.26 → airia-0.1.28}/PKG-INFO +1 -1
  2. {airia-0.1.26 → airia-0.1.28}/airia/client/async_client.py +2 -0
  3. {airia-0.1.26 → airia-0.1.28}/airia/client/models/async_models.py +60 -0
  4. {airia-0.1.26 → airia-0.1.28}/airia/client/models/base_models.py +34 -0
  5. {airia-0.1.26 → airia-0.1.28}/airia/client/models/sync_models.py +58 -0
  6. {airia-0.1.26 → airia-0.1.28}/airia/client/pipelines_config/async_pipelines_config.py +50 -0
  7. {airia-0.1.26 → airia-0.1.28}/airia/client/pipelines_config/base_pipelines_config.py +37 -0
  8. {airia-0.1.26 → airia-0.1.28}/airia/client/pipelines_config/sync_pipelines_config.py +50 -0
  9. {airia-0.1.26 → airia-0.1.28}/airia/client/sync_client.py +2 -0
  10. airia-0.1.28/airia/client/tools/__init__.py +4 -0
  11. airia-0.1.28/airia/client/tools/async_tools.py +259 -0
  12. airia-0.1.28/airia/client/tools/base_tools.py +153 -0
  13. airia-0.1.28/airia/client/tools/sync_tools.py +245 -0
  14. {airia-0.1.26 → airia-0.1.28}/airia/types/api/__init__.py +1 -0
  15. airia-0.1.28/airia/types/api/tools/__init__.py +7 -0
  16. airia-0.1.28/airia/types/api/tools/_tools.py +245 -0
  17. {airia-0.1.26 → airia-0.1.28}/airia.egg-info/PKG-INFO +1 -1
  18. {airia-0.1.26 → airia-0.1.28}/airia.egg-info/SOURCES.txt +6 -0
  19. {airia-0.1.26 → airia-0.1.28}/pyproject.toml +1 -1
  20. {airia-0.1.26 → airia-0.1.28}/LICENSE +0 -0
  21. {airia-0.1.26 → airia-0.1.28}/README.md +0 -0
  22. {airia-0.1.26 → airia-0.1.28}/airia/__init__.py +0 -0
  23. {airia-0.1.26 → airia-0.1.28}/airia/client/__init__.py +0 -0
  24. {airia-0.1.26 → airia-0.1.28}/airia/client/_request_handler/__init__.py +0 -0
  25. {airia-0.1.26 → airia-0.1.28}/airia/client/_request_handler/async_request_handler.py +0 -0
  26. {airia-0.1.26 → airia-0.1.28}/airia/client/_request_handler/base_request_handler.py +0 -0
  27. {airia-0.1.26 → airia-0.1.28}/airia/client/_request_handler/sync_request_handler.py +0 -0
  28. {airia-0.1.26 → airia-0.1.28}/airia/client/attachments/__init__.py +0 -0
  29. {airia-0.1.26 → airia-0.1.28}/airia/client/attachments/async_attachments.py +0 -0
  30. {airia-0.1.26 → airia-0.1.28}/airia/client/attachments/base_attachments.py +0 -0
  31. {airia-0.1.26 → airia-0.1.28}/airia/client/attachments/sync_attachments.py +0 -0
  32. {airia-0.1.26 → airia-0.1.28}/airia/client/base_client.py +0 -0
  33. {airia-0.1.26 → airia-0.1.28}/airia/client/conversations/__init__.py +0 -0
  34. {airia-0.1.26 → airia-0.1.28}/airia/client/conversations/async_conversations.py +0 -0
  35. {airia-0.1.26 → airia-0.1.28}/airia/client/conversations/base_conversations.py +0 -0
  36. {airia-0.1.26 → airia-0.1.28}/airia/client/conversations/sync_conversations.py +0 -0
  37. {airia-0.1.26 → airia-0.1.28}/airia/client/data_vector_search/__init__.py +0 -0
  38. {airia-0.1.26 → airia-0.1.28}/airia/client/data_vector_search/async_data_vector_search.py +0 -0
  39. {airia-0.1.26 → airia-0.1.28}/airia/client/data_vector_search/base_data_vector_search.py +0 -0
  40. {airia-0.1.26 → airia-0.1.28}/airia/client/data_vector_search/sync_data_vector_search.py +0 -0
  41. {airia-0.1.26 → airia-0.1.28}/airia/client/deployments/__init__.py +0 -0
  42. {airia-0.1.26 → airia-0.1.28}/airia/client/deployments/async_deployments.py +0 -0
  43. {airia-0.1.26 → airia-0.1.28}/airia/client/deployments/base_deployments.py +0 -0
  44. {airia-0.1.26 → airia-0.1.28}/airia/client/deployments/sync_deployments.py +0 -0
  45. {airia-0.1.26 → airia-0.1.28}/airia/client/library/__init__.py +0 -0
  46. {airia-0.1.26 → airia-0.1.28}/airia/client/library/async_library.py +0 -0
  47. {airia-0.1.26 → airia-0.1.28}/airia/client/library/base_library.py +0 -0
  48. {airia-0.1.26 → airia-0.1.28}/airia/client/library/sync_library.py +0 -0
  49. {airia-0.1.26 → airia-0.1.28}/airia/client/models/__init__.py +0 -0
  50. {airia-0.1.26 → airia-0.1.28}/airia/client/pipeline_execution/__init__.py +0 -0
  51. {airia-0.1.26 → airia-0.1.28}/airia/client/pipeline_execution/async_pipeline_execution.py +0 -0
  52. {airia-0.1.26 → airia-0.1.28}/airia/client/pipeline_execution/base_pipeline_execution.py +0 -0
  53. {airia-0.1.26 → airia-0.1.28}/airia/client/pipeline_execution/sync_pipeline_execution.py +0 -0
  54. {airia-0.1.26 → airia-0.1.28}/airia/client/pipeline_import/__init__.py +0 -0
  55. {airia-0.1.26 → airia-0.1.28}/airia/client/pipeline_import/async_pipeline_import.py +0 -0
  56. {airia-0.1.26 → airia-0.1.28}/airia/client/pipeline_import/base_pipeline_import.py +0 -0
  57. {airia-0.1.26 → airia-0.1.28}/airia/client/pipeline_import/sync_pipeline_import.py +0 -0
  58. {airia-0.1.26 → airia-0.1.28}/airia/client/pipelines_config/__init__.py +0 -0
  59. {airia-0.1.26 → airia-0.1.28}/airia/client/project/__init__.py +0 -0
  60. {airia-0.1.26 → airia-0.1.28}/airia/client/project/async_project.py +0 -0
  61. {airia-0.1.26 → airia-0.1.28}/airia/client/project/base_project.py +0 -0
  62. {airia-0.1.26 → airia-0.1.28}/airia/client/project/sync_project.py +0 -0
  63. {airia-0.1.26 → airia-0.1.28}/airia/client/store/__init__.py +0 -0
  64. {airia-0.1.26 → airia-0.1.28}/airia/client/store/async_store.py +0 -0
  65. {airia-0.1.26 → airia-0.1.28}/airia/client/store/base_store.py +0 -0
  66. {airia-0.1.26 → airia-0.1.28}/airia/client/store/sync_store.py +0 -0
  67. {airia-0.1.26 → airia-0.1.28}/airia/constants.py +0 -0
  68. {airia-0.1.26 → airia-0.1.28}/airia/exceptions.py +0 -0
  69. {airia-0.1.26 → airia-0.1.28}/airia/logs.py +0 -0
  70. {airia-0.1.26 → airia-0.1.28}/airia/types/__init__.py +0 -0
  71. {airia-0.1.26 → airia-0.1.28}/airia/types/_api_version.py +0 -0
  72. {airia-0.1.26 → airia-0.1.28}/airia/types/_request_data.py +0 -0
  73. {airia-0.1.26 → airia-0.1.28}/airia/types/api/attachments/__init__.py +0 -0
  74. {airia-0.1.26 → airia-0.1.28}/airia/types/api/attachments/upload_file.py +0 -0
  75. {airia-0.1.26 → airia-0.1.28}/airia/types/api/conversations/__init__.py +0 -0
  76. {airia-0.1.26 → airia-0.1.28}/airia/types/api/conversations/_conversations.py +0 -0
  77. {airia-0.1.26 → airia-0.1.28}/airia/types/api/data_vector_search/__init__.py +0 -0
  78. {airia-0.1.26 → airia-0.1.28}/airia/types/api/data_vector_search/get_file_chunks.py +0 -0
  79. {airia-0.1.26 → airia-0.1.28}/airia/types/api/deployments/__init__.py +0 -0
  80. {airia-0.1.26 → airia-0.1.28}/airia/types/api/deployments/get_deployment.py +0 -0
  81. {airia-0.1.26 → airia-0.1.28}/airia/types/api/deployments/get_deployments.py +0 -0
  82. {airia-0.1.26 → airia-0.1.28}/airia/types/api/library/__init__.py +0 -0
  83. {airia-0.1.26 → airia-0.1.28}/airia/types/api/library/_library_models.py +0 -0
  84. {airia-0.1.26 → airia-0.1.28}/airia/types/api/models/__init__.py +0 -0
  85. {airia-0.1.26 → airia-0.1.28}/airia/types/api/models/list_models.py +0 -0
  86. {airia-0.1.26 → airia-0.1.28}/airia/types/api/pipeline_execution/__init__.py +0 -0
  87. {airia-0.1.26 → airia-0.1.28}/airia/types/api/pipeline_execution/_pipeline_execution.py +0 -0
  88. {airia-0.1.26 → airia-0.1.28}/airia/types/api/pipeline_import/__init__.py +0 -0
  89. {airia-0.1.26 → airia-0.1.28}/airia/types/api/pipeline_import/create_agent_from_pipeline_definition.py +0 -0
  90. {airia-0.1.26 → airia-0.1.28}/airia/types/api/pipelines_config/__init__.py +0 -0
  91. {airia-0.1.26 → airia-0.1.28}/airia/types/api/pipelines_config/export_pipeline_definition.py +0 -0
  92. {airia-0.1.26 → airia-0.1.28}/airia/types/api/pipelines_config/get_pipeline_config.py +0 -0
  93. {airia-0.1.26 → airia-0.1.28}/airia/types/api/pipelines_config/get_pipelines_config.py +0 -0
  94. {airia-0.1.26 → airia-0.1.28}/airia/types/api/project/__init__.py +0 -0
  95. {airia-0.1.26 → airia-0.1.28}/airia/types/api/project/get_projects.py +0 -0
  96. {airia-0.1.26 → airia-0.1.28}/airia/types/api/store/__init__.py +0 -0
  97. {airia-0.1.26 → airia-0.1.28}/airia/types/api/store/get_file.py +0 -0
  98. {airia-0.1.26 → airia-0.1.28}/airia/types/api/store/get_files.py +0 -0
  99. {airia-0.1.26 → airia-0.1.28}/airia/types/sse/__init__.py +0 -0
  100. {airia-0.1.26 → airia-0.1.28}/airia/types/sse/sse_messages.py +0 -0
  101. {airia-0.1.26 → airia-0.1.28}/airia/utils/sse_parser.py +0 -0
  102. {airia-0.1.26 → airia-0.1.28}/airia.egg-info/dependency_links.txt +0 -0
  103. {airia-0.1.26 → airia-0.1.28}/airia.egg-info/requires.txt +0 -0
  104. {airia-0.1.26 → airia-0.1.28}/airia.egg-info/top_level.txt +0 -0
  105. {airia-0.1.26 → airia-0.1.28}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: airia
3
- Version: 0.1.26
3
+ Version: 0.1.28
4
4
  Summary: Python SDK for Airia API
5
5
  Author-email: Airia LLC <support@airia.com>
6
6
  License: MIT
@@ -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)
@@ -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,4 @@
1
+ from .async_tools import AsyncTools
2
+ from .sync_tools import Tools
3
+
4
+ __all__ = ["Tools", "AsyncTools"]
@@ -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
+ )