airia 0.1.12__py3-none-any.whl → 0.1.14__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/_request_handler/__init__.py +4 -0
- airia/client/_request_handler/async_request_handler.py +272 -0
- airia/client/_request_handler/base_request_handler.py +108 -0
- airia/client/_request_handler/sync_request_handler.py +255 -0
- airia/client/async_client.py +25 -584
- airia/client/base_client.py +2 -209
- airia/client/conversations/__init__.py +4 -0
- airia/client/conversations/async_conversations.py +187 -0
- airia/client/conversations/base_conversations.py +135 -0
- airia/client/conversations/sync_conversations.py +182 -0
- airia/client/pipeline_execution/__init__.py +4 -0
- airia/client/pipeline_execution/async_pipeline_execution.py +178 -0
- airia/client/pipeline_execution/base_pipeline_execution.py +96 -0
- airia/client/pipeline_execution/sync_pipeline_execution.py +178 -0
- airia/client/pipelines_config/__init__.py +4 -0
- airia/client/pipelines_config/async_pipelines_config.py +127 -0
- airia/client/pipelines_config/base_pipelines_config.py +76 -0
- airia/client/pipelines_config/sync_pipelines_config.py +127 -0
- airia/client/project/__init__.py +4 -0
- airia/client/project/async_project.py +122 -0
- airia/client/project/base_project.py +74 -0
- airia/client/project/sync_project.py +120 -0
- airia/client/store/__init__.py +4 -0
- airia/client/store/async_store.py +377 -0
- airia/client/store/base_store.py +243 -0
- airia/client/store/sync_store.py +352 -0
- airia/client/sync_client.py +25 -563
- airia/constants.py +13 -2
- airia/exceptions.py +8 -8
- airia/logs.py +10 -32
- airia/types/__init__.py +0 -0
- airia/types/_request_data.py +29 -2
- airia/types/api/__init__.py +0 -19
- airia/types/api/conversations/__init__.py +3 -0
- airia/types/api/conversations/_conversations.py +115 -0
- airia/types/api/pipeline_execution/__init__.py +13 -0
- airia/types/api/pipeline_execution/_pipeline_execution.py +76 -0
- airia/types/api/pipelines_config/__init__.py +3 -0
- airia/types/api/pipelines_config/get_pipeline_config.py +401 -0
- airia/types/api/project/__init__.py +3 -0
- airia/types/api/project/get_projects.py +91 -0
- airia/types/api/store/__init__.py +4 -0
- airia/types/api/store/get_file.py +145 -0
- airia/types/api/store/get_files.py +21 -0
- airia/types/sse/__init__.py +8 -0
- airia/types/sse/sse_messages.py +209 -0
- airia/utils/sse_parser.py +40 -7
- airia-0.1.14.dist-info/METADATA +221 -0
- airia-0.1.14.dist-info/RECORD +55 -0
- airia/types/api/conversations.py +0 -14
- airia/types/api/get_pipeline_config.py +0 -183
- airia/types/api/get_projects.py +0 -35
- airia/types/api/pipeline_execution.py +0 -29
- airia-0.1.12.dist-info/METADATA +0 -705
- airia-0.1.12.dist-info/RECORD +0 -23
- {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/WHEEL +0 -0
- {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/licenses/LICENSE +0 -0
- {airia-0.1.12.dist-info → airia-0.1.14.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from ...types._api_version import ApiVersion
|
|
4
|
+
from ...types.api.store import File, GetFileResponse, GetFilesResponse
|
|
5
|
+
from .._request_handler import RequestHandler
|
|
6
|
+
from .base_store import BaseStore
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Store(BaseStore):
|
|
10
|
+
def __init__(self, request_handler: RequestHandler):
|
|
11
|
+
super().__init__(request_handler)
|
|
12
|
+
|
|
13
|
+
def upload_file(
|
|
14
|
+
self,
|
|
15
|
+
store_connector_id: str,
|
|
16
|
+
project_id: str,
|
|
17
|
+
file_path: str,
|
|
18
|
+
folder_id: Optional[str] = None,
|
|
19
|
+
pending_ingestion: bool = True,
|
|
20
|
+
correlation_id: Optional[str] = None,
|
|
21
|
+
) -> File:
|
|
22
|
+
"""
|
|
23
|
+
Upload a file to the Airia store.
|
|
24
|
+
|
|
25
|
+
This method uploads a file to the specified store connector and project,
|
|
26
|
+
with optional folder organization and ingestion settings.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
store_connector_id: The unique identifier of the store connector (GUID format)
|
|
30
|
+
project_id: The unique identifier of the project (GUID format)
|
|
31
|
+
file_path: Path to the file on disk
|
|
32
|
+
folder_id: Optional folder identifier for organizing the file (GUID format)
|
|
33
|
+
pending_ingestion: Whether the file should be marked as pending ingestion. Default is True.
|
|
34
|
+
correlation_id: Optional correlation ID for request tracing
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
File: object containing details about the uploaded file.
|
|
38
|
+
|
|
39
|
+
Raises:
|
|
40
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
41
|
+
- The store_connector_id doesn't exist (404)
|
|
42
|
+
- The project_id doesn't exist (404)
|
|
43
|
+
- The folder_id is invalid (400)
|
|
44
|
+
- Authentication fails (401)
|
|
45
|
+
- Access is forbidden (403)
|
|
46
|
+
- Server errors (5xx)
|
|
47
|
+
ValueError: If required parameters are missing or invalid
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
```python
|
|
51
|
+
from airia import AiriaClient
|
|
52
|
+
|
|
53
|
+
client = AiriaClient(api_key="your_api_key")
|
|
54
|
+
|
|
55
|
+
# Upload file
|
|
56
|
+
uploaded_file = client.store.upload_file(
|
|
57
|
+
store_connector_id="your_store_connector_id",
|
|
58
|
+
project_id="your_project_id",
|
|
59
|
+
file_path="document.pdf"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Upload with folder organization
|
|
63
|
+
uploaded_file = client.store.upload_file(
|
|
64
|
+
store_connector_id="your_store_connector_id",
|
|
65
|
+
project_id="your_project_id",
|
|
66
|
+
file_path="document.pdf",
|
|
67
|
+
folder_id="your_folder_id",
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
"""
|
|
71
|
+
request_data = self._pre_upload_file(
|
|
72
|
+
store_connector_id=store_connector_id,
|
|
73
|
+
project_id=project_id,
|
|
74
|
+
file_path=file_path,
|
|
75
|
+
folder_id=folder_id,
|
|
76
|
+
pending_ingestion=pending_ingestion,
|
|
77
|
+
correlation_id=correlation_id,
|
|
78
|
+
api_version=ApiVersion.V1.value,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
response = self._request_handler.make_request_multipart(
|
|
83
|
+
"POST", request_data
|
|
84
|
+
)
|
|
85
|
+
return File(**response)
|
|
86
|
+
finally:
|
|
87
|
+
request_data.files["File"][1].close()
|
|
88
|
+
|
|
89
|
+
def update_file(
|
|
90
|
+
self,
|
|
91
|
+
store_connector_id: str,
|
|
92
|
+
store_file_id: str,
|
|
93
|
+
project_id: str,
|
|
94
|
+
file_path: str,
|
|
95
|
+
pending_ingestion: bool = True,
|
|
96
|
+
correlation_id: Optional[str] = None,
|
|
97
|
+
) -> str:
|
|
98
|
+
"""
|
|
99
|
+
Update an existing file in the Airia store.
|
|
100
|
+
|
|
101
|
+
This method updates an existing file in the specified store connector and project,
|
|
102
|
+
with optional ingestion settings.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
store_connector_id: The unique identifier of the store connector (GUID format)
|
|
106
|
+
store_file_id: The unique identifier of the file to update (GUID format)
|
|
107
|
+
project_id: The unique identifier of the project (GUID format)
|
|
108
|
+
file_path: Path to the file on disk
|
|
109
|
+
pending_ingestion: Whether the file should be marked as pending ingestion. Default is True.
|
|
110
|
+
correlation_id: Optional correlation ID for request tracing
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
The File ID of the updated file.
|
|
114
|
+
|
|
115
|
+
Raises:
|
|
116
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
117
|
+
- The store_connector_id doesn't exist (404)
|
|
118
|
+
- The store_file_id doesn't exist (404)
|
|
119
|
+
- The project_id doesn't exist (404)
|
|
120
|
+
- Authentication fails (401)
|
|
121
|
+
- Access is forbidden (403)
|
|
122
|
+
- Server errors (5xx)
|
|
123
|
+
ValueError: If required parameters are missing or invalid
|
|
124
|
+
|
|
125
|
+
Example:
|
|
126
|
+
```python
|
|
127
|
+
from airia import AiriaClient
|
|
128
|
+
|
|
129
|
+
client = AiriaClient(api_key="your_api_key")
|
|
130
|
+
|
|
131
|
+
# Update existing file
|
|
132
|
+
updated_file_id = client.store.update_file(
|
|
133
|
+
store_connector_id="your_store_connector_id",
|
|
134
|
+
store_file_id="your_store_file_id",
|
|
135
|
+
project_id="your_project_id",
|
|
136
|
+
file_path="document.pdf"
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
"""
|
|
140
|
+
request_data = self._pre_update_file(
|
|
141
|
+
store_connector_id=store_connector_id,
|
|
142
|
+
store_file_id=store_file_id,
|
|
143
|
+
project_id=project_id,
|
|
144
|
+
file_path=file_path,
|
|
145
|
+
pending_ingestion=pending_ingestion,
|
|
146
|
+
correlation_id=correlation_id,
|
|
147
|
+
api_version=ApiVersion.V1.value,
|
|
148
|
+
)
|
|
149
|
+
try:
|
|
150
|
+
response = self._request_handler.make_request_multipart("PUT", request_data)
|
|
151
|
+
return response["fileId"]
|
|
152
|
+
finally:
|
|
153
|
+
request_data.files["File"][1].close()
|
|
154
|
+
|
|
155
|
+
def get_file(
|
|
156
|
+
self,
|
|
157
|
+
project_id: str,
|
|
158
|
+
file_id: str,
|
|
159
|
+
correlation_id: Optional[str] = None,
|
|
160
|
+
) -> GetFileResponse:
|
|
161
|
+
"""
|
|
162
|
+
Retrieve a file from the Airia store.
|
|
163
|
+
|
|
164
|
+
This method retrieves file information, download URL, and preview information
|
|
165
|
+
for a specific file in the given project.
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
project_id: The unique identifier of the project (GUID format)
|
|
169
|
+
file_id: The unique identifier of the file (GUID format)
|
|
170
|
+
correlation_id: Optional correlation ID for request tracing
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
GetFileResponse: File information including metadata, download info, and preview info
|
|
174
|
+
|
|
175
|
+
Raises:
|
|
176
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
177
|
+
- The project_id doesn't exist (404)
|
|
178
|
+
- The file_id doesn't exist (404)
|
|
179
|
+
- Authentication fails (401)
|
|
180
|
+
- Access is forbidden (403)
|
|
181
|
+
- Server errors (5xx)
|
|
182
|
+
ValueError: If required parameters are missing or invalid
|
|
183
|
+
|
|
184
|
+
Example:
|
|
185
|
+
```python
|
|
186
|
+
from airia import AiriaClient
|
|
187
|
+
|
|
188
|
+
client = AiriaClient(api_key="your_api_key")
|
|
189
|
+
|
|
190
|
+
# Get file information
|
|
191
|
+
file_info = client.store.get_file(
|
|
192
|
+
project_id="your_project_id",
|
|
193
|
+
file_id="your_file_id"
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
# Access file metadata
|
|
197
|
+
if file_info.file:
|
|
198
|
+
print(f"File name: {file_info.file.name}")
|
|
199
|
+
print(f"File size: {file_info.file.size}")
|
|
200
|
+
print(f"Status: {file_info.file.status}")
|
|
201
|
+
|
|
202
|
+
# Access download URL
|
|
203
|
+
if file_info.downloadInfo:
|
|
204
|
+
print(f"Download URL: {file_info.download_info.url}")
|
|
205
|
+
|
|
206
|
+
# Access preview information
|
|
207
|
+
if file_info.previewInfo:
|
|
208
|
+
print(f"Preview URL: {file_info.preview_info.preview_url}")
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Note:
|
|
212
|
+
The response includes three optional components:
|
|
213
|
+
- file: File metadata and processing status
|
|
214
|
+
- downloadInfo: Direct download URL for the file
|
|
215
|
+
- previewInfo: Preview URL and connector information
|
|
216
|
+
"""
|
|
217
|
+
request_data = self._pre_get_file(
|
|
218
|
+
project_id=project_id,
|
|
219
|
+
file_id=file_id,
|
|
220
|
+
correlation_id=correlation_id,
|
|
221
|
+
api_version=ApiVersion.V1.value,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
response = self._request_handler.make_request(
|
|
225
|
+
"GET", request_data, return_json=True
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
return GetFileResponse(**response)
|
|
229
|
+
|
|
230
|
+
def get_files(
|
|
231
|
+
self,
|
|
232
|
+
project_id: str,
|
|
233
|
+
store_connector_id: str,
|
|
234
|
+
correlation_id: Optional[str] = None,
|
|
235
|
+
) -> GetFilesResponse:
|
|
236
|
+
"""
|
|
237
|
+
Retrieve all files from a store connector in the Airia store.
|
|
238
|
+
|
|
239
|
+
This method retrieves information about all files in the specified store connector
|
|
240
|
+
and project, including file metadata, download URLs, and processing status.
|
|
241
|
+
|
|
242
|
+
Args:
|
|
243
|
+
project_id: The unique identifier of the project (GUID format)
|
|
244
|
+
store_connector_id: The unique identifier of the store connector (GUID format)
|
|
245
|
+
correlation_id: Optional correlation ID for request tracing
|
|
246
|
+
|
|
247
|
+
Returns:
|
|
248
|
+
GetFilesResponse: List of files with metadata, download info, and total count
|
|
249
|
+
|
|
250
|
+
Raises:
|
|
251
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
252
|
+
- The project_id doesn't exist (404)
|
|
253
|
+
- The store_connector_id doesn't exist (404)
|
|
254
|
+
- Authentication fails (401)
|
|
255
|
+
- Access is forbidden (403)
|
|
256
|
+
- Server errors (5xx)
|
|
257
|
+
ValueError: If required parameters are missing or invalid
|
|
258
|
+
|
|
259
|
+
Example:
|
|
260
|
+
```python
|
|
261
|
+
from airia import AiriaClient
|
|
262
|
+
|
|
263
|
+
client = AiriaClient(api_key="your_api_key")
|
|
264
|
+
|
|
265
|
+
# Get all files from a store connector
|
|
266
|
+
files_response = client.store.get_files(
|
|
267
|
+
project_id="your_project_id",
|
|
268
|
+
store_connector_id="your_store_connector_id"
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
# Access files list
|
|
272
|
+
if files_response.files:
|
|
273
|
+
for file in files_response.files:
|
|
274
|
+
print(f"File: {file.name}, Status: {file.status}, Size: {file.size}")
|
|
275
|
+
|
|
276
|
+
# Access download URLs
|
|
277
|
+
if files_response.downloadInfos:
|
|
278
|
+
for download_info in files_response.downloadInfos:
|
|
279
|
+
print(f"File ID: {download_info.fileId}, URL: {download_info.url}")
|
|
280
|
+
|
|
281
|
+
# Access total count
|
|
282
|
+
print(f"Total files: {files_response.totalCount}")
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Note:
|
|
286
|
+
The response includes:
|
|
287
|
+
- files: List of file metadata and processing status
|
|
288
|
+
- downloadInfos: List of direct download URLs for files
|
|
289
|
+
- totalCount: Total number of files in the store connector
|
|
290
|
+
"""
|
|
291
|
+
request_data = self._pre_get_files(
|
|
292
|
+
project_id=project_id,
|
|
293
|
+
store_connector_id=store_connector_id,
|
|
294
|
+
correlation_id=correlation_id,
|
|
295
|
+
api_version=ApiVersion.V1.value,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
response = self._request_handler.make_request(
|
|
299
|
+
"GET", request_data, return_json=True
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
return GetFilesResponse(**response)
|
|
303
|
+
|
|
304
|
+
def delete_file(
|
|
305
|
+
self,
|
|
306
|
+
project_id: str,
|
|
307
|
+
file_id: str,
|
|
308
|
+
correlation_id: Optional[str] = None,
|
|
309
|
+
) -> None:
|
|
310
|
+
"""
|
|
311
|
+
Delete a file from the Airia store.
|
|
312
|
+
|
|
313
|
+
This method deletes a specific file from the given project.
|
|
314
|
+
|
|
315
|
+
Args:
|
|
316
|
+
project_id: The unique identifier of the project (GUID format)
|
|
317
|
+
file_id: The unique identifier of the file to delete (GUID format)
|
|
318
|
+
correlation_id: Optional correlation ID for request tracing
|
|
319
|
+
|
|
320
|
+
Returns:
|
|
321
|
+
None
|
|
322
|
+
|
|
323
|
+
Raises:
|
|
324
|
+
AiriaAPIError: If the API request fails, including cases where:
|
|
325
|
+
- The project_id doesn't exist (404)
|
|
326
|
+
- The file_id doesn't exist (404)
|
|
327
|
+
- Authentication fails (401)
|
|
328
|
+
- Access is forbidden (403)
|
|
329
|
+
- Server errors (5xx)
|
|
330
|
+
ValueError: If required parameters are missing or invalid
|
|
331
|
+
|
|
332
|
+
Example:
|
|
333
|
+
```python
|
|
334
|
+
from airia import AiriaClient
|
|
335
|
+
|
|
336
|
+
client = AiriaClient(api_key="your_api_key")
|
|
337
|
+
|
|
338
|
+
# Delete a file
|
|
339
|
+
client.store.delete_file(
|
|
340
|
+
project_id="your_project_id",
|
|
341
|
+
file_id="your_file_id"
|
|
342
|
+
)
|
|
343
|
+
```
|
|
344
|
+
"""
|
|
345
|
+
request_data = self._pre_delete_file(
|
|
346
|
+
project_id=project_id,
|
|
347
|
+
file_id=file_id,
|
|
348
|
+
correlation_id=correlation_id,
|
|
349
|
+
api_version=ApiVersion.V1.value,
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
self._request_handler.make_request("DELETE", request_data, return_json=False)
|