airia 0.1.5__tar.gz → 0.1.6__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.5 → airia-0.1.6}/PKG-INFO +110 -19
- {airia-0.1.5 → airia-0.1.6}/README.md +109 -18
- {airia-0.1.5 → airia-0.1.6}/airia/client/async_client.py +141 -23
- {airia-0.1.5 → airia-0.1.6}/airia/client/base_client.py +30 -0
- {airia-0.1.5 → airia-0.1.6}/airia/client/sync_client.py +119 -7
- airia-0.1.6/airia/types/__init__.py +71 -0
- airia-0.1.6/airia/types/api/get_pipeline_config.py +65 -0
- {airia-0.1.5/airia/types → airia-0.1.6/airia/types/api}/pipeline_execution.py +4 -2
- {airia-0.1.5 → airia-0.1.6}/airia/types/request_data.py +2 -2
- airia-0.1.6/airia/types/sse_messages.py +269 -0
- airia-0.1.6/airia/utils/sse_parser.py +91 -0
- {airia-0.1.5 → airia-0.1.6}/airia.egg-info/PKG-INFO +110 -19
- {airia-0.1.5 → airia-0.1.6}/airia.egg-info/SOURCES.txt +6 -1
- {airia-0.1.5 → airia-0.1.6}/pyproject.toml +1 -1
- {airia-0.1.5 → airia-0.1.6}/tests/test_anthropic_gateway.py +31 -18
- {airia-0.1.5 → airia-0.1.6}/tests/test_execute_pipeline.py +41 -48
- airia-0.1.6/tests/test_get_active_pipelines_ids.py +191 -0
- airia-0.1.6/tests/test_get_pipeline_config.py +394 -0
- {airia-0.1.5 → airia-0.1.6}/tests/test_openai_gateway.py +29 -18
- airia-0.1.5/airia/types/__init__.py +0 -19
- {airia-0.1.5 → airia-0.1.6}/LICENSE +0 -0
- {airia-0.1.5 → airia-0.1.6}/airia/__init__.py +0 -0
- {airia-0.1.5 → airia-0.1.6}/airia/client/__init__.py +0 -0
- {airia-0.1.5 → airia-0.1.6}/airia/exceptions.py +0 -0
- {airia-0.1.5 → airia-0.1.6}/airia/logs.py +0 -0
- {airia-0.1.5 → airia-0.1.6}/airia/types/api_version.py +0 -0
- {airia-0.1.5 → airia-0.1.6}/airia.egg-info/dependency_links.txt +0 -0
- {airia-0.1.5 → airia-0.1.6}/airia.egg-info/requires.txt +0 -0
- {airia-0.1.5 → airia-0.1.6}/airia.egg-info/top_level.txt +0 -0
- {airia-0.1.5 → airia-0.1.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: airia
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Python SDK for Airia API
|
|
5
5
|
Author-email: Airia LLC <support@airia.com>
|
|
6
6
|
License: MIT
|
|
@@ -182,7 +182,7 @@ This will create both wheel and source distribution in the `dist/` directory.
|
|
|
182
182
|
from airia import AiriaClient
|
|
183
183
|
|
|
184
184
|
client = AiriaClient(
|
|
185
|
-
base_url="https://api.airia.
|
|
185
|
+
base_url="https://api.airia.ai", # Default: "https://api.airia.ai"
|
|
186
186
|
api_key=None, # Or set AIRIA_API_KEY environment variable
|
|
187
187
|
timeout=30.0, # Request timeout in seconds (default: 30.0)
|
|
188
188
|
log_requests=False, # Enable request/response logging (default: False)
|
|
@@ -223,7 +223,7 @@ response = client.execute_pipeline(
|
|
|
223
223
|
)
|
|
224
224
|
|
|
225
225
|
for c in response.stream:
|
|
226
|
-
print(c
|
|
226
|
+
print(c)
|
|
227
227
|
```
|
|
228
228
|
|
|
229
229
|
### Asynchronous Usage
|
|
@@ -233,13 +233,12 @@ import asyncio
|
|
|
233
233
|
from airia import AiriaAsyncClient
|
|
234
234
|
|
|
235
235
|
async def main():
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
print(response.result)
|
|
236
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
237
|
+
response = await client.execute_pipeline(
|
|
238
|
+
pipeline_id="your_pipeline_id",
|
|
239
|
+
user_input="Tell me about quantum computing"
|
|
240
|
+
)
|
|
241
|
+
print(response.result)
|
|
243
242
|
|
|
244
243
|
asyncio.run(main())
|
|
245
244
|
```
|
|
@@ -251,19 +250,111 @@ import asyncio
|
|
|
251
250
|
from airia import AiriaAsyncClient
|
|
252
251
|
|
|
253
252
|
async def main():
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
print(c, end="")
|
|
253
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
254
|
+
response = await client.execute_pipeline(
|
|
255
|
+
pipeline_id="your_pipeline_id",
|
|
256
|
+
user_input="Tell me about quantum computing",
|
|
257
|
+
async_output=True
|
|
258
|
+
)
|
|
259
|
+
async for c in response.stream:
|
|
260
|
+
print(c)
|
|
263
261
|
|
|
264
262
|
asyncio.run(main())
|
|
265
263
|
```
|
|
266
264
|
|
|
265
|
+
## Streaming Event Parsing
|
|
266
|
+
|
|
267
|
+
When using streaming mode (`async_output=True`), the API returns Server-Sent Events (SSE) that contain different types of messages throughout the pipeline execution. You can parse and filter these events to extract specific information.
|
|
268
|
+
|
|
269
|
+
### Available Message Types
|
|
270
|
+
|
|
271
|
+
The streaming response includes various message types defined in `airia.types`. Here are the key ones:
|
|
272
|
+
|
|
273
|
+
- `AgentModelStreamFragmentMessage` - Contains actual LLM output chunks
|
|
274
|
+
- `AgentModelStreamStartMessage` - Indicates LLM streaming has started
|
|
275
|
+
- `AgentModelStreamEndMessage` - Indicates LLM streaming has ended
|
|
276
|
+
- `AgentStepStartMessage` - Indicates a pipeline step has started
|
|
277
|
+
- `AgentStepEndMessage` - Indicates a pipeline step has ended
|
|
278
|
+
- `AgentOutputMessage` - Contains step output
|
|
279
|
+
|
|
280
|
+
<details>
|
|
281
|
+
<summary>Click to expand the full list of message types</summary>
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
[
|
|
285
|
+
AgentPingMessage,
|
|
286
|
+
AgentStartMessage,
|
|
287
|
+
AgentEndMessage,
|
|
288
|
+
AgentStepStartMessage,
|
|
289
|
+
AgentStepHaltMessage,
|
|
290
|
+
AgentStepEndMessage,
|
|
291
|
+
AgentOutputMessage,
|
|
292
|
+
AgentAgentCardMessage,
|
|
293
|
+
AgentDatasearchMessage,
|
|
294
|
+
AgentInvocationMessage,
|
|
295
|
+
AgentModelMessage,
|
|
296
|
+
AgentPythonCodeMessage,
|
|
297
|
+
AgentToolActionMessage,
|
|
298
|
+
AgentModelStreamStartMessage,
|
|
299
|
+
AgentModelStreamEndMessage,
|
|
300
|
+
AgentModelStreamErrorMessage,
|
|
301
|
+
AgentModelStreamUsageMessage,
|
|
302
|
+
AgentModelStreamFragmentMessage,
|
|
303
|
+
AgentAgentCardStreamStartMessage,
|
|
304
|
+
AgentAgentCardStreamErrorMessage,
|
|
305
|
+
AgentAgentCardStreamFragmentMessage,
|
|
306
|
+
AgentAgentCardStreamEndMessage,
|
|
307
|
+
AgentToolRequestMessage,
|
|
308
|
+
AgentToolResponseMessage,
|
|
309
|
+
]
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
</details>
|
|
313
|
+
|
|
314
|
+
### Filtering LLM Output
|
|
315
|
+
|
|
316
|
+
To extract only the actual LLM output text from the stream:
|
|
317
|
+
|
|
318
|
+
```python
|
|
319
|
+
from airia import AiriaClient
|
|
320
|
+
from airia.types import AgentModelStreamFragmentMessage
|
|
321
|
+
|
|
322
|
+
client = AiriaClient(api_key="your_api_key")
|
|
323
|
+
|
|
324
|
+
response = client.execute_pipeline(
|
|
325
|
+
pipeline_id="your_pipeline_id",
|
|
326
|
+
user_input="Tell me about quantum computing",
|
|
327
|
+
async_output=True
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
# Filter and display only LLM output
|
|
331
|
+
for event in response.stream:
|
|
332
|
+
if isinstance(event, AgentModelStreamFragmentMessage) and event.index != -1:
|
|
333
|
+
print(event.content, end="", flush=True)
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Pipeline Configuration Retrieval
|
|
337
|
+
|
|
338
|
+
You can retrieve detailed configuration information about a pipeline using the `get_pipeline_config` method:
|
|
339
|
+
|
|
340
|
+
> To get a list of all active pipeline ids, run the `get_active_pipelines_ids` method.
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
from airia import AiriaClient
|
|
344
|
+
|
|
345
|
+
client = AiriaClient(api_key="your_api_key")
|
|
346
|
+
|
|
347
|
+
# Get pipeline configuration
|
|
348
|
+
config = client.get_pipeline_config(pipeline_id="your_pipeline_id")
|
|
349
|
+
|
|
350
|
+
# Access configuration details
|
|
351
|
+
print(f"Pipeline Name: {config.deployment_name}")
|
|
352
|
+
print(f"Description: {config.deployment_description}")
|
|
353
|
+
print(f"Active Version: {config.active_version.version_number}")
|
|
354
|
+
print(f"Success Count: {config.execution_stats.success_count}")
|
|
355
|
+
print(f"Failure Count: {config.execution_stats.failure_count}")
|
|
356
|
+
```
|
|
357
|
+
|
|
267
358
|
## Gateway Usage
|
|
268
359
|
|
|
269
360
|
Airia provides gateway capabilities for popular AI services like OpenAI and Anthropic, allowing you to use your Airia API key with these services.
|
|
@@ -152,7 +152,7 @@ This will create both wheel and source distribution in the `dist/` directory.
|
|
|
152
152
|
from airia import AiriaClient
|
|
153
153
|
|
|
154
154
|
client = AiriaClient(
|
|
155
|
-
base_url="https://api.airia.
|
|
155
|
+
base_url="https://api.airia.ai", # Default: "https://api.airia.ai"
|
|
156
156
|
api_key=None, # Or set AIRIA_API_KEY environment variable
|
|
157
157
|
timeout=30.0, # Request timeout in seconds (default: 30.0)
|
|
158
158
|
log_requests=False, # Enable request/response logging (default: False)
|
|
@@ -193,7 +193,7 @@ response = client.execute_pipeline(
|
|
|
193
193
|
)
|
|
194
194
|
|
|
195
195
|
for c in response.stream:
|
|
196
|
-
print(c
|
|
196
|
+
print(c)
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
### Asynchronous Usage
|
|
@@ -203,13 +203,12 @@ import asyncio
|
|
|
203
203
|
from airia import AiriaAsyncClient
|
|
204
204
|
|
|
205
205
|
async def main():
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
print(response.result)
|
|
206
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
207
|
+
response = await client.execute_pipeline(
|
|
208
|
+
pipeline_id="your_pipeline_id",
|
|
209
|
+
user_input="Tell me about quantum computing"
|
|
210
|
+
)
|
|
211
|
+
print(response.result)
|
|
213
212
|
|
|
214
213
|
asyncio.run(main())
|
|
215
214
|
```
|
|
@@ -221,19 +220,111 @@ import asyncio
|
|
|
221
220
|
from airia import AiriaAsyncClient
|
|
222
221
|
|
|
223
222
|
async def main():
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
print(c, end="")
|
|
223
|
+
client = AiriaAsyncClient(api_key="your_api_key")
|
|
224
|
+
response = await client.execute_pipeline(
|
|
225
|
+
pipeline_id="your_pipeline_id",
|
|
226
|
+
user_input="Tell me about quantum computing",
|
|
227
|
+
async_output=True
|
|
228
|
+
)
|
|
229
|
+
async for c in response.stream:
|
|
230
|
+
print(c)
|
|
233
231
|
|
|
234
232
|
asyncio.run(main())
|
|
235
233
|
```
|
|
236
234
|
|
|
235
|
+
## Streaming Event Parsing
|
|
236
|
+
|
|
237
|
+
When using streaming mode (`async_output=True`), the API returns Server-Sent Events (SSE) that contain different types of messages throughout the pipeline execution. You can parse and filter these events to extract specific information.
|
|
238
|
+
|
|
239
|
+
### Available Message Types
|
|
240
|
+
|
|
241
|
+
The streaming response includes various message types defined in `airia.types`. Here are the key ones:
|
|
242
|
+
|
|
243
|
+
- `AgentModelStreamFragmentMessage` - Contains actual LLM output chunks
|
|
244
|
+
- `AgentModelStreamStartMessage` - Indicates LLM streaming has started
|
|
245
|
+
- `AgentModelStreamEndMessage` - Indicates LLM streaming has ended
|
|
246
|
+
- `AgentStepStartMessage` - Indicates a pipeline step has started
|
|
247
|
+
- `AgentStepEndMessage` - Indicates a pipeline step has ended
|
|
248
|
+
- `AgentOutputMessage` - Contains step output
|
|
249
|
+
|
|
250
|
+
<details>
|
|
251
|
+
<summary>Click to expand the full list of message types</summary>
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
[
|
|
255
|
+
AgentPingMessage,
|
|
256
|
+
AgentStartMessage,
|
|
257
|
+
AgentEndMessage,
|
|
258
|
+
AgentStepStartMessage,
|
|
259
|
+
AgentStepHaltMessage,
|
|
260
|
+
AgentStepEndMessage,
|
|
261
|
+
AgentOutputMessage,
|
|
262
|
+
AgentAgentCardMessage,
|
|
263
|
+
AgentDatasearchMessage,
|
|
264
|
+
AgentInvocationMessage,
|
|
265
|
+
AgentModelMessage,
|
|
266
|
+
AgentPythonCodeMessage,
|
|
267
|
+
AgentToolActionMessage,
|
|
268
|
+
AgentModelStreamStartMessage,
|
|
269
|
+
AgentModelStreamEndMessage,
|
|
270
|
+
AgentModelStreamErrorMessage,
|
|
271
|
+
AgentModelStreamUsageMessage,
|
|
272
|
+
AgentModelStreamFragmentMessage,
|
|
273
|
+
AgentAgentCardStreamStartMessage,
|
|
274
|
+
AgentAgentCardStreamErrorMessage,
|
|
275
|
+
AgentAgentCardStreamFragmentMessage,
|
|
276
|
+
AgentAgentCardStreamEndMessage,
|
|
277
|
+
AgentToolRequestMessage,
|
|
278
|
+
AgentToolResponseMessage,
|
|
279
|
+
]
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
</details>
|
|
283
|
+
|
|
284
|
+
### Filtering LLM Output
|
|
285
|
+
|
|
286
|
+
To extract only the actual LLM output text from the stream:
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
from airia import AiriaClient
|
|
290
|
+
from airia.types import AgentModelStreamFragmentMessage
|
|
291
|
+
|
|
292
|
+
client = AiriaClient(api_key="your_api_key")
|
|
293
|
+
|
|
294
|
+
response = client.execute_pipeline(
|
|
295
|
+
pipeline_id="your_pipeline_id",
|
|
296
|
+
user_input="Tell me about quantum computing",
|
|
297
|
+
async_output=True
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
# Filter and display only LLM output
|
|
301
|
+
for event in response.stream:
|
|
302
|
+
if isinstance(event, AgentModelStreamFragmentMessage) and event.index != -1:
|
|
303
|
+
print(event.content, end="", flush=True)
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Pipeline Configuration Retrieval
|
|
307
|
+
|
|
308
|
+
You can retrieve detailed configuration information about a pipeline using the `get_pipeline_config` method:
|
|
309
|
+
|
|
310
|
+
> To get a list of all active pipeline ids, run the `get_active_pipelines_ids` method.
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
from airia import AiriaClient
|
|
314
|
+
|
|
315
|
+
client = AiriaClient(api_key="your_api_key")
|
|
316
|
+
|
|
317
|
+
# Get pipeline configuration
|
|
318
|
+
config = client.get_pipeline_config(pipeline_id="your_pipeline_id")
|
|
319
|
+
|
|
320
|
+
# Access configuration details
|
|
321
|
+
print(f"Pipeline Name: {config.deployment_name}")
|
|
322
|
+
print(f"Description: {config.deployment_description}")
|
|
323
|
+
print(f"Active Version: {config.active_version.version_number}")
|
|
324
|
+
print(f"Success Count: {config.execution_stats.success_count}")
|
|
325
|
+
print(f"Failure Count: {config.execution_stats.failure_count}")
|
|
326
|
+
```
|
|
327
|
+
|
|
237
328
|
## Gateway Usage
|
|
238
329
|
|
|
239
330
|
Airia provides gateway capabilities for popular AI services like OpenAI and Anthropic, allowing you to use your Airia API key with these services.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import weakref
|
|
1
3
|
from typing import Any, AsyncIterator, Dict, List, Literal, Optional, overload
|
|
2
4
|
from urllib.parse import urljoin
|
|
3
5
|
|
|
@@ -7,12 +9,14 @@ import loguru
|
|
|
7
9
|
from ..exceptions import AiriaAPIError
|
|
8
10
|
from ..types import (
|
|
9
11
|
ApiVersion,
|
|
12
|
+
GetPipelineConfigResponse,
|
|
10
13
|
PipelineExecutionDebugResponse,
|
|
11
14
|
PipelineExecutionResponse,
|
|
12
15
|
PipelineExecutionV1StreamedResponse,
|
|
13
16
|
PipelineExecutionV2AsyncStreamedResponse,
|
|
14
17
|
RequestData,
|
|
15
18
|
)
|
|
19
|
+
from ..utils.sse_parser import async_parse_sse_stream_chunked
|
|
16
20
|
from .base_client import AiriaBaseClient
|
|
17
21
|
|
|
18
22
|
|
|
@@ -46,8 +50,31 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
46
50
|
)
|
|
47
51
|
|
|
48
52
|
# Session will be initialized in __aenter__
|
|
49
|
-
self.session = None
|
|
50
53
|
self.headers = {"Content-Type": "application/json"}
|
|
54
|
+
self.session = aiohttp.ClientSession(headers=self.headers)
|
|
55
|
+
|
|
56
|
+
# Register finalizer to clean up session when client is garbage collected
|
|
57
|
+
self._finalizer = weakref.finalize(self, self._cleanup_session, self.session)
|
|
58
|
+
|
|
59
|
+
@staticmethod
|
|
60
|
+
def _cleanup_session(session: aiohttp.ClientSession):
|
|
61
|
+
"""Static method to clean up session - called by finalizer"""
|
|
62
|
+
if session and not session.closed:
|
|
63
|
+
# Create a new event loop if none exists
|
|
64
|
+
try:
|
|
65
|
+
loop = asyncio.get_event_loop()
|
|
66
|
+
if loop.is_closed():
|
|
67
|
+
raise RuntimeError("Event loop is closed")
|
|
68
|
+
except RuntimeError:
|
|
69
|
+
loop = asyncio.new_event_loop()
|
|
70
|
+
asyncio.set_event_loop(loop)
|
|
71
|
+
|
|
72
|
+
# Close the session
|
|
73
|
+
if not loop.is_running():
|
|
74
|
+
loop.run_until_complete(session.close())
|
|
75
|
+
else:
|
|
76
|
+
# If loop is running, schedule the close operation
|
|
77
|
+
asyncio.create_task(session.close())
|
|
51
78
|
|
|
52
79
|
@classmethod
|
|
53
80
|
def with_openai_gateway(
|
|
@@ -117,24 +144,6 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
117
144
|
|
|
118
145
|
return cls(base_url, api_key, timeout, log_requests, custom_logger)
|
|
119
146
|
|
|
120
|
-
async def __aenter__(self):
|
|
121
|
-
"""Async context manager entry point."""
|
|
122
|
-
self.session = aiohttp.ClientSession(headers=self.headers)
|
|
123
|
-
return self
|
|
124
|
-
|
|
125
|
-
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
126
|
-
"""Async context manager exit point."""
|
|
127
|
-
if self.session:
|
|
128
|
-
await self.session.close()
|
|
129
|
-
self.session = None
|
|
130
|
-
|
|
131
|
-
def _check_session(self):
|
|
132
|
-
"""Check if the client session is initialized."""
|
|
133
|
-
if not self.session:
|
|
134
|
-
raise RuntimeError(
|
|
135
|
-
"Client session not initialized. Use async with AiriaAsyncClient() as client: ..."
|
|
136
|
-
)
|
|
137
|
-
|
|
138
147
|
def _handle_exception(
|
|
139
148
|
self, e: aiohttp.ClientResponseError, url: str, correlation_id: str
|
|
140
149
|
):
|
|
@@ -257,8 +266,10 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
257
266
|
response.raise_for_status()
|
|
258
267
|
|
|
259
268
|
# Yields the response content as a stream if streaming
|
|
260
|
-
async for
|
|
261
|
-
|
|
269
|
+
async for message in async_parse_sse_stream_chunked(
|
|
270
|
+
response.content.iter_any()
|
|
271
|
+
):
|
|
272
|
+
yield message
|
|
262
273
|
|
|
263
274
|
except aiohttp.ClientResponseError as e:
|
|
264
275
|
self._handle_exception(e, request_data.url, request_data.correlation_id)
|
|
@@ -415,8 +426,6 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
415
426
|
... )
|
|
416
427
|
>>> print(response.result)
|
|
417
428
|
"""
|
|
418
|
-
self._check_session()
|
|
419
|
-
|
|
420
429
|
request_data = self._pre_execute_pipeline(
|
|
421
430
|
pipeline_id=pipeline_id,
|
|
422
431
|
user_input=user_input,
|
|
@@ -462,3 +471,112 @@ class AiriaAsyncClient(AiriaBaseClient):
|
|
|
462
471
|
return PipelineExecutionV1StreamedResponse(**resp)
|
|
463
472
|
|
|
464
473
|
return PipelineExecutionV2AsyncStreamedResponse(stream=resp)
|
|
474
|
+
|
|
475
|
+
async def get_active_pipelines_ids(
|
|
476
|
+
self,
|
|
477
|
+
correlation_id: Optional[str] = None,
|
|
478
|
+
api_version: str = ApiVersion.V1.value,
|
|
479
|
+
) -> List[str]:
|
|
480
|
+
"""
|
|
481
|
+
Retrieve a list of active pipeline IDs.
|
|
482
|
+
|
|
483
|
+
This method fetches all currently active pipeline IDs from the Airia API.
|
|
484
|
+
These IDs can be used with other methods like execute_pipeline() or
|
|
485
|
+
get_pipeline_config().
|
|
486
|
+
|
|
487
|
+
Args:
|
|
488
|
+
api_version (str, optional): API version to use for the request.
|
|
489
|
+
Must be one of the supported versions. Defaults to "v1".
|
|
490
|
+
correlation_id (str, optional): Unique identifier for request tracing
|
|
491
|
+
and logging. If not provided, a new UUID will be automatically
|
|
492
|
+
generated.
|
|
493
|
+
|
|
494
|
+
Returns:
|
|
495
|
+
List[str]: A list of active pipeline ID strings. Returns an empty list
|
|
496
|
+
if no active pipelines are found.
|
|
497
|
+
|
|
498
|
+
Raises:
|
|
499
|
+
ValueError: If the provided API version is not supported.
|
|
500
|
+
AiriaAPIError: If the API request fails, including network errors,
|
|
501
|
+
authentication failures, or server errors.
|
|
502
|
+
|
|
503
|
+
Example:
|
|
504
|
+
>>> client = AiriaClient(api_key="your_api_key")
|
|
505
|
+
>>> pipeline_ids = client.get_active_pipelines_ids()
|
|
506
|
+
>>> print(f"Found {len(pipeline_ids)} active pipelines")
|
|
507
|
+
>>> for pipeline_id in pipeline_ids:
|
|
508
|
+
... print(f"Pipeline ID: {pipeline_id}")
|
|
509
|
+
"""
|
|
510
|
+
request_data = self._pre_get_active_pipelines_ids(
|
|
511
|
+
correlation_id=correlation_id, api_version=api_version
|
|
512
|
+
)
|
|
513
|
+
resp = await self._make_request("GET", request_data)
|
|
514
|
+
|
|
515
|
+
if "items" not in resp or len(resp["items"]) == 0:
|
|
516
|
+
return []
|
|
517
|
+
|
|
518
|
+
pipeline_ids = [r["activeVersion"]["pipelineId"] for r in resp["items"]]
|
|
519
|
+
|
|
520
|
+
return pipeline_ids
|
|
521
|
+
|
|
522
|
+
async def get_pipeline_config(
|
|
523
|
+
self,
|
|
524
|
+
pipeline_id: str,
|
|
525
|
+
correlation_id: Optional[str] = None,
|
|
526
|
+
api_version: str = ApiVersion.V1.value,
|
|
527
|
+
) -> GetPipelineConfigResponse:
|
|
528
|
+
"""
|
|
529
|
+
Retrieve configuration details for a specific pipeline.
|
|
530
|
+
|
|
531
|
+
This method fetches comprehensive information about a pipeline including its
|
|
532
|
+
deployment details, execution statistics, version information, and metadata.
|
|
533
|
+
|
|
534
|
+
Args:
|
|
535
|
+
pipeline_id (str): The unique identifier of the pipeline to retrieve
|
|
536
|
+
configuration for.
|
|
537
|
+
api_version (str, optional): The API version to use for the request.
|
|
538
|
+
Defaults to "v1". Valid versions are defined in ApiVersion enum.
|
|
539
|
+
correlation_id (str, optional): A unique identifier for request tracing
|
|
540
|
+
and logging. If not provided, one will be automatically generated.
|
|
541
|
+
|
|
542
|
+
Returns:
|
|
543
|
+
GetPipelineConfigResponse: A response object containing the pipeline
|
|
544
|
+
configuration.
|
|
545
|
+
|
|
546
|
+
Raises:
|
|
547
|
+
ValueError: If the provided api_version is not valid.
|
|
548
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
549
|
+
- The pipeline_id doesn't exist (404)
|
|
550
|
+
- Authentication fails (401)
|
|
551
|
+
- Access is forbidden (403)
|
|
552
|
+
- Server errors (5xx)
|
|
553
|
+
|
|
554
|
+
Example:
|
|
555
|
+
```python
|
|
556
|
+
from airia import AiriaClient
|
|
557
|
+
|
|
558
|
+
client = AiriaClient(api_key="your_api_key")
|
|
559
|
+
|
|
560
|
+
# Get pipeline configuration
|
|
561
|
+
config = client.get_pipeline_config(
|
|
562
|
+
pipeline_id="your_pipeline_id"
|
|
563
|
+
)
|
|
564
|
+
|
|
565
|
+
print(f"Pipeline: {config.deployment_name}")
|
|
566
|
+
print(f"Description: {config.deployment_description}")
|
|
567
|
+
print(f"Success rate: {config.execution_stats.success_count}")
|
|
568
|
+
print(f"Active version: {config.active_version.version_number}")
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
Note:
|
|
572
|
+
This method only retrieves configuration information and does not
|
|
573
|
+
execute the pipeline. Use execute_pipeline() to run the pipeline.
|
|
574
|
+
"""
|
|
575
|
+
request_data = self._pre_get_pipeline_config(
|
|
576
|
+
pipeline_id=pipeline_id,
|
|
577
|
+
correlation_id=correlation_id,
|
|
578
|
+
api_version=api_version,
|
|
579
|
+
)
|
|
580
|
+
resp = await self._make_request("GET", request_data)
|
|
581
|
+
|
|
582
|
+
return GetPipelineConfigResponse(**resp)
|
|
@@ -11,6 +11,7 @@ from ..types import ApiVersion, RequestData
|
|
|
11
11
|
|
|
12
12
|
class AiriaBaseClient:
|
|
13
13
|
"""Base client containing shared functionality for Airia API clients."""
|
|
14
|
+
|
|
14
15
|
openai = None
|
|
15
16
|
anthropic = None
|
|
16
17
|
|
|
@@ -186,3 +187,32 @@ class AiriaBaseClient:
|
|
|
186
187
|
request_data = self._prepare_request(url, payload, correlation_id)
|
|
187
188
|
|
|
188
189
|
return request_data
|
|
190
|
+
|
|
191
|
+
def _pre_get_active_pipelines_ids(
|
|
192
|
+
self,
|
|
193
|
+
correlation_id: Optional[str] = None,
|
|
194
|
+
api_version: str = ApiVersion.V1.value,
|
|
195
|
+
):
|
|
196
|
+
if api_version not in ApiVersion.as_list():
|
|
197
|
+
raise ValueError(
|
|
198
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
199
|
+
)
|
|
200
|
+
url = urljoin(self.base_url, f"{api_version}/PipelinesConfig")
|
|
201
|
+
request_data = self._prepare_request(url, correlation_id=correlation_id)
|
|
202
|
+
|
|
203
|
+
return request_data
|
|
204
|
+
|
|
205
|
+
def _pre_get_pipeline_config(
|
|
206
|
+
self,
|
|
207
|
+
pipeline_id: str,
|
|
208
|
+
correlation_id: Optional[str] = None,
|
|
209
|
+
api_version: str = ApiVersion.V1.value,
|
|
210
|
+
):
|
|
211
|
+
if api_version not in ApiVersion.as_list():
|
|
212
|
+
raise ValueError(
|
|
213
|
+
f"Invalid API version: {api_version}. Valid versions are: {', '.join(ApiVersion.as_list())}"
|
|
214
|
+
)
|
|
215
|
+
url = urljoin(self.base_url, f"{api_version}/PipelinesConfig/{pipeline_id}")
|
|
216
|
+
request_data = self._prepare_request(url, correlation_id=correlation_id)
|
|
217
|
+
|
|
218
|
+
return request_data
|