airia 0.1.25__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.25 → airia-0.1.27}/PKG-INFO +1 -1
- {airia-0.1.25 → airia-0.1.27}/airia/client/_request_handler/async_request_handler.py +29 -8
- {airia-0.1.25 → airia-0.1.27}/airia/client/_request_handler/sync_request_handler.py +25 -8
- {airia-0.1.25 → airia-0.1.27}/airia/client/async_client.py +6 -0
- airia-0.1.27/airia/client/models/__init__.py +4 -0
- airia-0.1.27/airia/client/models/async_models.py +96 -0
- airia-0.1.27/airia/client/models/base_models.py +68 -0
- airia-0.1.27/airia/client/models/sync_models.py +96 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/pipeline_execution/async_pipeline_execution.py +3 -3
- {airia-0.1.25 → airia-0.1.27}/airia/client/pipeline_execution/base_pipeline_execution.py +1 -1
- {airia-0.1.25 → airia-0.1.27}/airia/client/pipeline_execution/sync_pipeline_execution.py +3 -3
- airia-0.1.27/airia/client/pipeline_import/__init__.py +4 -0
- airia-0.1.27/airia/client/pipeline_import/async_pipeline_import.py +147 -0
- airia-0.1.27/airia/client/pipeline_import/base_pipeline_import.py +95 -0
- airia-0.1.27/airia/client/pipeline_import/sync_pipeline_import.py +143 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/pipelines_config/async_pipelines_config.py +50 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/pipelines_config/base_pipelines_config.py +37 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/pipelines_config/sync_pipelines_config.py +50 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/sync_client.py +6 -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.25 → airia-0.1.27}/airia/exceptions.py +4 -3
- airia-0.1.27/airia/types/api/__init__.py +4 -0
- airia-0.1.27/airia/types/api/models/__init__.py +13 -0
- airia-0.1.27/airia/types/api/models/list_models.py +129 -0
- airia-0.1.27/airia/types/api/pipeline_import/__init__.py +11 -0
- airia-0.1.27/airia/types/api/pipeline_import/create_agent_from_pipeline_definition.py +108 -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.25 → airia-0.1.27}/airia.egg-info/PKG-INFO +1 -1
- {airia-0.1.25 → airia-0.1.27}/airia.egg-info/SOURCES.txt +18 -0
- {airia-0.1.25 → airia-0.1.27}/pyproject.toml +1 -1
- airia-0.1.25/airia/types/api/__init__.py +0 -1
- {airia-0.1.25 → airia-0.1.27}/LICENSE +0 -0
- {airia-0.1.25 → airia-0.1.27}/README.md +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/_request_handler/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/_request_handler/base_request_handler.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/attachments/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/attachments/async_attachments.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/attachments/base_attachments.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/attachments/sync_attachments.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/base_client.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/conversations/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/conversations/async_conversations.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/conversations/base_conversations.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/conversations/sync_conversations.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/data_vector_search/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/data_vector_search/async_data_vector_search.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/data_vector_search/base_data_vector_search.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/data_vector_search/sync_data_vector_search.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/deployments/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/deployments/async_deployments.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/deployments/base_deployments.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/deployments/sync_deployments.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/library/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/library/async_library.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/library/base_library.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/library/sync_library.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/pipeline_execution/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/pipelines_config/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/project/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/project/async_project.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/project/base_project.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/project/sync_project.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/store/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/store/async_store.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/store/base_store.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/client/store/sync_store.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/constants.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/logs.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/_api_version.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/_request_data.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/attachments/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/attachments/upload_file.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/conversations/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/conversations/_conversations.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/data_vector_search/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/data_vector_search/get_file_chunks.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/deployments/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/deployments/get_deployment.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/deployments/get_deployments.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/library/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/library/_library_models.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/pipeline_execution/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/pipeline_execution/_pipeline_execution.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/pipelines_config/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/pipelines_config/export_pipeline_definition.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/pipelines_config/get_pipeline_config.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/pipelines_config/get_pipelines_config.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/project/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/project/get_projects.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/store/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/store/get_file.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/api/store/get_files.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/sse/__init__.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/types/sse/sse_messages.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia/utils/sse_parser.py +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia.egg-info/dependency_links.txt +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia.egg-info/requires.txt +0 -0
- {airia-0.1.25 → airia-0.1.27}/airia.egg-info/top_level.txt +0 -0
- {airia-0.1.25 → airia-0.1.27}/setup.cfg +0 -0
|
@@ -65,12 +65,17 @@ class AsyncRequestHandler(BaseRequestHandler):
|
|
|
65
65
|
await self.session.close()
|
|
66
66
|
|
|
67
67
|
def _handle_exception(
|
|
68
|
-
self,
|
|
68
|
+
self,
|
|
69
|
+
e: aiohttp.ClientResponseError,
|
|
70
|
+
detailed_error: str,
|
|
71
|
+
url: str,
|
|
72
|
+
correlation_id: str,
|
|
69
73
|
):
|
|
70
74
|
# Log the error response if enabled
|
|
71
75
|
if self.log_requests:
|
|
72
76
|
self.logger.error(
|
|
73
77
|
f"API Error: {e.status} {e.message}\n"
|
|
78
|
+
f"Detailed Error Message: {detailed_error}\n"
|
|
74
79
|
f"URL: {url}\n"
|
|
75
80
|
f"Correlation ID: {correlation_id}"
|
|
76
81
|
)
|
|
@@ -88,7 +93,11 @@ class AsyncRequestHandler(BaseRequestHandler):
|
|
|
88
93
|
)
|
|
89
94
|
|
|
90
95
|
# Raise custom exception with status code and sanitized message
|
|
91
|
-
raise AiriaAPIError(
|
|
96
|
+
raise AiriaAPIError(
|
|
97
|
+
status_code=e.status,
|
|
98
|
+
message=sanitized_message,
|
|
99
|
+
detailed_message=detailed_error,
|
|
100
|
+
) from e
|
|
92
101
|
|
|
93
102
|
async def make_request(
|
|
94
103
|
self, method: str, request_data: RequestData, return_json: bool = True
|
|
@@ -137,14 +146,18 @@ class AsyncRequestHandler(BaseRequestHandler):
|
|
|
137
146
|
)
|
|
138
147
|
|
|
139
148
|
# Check for HTTP errors
|
|
140
|
-
response.
|
|
149
|
+
if not response.ok:
|
|
150
|
+
response_text = await response.text()
|
|
151
|
+
response.raise_for_status()
|
|
141
152
|
|
|
142
153
|
# Return the response as a dictionary
|
|
143
154
|
if return_json:
|
|
144
155
|
return await response.json()
|
|
145
156
|
|
|
146
157
|
except aiohttp.ClientResponseError as e:
|
|
147
|
-
self._handle_exception(
|
|
158
|
+
self._handle_exception(
|
|
159
|
+
e, response_text, request_data.url, request_data.correlation_id
|
|
160
|
+
)
|
|
148
161
|
|
|
149
162
|
async def make_request_stream(
|
|
150
163
|
self, method: str, request_data: RequestData
|
|
@@ -193,7 +206,9 @@ class AsyncRequestHandler(BaseRequestHandler):
|
|
|
193
206
|
)
|
|
194
207
|
|
|
195
208
|
# Check for HTTP errors
|
|
196
|
-
response.
|
|
209
|
+
if not response.ok:
|
|
210
|
+
response_text = await response.text()
|
|
211
|
+
response.raise_for_status()
|
|
197
212
|
|
|
198
213
|
# Yields the response content as a stream if streaming
|
|
199
214
|
async for message in async_parse_sse_stream_chunked(
|
|
@@ -202,7 +217,9 @@ class AsyncRequestHandler(BaseRequestHandler):
|
|
|
202
217
|
yield message
|
|
203
218
|
|
|
204
219
|
except aiohttp.ClientResponseError as e:
|
|
205
|
-
self._handle_exception(
|
|
220
|
+
self._handle_exception(
|
|
221
|
+
e, response_text, request_data.url, request_data.correlation_id
|
|
222
|
+
)
|
|
206
223
|
|
|
207
224
|
async def make_request_multipart(
|
|
208
225
|
self, method: str, request_data: RequestData, return_json: bool = True
|
|
@@ -262,11 +279,15 @@ class AsyncRequestHandler(BaseRequestHandler):
|
|
|
262
279
|
)
|
|
263
280
|
|
|
264
281
|
# Check for HTTP errors
|
|
265
|
-
response.
|
|
282
|
+
if not response.ok:
|
|
283
|
+
response_text = await response.text()
|
|
284
|
+
response.raise_for_status()
|
|
266
285
|
|
|
267
286
|
# Return the response as a dictionary
|
|
268
287
|
if return_json:
|
|
269
288
|
return await response.json()
|
|
270
289
|
|
|
271
290
|
except aiohttp.ClientResponseError as e:
|
|
272
|
-
self._handle_exception(
|
|
291
|
+
self._handle_exception(
|
|
292
|
+
e, response_text, request_data.url, request_data.correlation_id
|
|
293
|
+
)
|
|
@@ -48,11 +48,14 @@ class RequestHandler(BaseRequestHandler):
|
|
|
48
48
|
"""
|
|
49
49
|
self.session.close()
|
|
50
50
|
|
|
51
|
-
def _handle_exception(
|
|
51
|
+
def _handle_exception(
|
|
52
|
+
self, e: requests.HTTPError, detailed_error: str, url: str, correlation_id: str
|
|
53
|
+
):
|
|
52
54
|
# Log the error response if enabled
|
|
53
55
|
if self.log_requests:
|
|
54
56
|
self.logger.error(
|
|
55
57
|
f"API Error: {e.response.status_code} {e.response.reason}\n"
|
|
58
|
+
f"Detailed Error Message: {detailed_error}\n"
|
|
56
59
|
f"URL: {url}\n"
|
|
57
60
|
f"Correlation ID: {correlation_id}"
|
|
58
61
|
)
|
|
@@ -80,7 +83,9 @@ class RequestHandler(BaseRequestHandler):
|
|
|
80
83
|
|
|
81
84
|
# Raise custom exception with status code and sanitized message
|
|
82
85
|
raise AiriaAPIError(
|
|
83
|
-
status_code=e.response.status_code,
|
|
86
|
+
status_code=e.response.status_code,
|
|
87
|
+
message=sanitized_message,
|
|
88
|
+
detailed_message=detailed_error,
|
|
84
89
|
) from e
|
|
85
90
|
|
|
86
91
|
def make_request(
|
|
@@ -131,14 +136,18 @@ class RequestHandler(BaseRequestHandler):
|
|
|
131
136
|
)
|
|
132
137
|
|
|
133
138
|
# Check for HTTP errors
|
|
134
|
-
response.
|
|
139
|
+
if not response.ok:
|
|
140
|
+
response_text = response.text
|
|
141
|
+
response.raise_for_status()
|
|
135
142
|
|
|
136
143
|
# Returns the JSON response
|
|
137
144
|
if return_json:
|
|
138
145
|
return response.json()
|
|
139
146
|
|
|
140
147
|
except requests.HTTPError as e:
|
|
141
|
-
self._handle_exception(
|
|
148
|
+
self._handle_exception(
|
|
149
|
+
e, response_text, request_data.url, request_data.correlation_id
|
|
150
|
+
)
|
|
142
151
|
|
|
143
152
|
def make_request_stream(self, method: str, request_data: RequestData):
|
|
144
153
|
"""
|
|
@@ -187,14 +196,18 @@ class RequestHandler(BaseRequestHandler):
|
|
|
187
196
|
)
|
|
188
197
|
|
|
189
198
|
# Check for HTTP errors
|
|
190
|
-
response.
|
|
199
|
+
if not response.ok:
|
|
200
|
+
response_text = response.text
|
|
201
|
+
response.raise_for_status()
|
|
191
202
|
|
|
192
203
|
# Yields the response content as a stream
|
|
193
204
|
for message in parse_sse_stream_chunked(response.iter_content()):
|
|
194
205
|
yield message
|
|
195
206
|
|
|
196
207
|
except requests.HTTPError as e:
|
|
197
|
-
self._handle_exception(
|
|
208
|
+
self._handle_exception(
|
|
209
|
+
e, response_text, request_data.url, request_data.correlation_id
|
|
210
|
+
)
|
|
198
211
|
|
|
199
212
|
def make_request_multipart(
|
|
200
213
|
self, method: str, request_data: RequestData, return_json: bool = True
|
|
@@ -245,11 +258,15 @@ class RequestHandler(BaseRequestHandler):
|
|
|
245
258
|
)
|
|
246
259
|
|
|
247
260
|
# Check for HTTP errors
|
|
248
|
-
response.
|
|
261
|
+
if not response.ok:
|
|
262
|
+
response_text = response.text
|
|
263
|
+
response.raise_for_status()
|
|
249
264
|
|
|
250
265
|
# Returns the JSON response
|
|
251
266
|
if return_json:
|
|
252
267
|
return response.json()
|
|
253
268
|
|
|
254
269
|
except requests.HTTPError as e:
|
|
255
|
-
self._handle_exception(
|
|
270
|
+
self._handle_exception(
|
|
271
|
+
e, response_text, request_data.url, request_data.correlation_id
|
|
272
|
+
)
|
|
@@ -15,10 +15,13 @@ from .conversations import AsyncConversations
|
|
|
15
15
|
from .data_vector_search import AsyncDataVectorSearch
|
|
16
16
|
from .deployments import AsyncDeployments
|
|
17
17
|
from .library import AsyncLibrary
|
|
18
|
+
from .models import AsyncModels
|
|
18
19
|
from .pipeline_execution import AsyncPipelineExecution
|
|
20
|
+
from .pipeline_import import AsyncPipelineImport
|
|
19
21
|
from .pipelines_config import AsyncPipelinesConfig
|
|
20
22
|
from .project import AsyncProject
|
|
21
23
|
from .store import AsyncStore
|
|
24
|
+
from .tools import AsyncTools
|
|
22
25
|
|
|
23
26
|
|
|
24
27
|
class AiriaAsyncClient(AiriaBaseClient):
|
|
@@ -63,6 +66,7 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
63
66
|
)
|
|
64
67
|
self.attachments = AsyncAttachments(self._request_handler)
|
|
65
68
|
self.pipeline_execution = AsyncPipelineExecution(self._request_handler)
|
|
69
|
+
self.pipeline_import = AsyncPipelineImport(self._request_handler)
|
|
66
70
|
self.pipelines_config = AsyncPipelinesConfig(self._request_handler)
|
|
67
71
|
self.project = AsyncProject(self._request_handler)
|
|
68
72
|
self.conversations = AsyncConversations(self._request_handler)
|
|
@@ -70,6 +74,8 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
70
74
|
self.deployments = AsyncDeployments(self._request_handler)
|
|
71
75
|
self.data_vector_search = AsyncDataVectorSearch(self._request_handler)
|
|
72
76
|
self.library = AsyncLibrary(self._request_handler)
|
|
77
|
+
self.models = AsyncModels(self._request_handler)
|
|
78
|
+
self.tools = AsyncTools(self._request_handler)
|
|
73
79
|
|
|
74
80
|
@classmethod
|
|
75
81
|
def with_openai_gateway(
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.models import ModelItem
|
|
5
|
+
from .._request_handler import AsyncRequestHandler
|
|
6
|
+
from .base_models import BaseModels
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncModels(BaseModels):
|
|
10
|
+
def __init__(self, request_handler: AsyncRequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
async def list_models(
|
|
14
|
+
self,
|
|
15
|
+
project_id: Optional[str] = None,
|
|
16
|
+
include_global: bool = True,
|
|
17
|
+
page_number: int = 1,
|
|
18
|
+
page_size: int = 50,
|
|
19
|
+
sort_by: str = "updatedAt",
|
|
20
|
+
sort_direction: str = "DESC",
|
|
21
|
+
correlation_id: Optional[str] = None,
|
|
22
|
+
) -> List[ModelItem]:
|
|
23
|
+
"""
|
|
24
|
+
Retrieve a list of models accessible to the authenticated user.
|
|
25
|
+
|
|
26
|
+
This method fetches information about all models that the current user
|
|
27
|
+
has access to, optionally filtered by project. Models can be either
|
|
28
|
+
library-provided or user-configured.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
project_id (str, optional): Filter models by project ID. If provided,
|
|
32
|
+
returns models associated with this project.
|
|
33
|
+
include_global (bool, optional): Whether to include global/library models
|
|
34
|
+
in the results. Defaults to True.
|
|
35
|
+
page_number (int, optional): Page number for pagination. Defaults to 1.
|
|
36
|
+
page_size (int, optional): Number of items per page. Defaults to 50.
|
|
37
|
+
sort_by (str, optional): Field to sort results by. Defaults to "updatedAt".
|
|
38
|
+
sort_direction (str, optional): Sort direction, either "ASC" or "DESC".
|
|
39
|
+
Defaults to "DESC".
|
|
40
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
41
|
+
and logging. If not provided, one will be automatically generated.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
List[ModelItem]: A list of ModelItem objects containing model
|
|
45
|
+
information including configuration, pricing, and capabilities.
|
|
46
|
+
Returns an empty list if no models are found.
|
|
47
|
+
|
|
48
|
+
Raises:
|
|
49
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
50
|
+
- Authentication fails (401)
|
|
51
|
+
- Access is forbidden (403)
|
|
52
|
+
- Server errors (5xx)
|
|
53
|
+
|
|
54
|
+
Example:
|
|
55
|
+
```python
|
|
56
|
+
from airia import AiriaAsyncClient
|
|
57
|
+
|
|
58
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
59
|
+
|
|
60
|
+
# Get all accessible models
|
|
61
|
+
models = await client.models.list_models()
|
|
62
|
+
|
|
63
|
+
for model in models:
|
|
64
|
+
print(f"Model: {model.display_name}")
|
|
65
|
+
print(f"Provider: {model.provider}")
|
|
66
|
+
print(f"Type: {model.type}")
|
|
67
|
+
print(f"Has tool support: {model.has_tool_support}")
|
|
68
|
+
print("---")
|
|
69
|
+
|
|
70
|
+
# Get models for a specific project
|
|
71
|
+
project_models = await client.models.list_models(
|
|
72
|
+
project_id="12345678-1234-1234-1234-123456789abc",
|
|
73
|
+
include_global=False
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Note:
|
|
78
|
+
The returned models are filtered based on the authenticated user's
|
|
79
|
+
permissions. Users will only see models they have been granted access to.
|
|
80
|
+
"""
|
|
81
|
+
request_data = self._pre_list_models(
|
|
82
|
+
project_id=project_id,
|
|
83
|
+
include_global=include_global,
|
|
84
|
+
page_number=page_number,
|
|
85
|
+
page_size=page_size,
|
|
86
|
+
sort_by=sort_by,
|
|
87
|
+
sort_direction=sort_direction,
|
|
88
|
+
correlation_id=correlation_id,
|
|
89
|
+
api_version=ApiVersion.V1.value,
|
|
90
|
+
)
|
|
91
|
+
resp = await self._request_handler.make_request("GET", request_data)
|
|
92
|
+
|
|
93
|
+
if "items" not in resp or len(resp["items"]) == 0:
|
|
94
|
+
return []
|
|
95
|
+
|
|
96
|
+
return [ModelItem(**item) for item in resp["items"]]
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from typing import Optional, Union
|
|
2
|
+
from urllib.parse import urljoin, urlencode
|
|
3
|
+
|
|
4
|
+
from ...types._api_version import ApiVersion
|
|
5
|
+
from .._request_handler import AsyncRequestHandler, RequestHandler
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BaseModels:
|
|
9
|
+
def __init__(self, request_handler: Union[RequestHandler, AsyncRequestHandler]):
|
|
10
|
+
self._request_handler = request_handler
|
|
11
|
+
|
|
12
|
+
def _pre_list_models(
|
|
13
|
+
self,
|
|
14
|
+
project_id: Optional[str] = None,
|
|
15
|
+
include_global: bool = True,
|
|
16
|
+
page_number: int = 1,
|
|
17
|
+
page_size: int = 50,
|
|
18
|
+
sort_by: str = "updatedAt",
|
|
19
|
+
sort_direction: str = "DESC",
|
|
20
|
+
correlation_id: Optional[str] = None,
|
|
21
|
+
api_version: str = ApiVersion.V1.value,
|
|
22
|
+
):
|
|
23
|
+
"""
|
|
24
|
+
Prepare request data for listing models endpoint.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
project_id: Optional project ID to filter models
|
|
28
|
+
include_global: Whether to include global models (default: True)
|
|
29
|
+
page_number: Page number for pagination (default: 1)
|
|
30
|
+
page_size: Number of items per page (default: 50)
|
|
31
|
+
sort_by: Field to sort by (default: "updatedAt")
|
|
32
|
+
sort_direction: Sort direction "ASC" or "DESC" (default: "DESC")
|
|
33
|
+
correlation_id: Optional correlation ID for tracing
|
|
34
|
+
api_version: API version to use for the request
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
RequestData: Prepared request data for the models endpoint
|
|
38
|
+
|
|
39
|
+
Raises:
|
|
40
|
+
ValueError: If an invalid API version is provided
|
|
41
|
+
"""
|
|
42
|
+
if api_version not in ApiVersion.as_list():
|
|
43
|
+
raise ValueError(
|
|
44
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# Build query parameters
|
|
48
|
+
query_params = {
|
|
49
|
+
"pageNumber": page_number,
|
|
50
|
+
"pageSize": page_size,
|
|
51
|
+
"sortBy": sort_by,
|
|
52
|
+
"sortDirection": sort_direction,
|
|
53
|
+
"includeGlobal": str(include_global).lower(),
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if project_id:
|
|
57
|
+
query_params["projectId"] = project_id
|
|
58
|
+
|
|
59
|
+
query_string = urlencode(query_params)
|
|
60
|
+
url = urljoin(
|
|
61
|
+
self._request_handler.base_url, f"{api_version}/Models?{query_string}"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
request_data = self._request_handler.prepare_request(
|
|
65
|
+
url, correlation_id=correlation_id
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
return request_data
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.models import ModelItem
|
|
5
|
+
from .._request_handler import RequestHandler
|
|
6
|
+
from .base_models import BaseModels
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Models(BaseModels):
|
|
10
|
+
def __init__(self, request_handler: RequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
def list_models(
|
|
14
|
+
self,
|
|
15
|
+
project_id: Optional[str] = None,
|
|
16
|
+
include_global: bool = True,
|
|
17
|
+
page_number: int = 1,
|
|
18
|
+
page_size: int = 50,
|
|
19
|
+
sort_by: str = "updatedAt",
|
|
20
|
+
sort_direction: str = "DESC",
|
|
21
|
+
correlation_id: Optional[str] = None,
|
|
22
|
+
) -> List[ModelItem]:
|
|
23
|
+
"""
|
|
24
|
+
Retrieve a list of models accessible to the authenticated user.
|
|
25
|
+
|
|
26
|
+
This method fetches information about all models that the current user
|
|
27
|
+
has access to, optionally filtered by project. Models can be either
|
|
28
|
+
library-provided or user-configured.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
project_id (str, optional): Filter models by project ID. If provided,
|
|
32
|
+
returns models associated with this project.
|
|
33
|
+
include_global (bool, optional): Whether to include global/library models
|
|
34
|
+
in the results. Defaults to True.
|
|
35
|
+
page_number (int, optional): Page number for pagination. Defaults to 1.
|
|
36
|
+
page_size (int, optional): Number of items per page. Defaults to 50.
|
|
37
|
+
sort_by (str, optional): Field to sort results by. Defaults to "updatedAt".
|
|
38
|
+
sort_direction (str, optional): Sort direction, either "ASC" or "DESC".
|
|
39
|
+
Defaults to "DESC".
|
|
40
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
41
|
+
and logging. If not provided, one will be automatically generated.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
List[ModelItem]: A list of ModelItem objects containing model
|
|
45
|
+
information including configuration, pricing, and capabilities.
|
|
46
|
+
Returns an empty list if no models are found.
|
|
47
|
+
|
|
48
|
+
Raises:
|
|
49
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
50
|
+
- Authentication fails (401)
|
|
51
|
+
- Access is forbidden (403)
|
|
52
|
+
- Server errors (5xx)
|
|
53
|
+
|
|
54
|
+
Example:
|
|
55
|
+
```python
|
|
56
|
+
from airia import AiriaClient
|
|
57
|
+
|
|
58
|
+
client = AiriaClient(api_key="your_api_key")
|
|
59
|
+
|
|
60
|
+
# Get all accessible models
|
|
61
|
+
models = client.models.list_models()
|
|
62
|
+
|
|
63
|
+
for model in models:
|
|
64
|
+
print(f"Model: {model.display_name}")
|
|
65
|
+
print(f"Provider: {model.provider}")
|
|
66
|
+
print(f"Type: {model.type}")
|
|
67
|
+
print(f"Has tool support: {model.has_tool_support}")
|
|
68
|
+
print("---")
|
|
69
|
+
|
|
70
|
+
# Get models for a specific project
|
|
71
|
+
project_models = client.models.list_models(
|
|
72
|
+
project_id="12345678-1234-1234-1234-123456789abc",
|
|
73
|
+
include_global=False
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Note:
|
|
78
|
+
The returned models are filtered based on the authenticated user's
|
|
79
|
+
permissions. Users will only see models they have been granted access to.
|
|
80
|
+
"""
|
|
81
|
+
request_data = self._pre_list_models(
|
|
82
|
+
project_id=project_id,
|
|
83
|
+
include_global=include_global,
|
|
84
|
+
page_number=page_number,
|
|
85
|
+
page_size=page_size,
|
|
86
|
+
sort_by=sort_by,
|
|
87
|
+
sort_direction=sort_direction,
|
|
88
|
+
correlation_id=correlation_id,
|
|
89
|
+
api_version=ApiVersion.V1.value,
|
|
90
|
+
)
|
|
91
|
+
resp = self._request_handler.make_request("GET", request_data)
|
|
92
|
+
|
|
93
|
+
if "items" not in resp or len(resp["items"]) == 0:
|
|
94
|
+
return []
|
|
95
|
+
|
|
96
|
+
return [ModelItem(**item) for item in resp["items"]]
|
|
@@ -74,7 +74,7 @@ class AsyncPipelineExecution(BasePipelineExecution):
|
|
|
74
74
|
files: Optional[List[str]] = None,
|
|
75
75
|
data_source_folders: Optional[Dict[str, Any]] = None,
|
|
76
76
|
data_source_files: Optional[Dict[str, Any]] = None,
|
|
77
|
-
in_memory_messages: Optional[List[Dict[str,
|
|
77
|
+
in_memory_messages: Optional[List[Dict[str, Any]]] = None,
|
|
78
78
|
current_date_time: Optional[str] = None,
|
|
79
79
|
save_history: bool = True,
|
|
80
80
|
additional_info: Optional[List[Any]] = None,
|
|
@@ -97,7 +97,7 @@ class AsyncPipelineExecution(BasePipelineExecution):
|
|
|
97
97
|
files: Optional[List[str]] = None,
|
|
98
98
|
data_source_folders: Optional[Dict[str, Any]] = None,
|
|
99
99
|
data_source_files: Optional[Dict[str, Any]] = None,
|
|
100
|
-
in_memory_messages: Optional[List[Dict[str,
|
|
100
|
+
in_memory_messages: Optional[List[Dict[str, Any]]] = None,
|
|
101
101
|
current_date_time: Optional[str] = None,
|
|
102
102
|
save_history: bool = True,
|
|
103
103
|
additional_info: Optional[List[Any]] = None,
|
|
@@ -119,7 +119,7 @@ class AsyncPipelineExecution(BasePipelineExecution):
|
|
|
119
119
|
files: Optional[List[str]] = None,
|
|
120
120
|
data_source_folders: Optional[Dict[str, Any]] = None,
|
|
121
121
|
data_source_files: Optional[Dict[str, Any]] = None,
|
|
122
|
-
in_memory_messages: Optional[List[Dict[str,
|
|
122
|
+
in_memory_messages: Optional[List[Dict[str, Any]]] = None,
|
|
123
123
|
current_date_time: Optional[str] = None,
|
|
124
124
|
save_history: bool = True,
|
|
125
125
|
additional_info: Optional[List[Any]] = None,
|
|
@@ -36,7 +36,7 @@ class BasePipelineExecution:
|
|
|
36
36
|
files: Optional[List[str]] = None,
|
|
37
37
|
data_source_folders: Optional[Dict[str, Any]] = None,
|
|
38
38
|
data_source_files: Optional[Dict[str, Any]] = None,
|
|
39
|
-
in_memory_messages: Optional[List[Dict[str,
|
|
39
|
+
in_memory_messages: Optional[List[Dict[str, Any]]] = None,
|
|
40
40
|
current_date_time: Optional[str] = None,
|
|
41
41
|
save_history: bool = True,
|
|
42
42
|
additional_info: Optional[List[Any]] = None,
|
|
@@ -74,7 +74,7 @@ class PipelineExecution(BasePipelineExecution):
|
|
|
74
74
|
files: Optional[List[str]] = None,
|
|
75
75
|
data_source_folders: Optional[Dict[str, Any]] = None,
|
|
76
76
|
data_source_files: Optional[Dict[str, Any]] = None,
|
|
77
|
-
in_memory_messages: Optional[List[Dict[str,
|
|
77
|
+
in_memory_messages: Optional[List[Dict[str, Any]]] = None,
|
|
78
78
|
current_date_time: Optional[str] = None,
|
|
79
79
|
save_history: bool = True,
|
|
80
80
|
additional_info: Optional[List[Any]] = None,
|
|
@@ -97,7 +97,7 @@ class PipelineExecution(BasePipelineExecution):
|
|
|
97
97
|
files: Optional[List[str]] = None,
|
|
98
98
|
data_source_folders: Optional[Dict[str, Any]] = None,
|
|
99
99
|
data_source_files: Optional[Dict[str, Any]] = None,
|
|
100
|
-
in_memory_messages: Optional[List[Dict[str,
|
|
100
|
+
in_memory_messages: Optional[List[Dict[str, Any]]] = None,
|
|
101
101
|
current_date_time: Optional[str] = None,
|
|
102
102
|
save_history: bool = True,
|
|
103
103
|
additional_info: Optional[List[Any]] = None,
|
|
@@ -119,7 +119,7 @@ class PipelineExecution(BasePipelineExecution):
|
|
|
119
119
|
files: Optional[List[str]] = None,
|
|
120
120
|
data_source_folders: Optional[Dict[str, Any]] = None,
|
|
121
121
|
data_source_files: Optional[Dict[str, Any]] = None,
|
|
122
|
-
in_memory_messages: Optional[List[Dict[str,
|
|
122
|
+
in_memory_messages: Optional[List[Dict[str, Any]]] = None,
|
|
123
123
|
current_date_time: Optional[str] = None,
|
|
124
124
|
save_history: bool = True,
|
|
125
125
|
additional_info: Optional[List[Any]] = None,
|