pygeai 0.4.0b4__py3-none-any.whl → 0.4.0b5__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.
- pygeai/cli/commands/chat.py +8 -2
- pygeai/cli/commands/lab/ai_lab.py +44 -550
- pygeai/cli/commands/lab/utils.py +13 -0
- pygeai/cli/geai.py +5 -2
- pygeai/cli/texts/help.py +12 -0
- pygeai/core/common/exceptions.py +5 -0
- pygeai/lab/agents/clients.py +30 -61
- pygeai/lab/clients.py +17 -0
- pygeai/lab/managers.py +1 -53
- pygeai/lab/processes/clients.py +81 -129
- pygeai/lab/strategies/clients.py +11 -17
- pygeai/lab/tools/clients.py +30 -50
- pygeai/tests/integration/lab/tools/test_create_tool.py +3 -4
- pygeai/tests/integration/lab/tools/test_list_tools.py +77 -9
- pygeai/tests/integration/lab/tools/test_update_tool.py +268 -0
- {pygeai-0.4.0b4.dist-info → pygeai-0.4.0b5.dist-info}/METADATA +1 -1
- {pygeai-0.4.0b4.dist-info → pygeai-0.4.0b5.dist-info}/RECORD +21 -18
- {pygeai-0.4.0b4.dist-info → pygeai-0.4.0b5.dist-info}/WHEEL +0 -0
- {pygeai-0.4.0b4.dist-info → pygeai-0.4.0b5.dist-info}/entry_points.txt +0 -0
- {pygeai-0.4.0b4.dist-info → pygeai-0.4.0b5.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.4.0b4.dist-info → pygeai-0.4.0b5.dist-info}/top_level.txt +0 -0
pygeai/lab/processes/clients.py
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
from json import JSONDecodeError
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import List
|
|
3
3
|
|
|
4
4
|
from pygeai import logger
|
|
5
|
-
from pygeai.core.base.clients import BaseClient
|
|
6
5
|
from pygeai.core.common.exceptions import InvalidAPIResponseException
|
|
7
6
|
from pygeai.lab.processes.endpoints import CREATE_PROCESS_V2, UPDATE_PROCESS_V2, UPSERT_PROCESS_V2, GET_PROCESS_V2, \
|
|
8
7
|
LIST_PROCESSES_V2, LIST_PROCESS_INSTANCES_V2, DELETE_PROCESS_V2, PUBLISH_PROCESS_REVISION_V2, CREATE_TASK_V2, \
|
|
9
8
|
UPDATE_TASK_V2, UPSERT_TASK_V2, GET_TASK_V2, LIST_TASKS_V2, DELETE_TASK_V2, PUBLISH_TASK_REVISION_V2, \
|
|
10
9
|
START_INSTANCE_V2, ABORT_INSTANCE_V2, GET_INSTANCE_V2, GET_INSTANCE_HISTORY_V2, GET_THREAD_INFORMATION_V2, \
|
|
11
10
|
SEND_USER_SIGNAL_V2, CREATE_KB_V1, GET_KB_V1, LIST_KBS_V1, DELETE_KB_V1, LIST_JOBS_V1
|
|
11
|
+
from pygeai.lab.clients import AILabClient
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
class AgenticProcessClient(
|
|
14
|
+
class AgenticProcessClient(AILabClient):
|
|
15
15
|
|
|
16
16
|
def create_process(
|
|
17
17
|
self,
|
|
18
|
-
project_id: str,
|
|
19
18
|
key: str,
|
|
20
19
|
name: str,
|
|
21
20
|
description: str = None,
|
|
@@ -32,7 +31,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
32
31
|
"""
|
|
33
32
|
Creates a new process in the specified project.
|
|
34
33
|
|
|
35
|
-
:param project_id: str - Unique identifier of the project.
|
|
36
34
|
:param key: str - Unique key for the process within the project.
|
|
37
35
|
:param name: str - Name of the process.
|
|
38
36
|
:param description: str, optional - Description of the process purpose.
|
|
@@ -54,7 +52,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
54
52
|
|
|
55
53
|
headers = {
|
|
56
54
|
"Authorization": self.api_service.token,
|
|
57
|
-
"ProjectId": project_id,
|
|
55
|
+
"ProjectId": self.project_id,
|
|
58
56
|
"Content-Type": "application/json",
|
|
59
57
|
"Accept": "application/json"
|
|
60
58
|
}
|
|
@@ -89,14 +87,13 @@ class AgenticProcessClient(BaseClient):
|
|
|
89
87
|
try:
|
|
90
88
|
result = response.json()
|
|
91
89
|
except JSONDecodeError as e:
|
|
92
|
-
logger.error(f"Unable to create process for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
93
|
-
raise InvalidAPIResponseException(f"Unable to create process for project {project_id}: {response.text}")
|
|
90
|
+
logger.error(f"Unable to create process for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
91
|
+
raise InvalidAPIResponseException(f"Unable to create process for project {self.project_id}: {response.text}")
|
|
94
92
|
|
|
95
93
|
return result
|
|
96
94
|
|
|
97
95
|
def update_process(
|
|
98
96
|
self,
|
|
99
|
-
project_id: str,
|
|
100
97
|
process_id: str = None,
|
|
101
98
|
name: str = None,
|
|
102
99
|
key: str = None,
|
|
@@ -115,7 +112,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
115
112
|
"""
|
|
116
113
|
Updates an existing process or creates it if upsert is enabled.
|
|
117
114
|
|
|
118
|
-
:param project_id: str - Unique identifier of the project.
|
|
119
115
|
:param process_id: str, optional - Unique identifier of the process to update.
|
|
120
116
|
:param name: str, optional - Name of the process to update or create.
|
|
121
117
|
:param key: str, optional - Updated unique key for the process.
|
|
@@ -146,7 +142,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
146
142
|
|
|
147
143
|
headers = {
|
|
148
144
|
"Authorization": self.api_service.token,
|
|
149
|
-
"ProjectId": project_id,
|
|
145
|
+
"ProjectId": self.project_id,
|
|
150
146
|
"Content-Type": "application/json",
|
|
151
147
|
"Accept": "application/json"
|
|
152
148
|
}
|
|
@@ -177,12 +173,12 @@ class AgenticProcessClient(BaseClient):
|
|
|
177
173
|
data["processDefinition"]["variables"] = variables
|
|
178
174
|
|
|
179
175
|
if kb is None and not upsert:
|
|
180
|
-
current_process = self.get_process(
|
|
176
|
+
current_process = self.get_process(process_id=process_id, process_name=name)
|
|
181
177
|
if isinstance(current_process, dict) and "processDefinition" in current_process:
|
|
182
178
|
kb = current_process["processDefinition"].get("kb")
|
|
183
179
|
|
|
184
180
|
if agentic_activities is None and not upsert:
|
|
185
|
-
current_process = self.get_process(
|
|
181
|
+
current_process = self.get_process(process_id=process_id, process_name=name)
|
|
186
182
|
if isinstance(current_process, dict) and "processDefinition" in current_process:
|
|
187
183
|
agentic_activities = current_process["processDefinition"].get("agenticActivities")
|
|
188
184
|
if agentic_activities is not None:
|
|
@@ -201,14 +197,13 @@ class AgenticProcessClient(BaseClient):
|
|
|
201
197
|
try:
|
|
202
198
|
result = response.json()
|
|
203
199
|
except JSONDecodeError as e:
|
|
204
|
-
logger.error(f"Unable to update process {process_id or name} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
205
|
-
raise InvalidAPIResponseException(f"Unable to update process {process_id or name} in project {project_id}: {response.text}")
|
|
200
|
+
logger.error(f"Unable to update process {process_id or name} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
201
|
+
raise InvalidAPIResponseException(f"Unable to update process {process_id or name} in project {self.project_id}: {response.text}")
|
|
206
202
|
|
|
207
203
|
return result
|
|
208
204
|
|
|
209
205
|
def get_process(
|
|
210
206
|
self,
|
|
211
|
-
project_id: str,
|
|
212
207
|
process_id: str = None,
|
|
213
208
|
process_name: str = None,
|
|
214
209
|
revision: str = "0",
|
|
@@ -218,7 +213,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
218
213
|
"""
|
|
219
214
|
Retrieves details of a specific process by its ID or name.
|
|
220
215
|
|
|
221
|
-
:param project_id: str - Unique identifier of the project.
|
|
222
216
|
:param process_id: str, optional - Unique identifier of the process.
|
|
223
217
|
:param process_name: str, optional - Name of the process.
|
|
224
218
|
:param revision: str, optional - Revision of the process (default: '0').
|
|
@@ -236,7 +230,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
236
230
|
|
|
237
231
|
headers = {
|
|
238
232
|
"Authorization": self.api_service.token,
|
|
239
|
-
"ProjectId": project_id
|
|
233
|
+
"ProjectId": self.project_id
|
|
240
234
|
}
|
|
241
235
|
params = {
|
|
242
236
|
"revision": revision,
|
|
@@ -257,14 +251,13 @@ class AgenticProcessClient(BaseClient):
|
|
|
257
251
|
try:
|
|
258
252
|
result = response.json()
|
|
259
253
|
except JSONDecodeError as e:
|
|
260
|
-
logger.error(f"Unable to retrieve process {process_id or process_name} for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
261
|
-
raise InvalidAPIResponseException(f"Unable to retrieve process {process_id or process_name} for project {project_id}: {response.text}")
|
|
254
|
+
logger.error(f"Unable to retrieve process {process_id or process_name} for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
255
|
+
raise InvalidAPIResponseException(f"Unable to retrieve process {process_id or process_name} for project {self.project_id}: {response.text}")
|
|
262
256
|
|
|
263
257
|
return result
|
|
264
258
|
|
|
265
259
|
def list_processes(
|
|
266
260
|
self,
|
|
267
|
-
project_id: str,
|
|
268
261
|
id: str = None,
|
|
269
262
|
name: str = None,
|
|
270
263
|
status: str = None,
|
|
@@ -275,7 +268,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
275
268
|
"""
|
|
276
269
|
Retrieves a list of processes in the specified project.
|
|
277
270
|
|
|
278
|
-
:param project_id: str - Unique identifier of the project.
|
|
279
271
|
:param id: str, optional - ID of the process to filter by.
|
|
280
272
|
:param name: str, optional - Name of the process to filter by.
|
|
281
273
|
:param status: str, optional - Status of the processes (e.g., 'active', 'inactive').
|
|
@@ -288,7 +280,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
288
280
|
endpoint = LIST_PROCESSES_V2
|
|
289
281
|
headers = {
|
|
290
282
|
"Authorization": self.api_service.token,
|
|
291
|
-
"ProjectId": project_id
|
|
283
|
+
"ProjectId": self.project_id
|
|
292
284
|
}
|
|
293
285
|
params = {
|
|
294
286
|
"start": start,
|
|
@@ -302,7 +294,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
302
294
|
if status:
|
|
303
295
|
params["status"] = status
|
|
304
296
|
|
|
305
|
-
logger.debug(f"Listing agentic processes for project with ID {project_id}")
|
|
297
|
+
logger.debug(f"Listing agentic processes for project with ID {self.project_id}")
|
|
306
298
|
|
|
307
299
|
response = self.api_service.get(
|
|
308
300
|
endpoint=endpoint,
|
|
@@ -312,14 +304,13 @@ class AgenticProcessClient(BaseClient):
|
|
|
312
304
|
try:
|
|
313
305
|
result = response.json()
|
|
314
306
|
except JSONDecodeError as e:
|
|
315
|
-
logger.error(f"Unable to list processes for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
316
|
-
raise InvalidAPIResponseException(f"Unable to list processes for project {project_id}: {response.text}")
|
|
307
|
+
logger.error(f"Unable to list processes for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
308
|
+
raise InvalidAPIResponseException(f"Unable to list processes for project {self.project_id}: {response.text}")
|
|
317
309
|
|
|
318
310
|
return result
|
|
319
311
|
|
|
320
312
|
def list_process_instances(
|
|
321
313
|
self,
|
|
322
|
-
project_id: str,
|
|
323
314
|
process_id: str,
|
|
324
315
|
is_active: bool = True,
|
|
325
316
|
start: str = "0",
|
|
@@ -328,7 +319,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
328
319
|
"""
|
|
329
320
|
Retrieves a list of process instances for a specific process.
|
|
330
321
|
|
|
331
|
-
:param project_id: str - Unique identifier of the project.
|
|
332
322
|
:param process_id: str - Unique identifier of the process.
|
|
333
323
|
:param is_active: bool, optional - List only active instances (default: True).
|
|
334
324
|
:param start: str, optional - Starting index for pagination (default: '0').
|
|
@@ -343,7 +333,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
343
333
|
endpoint = LIST_PROCESS_INSTANCES_V2.format(processId=process_id)
|
|
344
334
|
headers = {
|
|
345
335
|
"Authorization": self.api_service.token,
|
|
346
|
-
"ProjectId": project_id
|
|
336
|
+
"ProjectId": self.project_id
|
|
347
337
|
}
|
|
348
338
|
params = {
|
|
349
339
|
"isActive": is_active,
|
|
@@ -361,21 +351,19 @@ class AgenticProcessClient(BaseClient):
|
|
|
361
351
|
try:
|
|
362
352
|
result = response.json()
|
|
363
353
|
except JSONDecodeError as e:
|
|
364
|
-
logger.error(f"Unable to list process instances for process {process_id} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
365
|
-
raise InvalidAPIResponseException(f"Unable to list process instances for process {process_id} in project {project_id}: {response.text}")
|
|
354
|
+
logger.error(f"Unable to list process instances for process {process_id} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
355
|
+
raise InvalidAPIResponseException(f"Unable to list process instances for process {process_id} in project {self.project_id}: {response.text}")
|
|
366
356
|
|
|
367
357
|
return result
|
|
368
358
|
|
|
369
359
|
def delete_process(
|
|
370
360
|
self,
|
|
371
|
-
project_id: str,
|
|
372
361
|
process_id: str = None,
|
|
373
362
|
process_name: str = None
|
|
374
363
|
) -> dict:
|
|
375
364
|
"""
|
|
376
365
|
Deletes a specific process by its ID or name.
|
|
377
366
|
|
|
378
|
-
:param project_id: str - Unique identifier of the project.
|
|
379
367
|
:param process_id: str, optional - Unique identifier of the process.
|
|
380
368
|
:param process_name: str, optional - Name of the process.
|
|
381
369
|
:return: dict or str - Confirmation of deletion or error message.
|
|
@@ -390,7 +378,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
390
378
|
|
|
391
379
|
headers = {
|
|
392
380
|
"Authorization": self.api_service.token,
|
|
393
|
-
"ProjectId": project_id
|
|
381
|
+
"ProjectId": self.project_id
|
|
394
382
|
}
|
|
395
383
|
|
|
396
384
|
logger.debug(f"Deleting agentic process with ID {process_id}")
|
|
@@ -401,14 +389,13 @@ class AgenticProcessClient(BaseClient):
|
|
|
401
389
|
)
|
|
402
390
|
|
|
403
391
|
if response.status_code != 204:
|
|
404
|
-
logger.error(f"Unable to delete process {process_id or process_name} from project {project_id}: JSON parsing error (status {response.status_code}). Response: {response.text}")
|
|
405
|
-
raise InvalidAPIResponseException(f"Unable to delete process {process_id or process_name} from project {project_id}: {response.text}")
|
|
392
|
+
logger.error(f"Unable to delete process {process_id or process_name} from project {self.project_id}: JSON parsing error (status {response.status_code}). Response: {response.text}")
|
|
393
|
+
raise InvalidAPIResponseException(f"Unable to delete process {process_id or process_name} from project {self.project_id}: {response.text}")
|
|
406
394
|
else:
|
|
407
395
|
return {}
|
|
408
396
|
|
|
409
397
|
def publish_process_revision(
|
|
410
398
|
self,
|
|
411
|
-
project_id: str,
|
|
412
399
|
process_id: str = None,
|
|
413
400
|
process_name: str = None,
|
|
414
401
|
revision: str = None
|
|
@@ -416,7 +403,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
416
403
|
"""
|
|
417
404
|
Publishes a specific revision of a process.
|
|
418
405
|
|
|
419
|
-
:param project_id: str - Unique identifier of the project.
|
|
420
406
|
:param process_id: str, optional - Unique identifier of the process.
|
|
421
407
|
:param process_name: str, optional - Name of the process.
|
|
422
408
|
:param revision: str, optional - Revision of the process to publish.
|
|
@@ -434,7 +420,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
434
420
|
|
|
435
421
|
headers = {
|
|
436
422
|
"Authorization": self.api_service.token,
|
|
437
|
-
"ProjectId": project_id
|
|
423
|
+
"ProjectId": self.project_id
|
|
438
424
|
}
|
|
439
425
|
|
|
440
426
|
if process_id:
|
|
@@ -452,14 +438,13 @@ class AgenticProcessClient(BaseClient):
|
|
|
452
438
|
try:
|
|
453
439
|
result = response.json()
|
|
454
440
|
except JSONDecodeError as e:
|
|
455
|
-
logger.error(f"Unable to publish revision {revision} for process {process_id or process_name} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
456
|
-
raise InvalidAPIResponseException(f"Unable to publish revision {revision} for process {process_id or process_name} in project {project_id}: {response.text}")
|
|
441
|
+
logger.error(f"Unable to publish revision {revision} for process {process_id or process_name} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
442
|
+
raise InvalidAPIResponseException(f"Unable to publish revision {revision} for process {process_id or process_name} in project {self.project_id}: {response.text}")
|
|
457
443
|
|
|
458
444
|
return result
|
|
459
445
|
|
|
460
446
|
def create_task(
|
|
461
447
|
self,
|
|
462
|
-
project_id: str,
|
|
463
448
|
name: str,
|
|
464
449
|
description: str = None,
|
|
465
450
|
title_template: str = None,
|
|
@@ -471,7 +456,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
471
456
|
"""
|
|
472
457
|
Creates a new task in the specified project.
|
|
473
458
|
|
|
474
|
-
:param project_id: str - Unique identifier of the project.
|
|
475
459
|
:param name: str - Name of the task, unique within the project, excluding ':' or '/'.
|
|
476
460
|
:param description: str, optional - Description of the task purpose.
|
|
477
461
|
:param title_template: str, optional - Template for task instance names (e.g., 'specs for {{issue}}').
|
|
@@ -488,7 +472,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
488
472
|
|
|
489
473
|
headers = {
|
|
490
474
|
"Authorization": self.api_service.token,
|
|
491
|
-
"ProjectId": project_id,
|
|
475
|
+
"ProjectId": self.project_id,
|
|
492
476
|
"Content-Type": "application/json",
|
|
493
477
|
"Accept": "application/json"
|
|
494
478
|
}
|
|
@@ -514,19 +498,17 @@ class AgenticProcessClient(BaseClient):
|
|
|
514
498
|
try:
|
|
515
499
|
return response.json()
|
|
516
500
|
except JSONDecodeError as e:
|
|
517
|
-
logger.error(f"Unable to create task for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
518
|
-
raise InvalidAPIResponseException(f"Unable to create task for project {project_id}: {response.text}")
|
|
501
|
+
logger.error(f"Unable to create task for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
502
|
+
raise InvalidAPIResponseException(f"Unable to create task for project {self.project_id}: {response.text}")
|
|
519
503
|
|
|
520
504
|
def get_task(
|
|
521
505
|
self,
|
|
522
|
-
project_id: str,
|
|
523
506
|
task_id: str,
|
|
524
507
|
task_name: str = None
|
|
525
508
|
) -> dict:
|
|
526
509
|
"""
|
|
527
510
|
Retrieves details of a specific task by its ID or name.
|
|
528
511
|
|
|
529
|
-
:param project_id: str - Unique identifier of the project.
|
|
530
512
|
:param task_id: str, optional - Unique identifier of the task.
|
|
531
513
|
:param task_name: str, optional - Name of the task.
|
|
532
514
|
:return: dict or str - Task details or error message.
|
|
@@ -540,7 +522,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
540
522
|
endpoint = GET_TASK_V2.format(taskId=identifier)
|
|
541
523
|
headers = {
|
|
542
524
|
"Authorization": self.api_service.token,
|
|
543
|
-
"ProjectId": project_id
|
|
525
|
+
"ProjectId": self.project_id
|
|
544
526
|
}
|
|
545
527
|
|
|
546
528
|
if task_id:
|
|
@@ -552,12 +534,11 @@ class AgenticProcessClient(BaseClient):
|
|
|
552
534
|
try:
|
|
553
535
|
return response.json()
|
|
554
536
|
except JSONDecodeError as e:
|
|
555
|
-
logger.error(f"Unable to retrieve task {task_id or task_name} for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
556
|
-
raise InvalidAPIResponseException(f"Unable to retrieve task {task_id or task_name} for project {project_id}: {response.text}")
|
|
537
|
+
logger.error(f"Unable to retrieve task {task_id or task_name} for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
538
|
+
raise InvalidAPIResponseException(f"Unable to retrieve task {task_id or task_name} for project {self.project_id}: {response.text}")
|
|
557
539
|
|
|
558
540
|
def list_tasks(
|
|
559
541
|
self,
|
|
560
|
-
project_id: str,
|
|
561
542
|
id: str = None,
|
|
562
543
|
start: str = "0",
|
|
563
544
|
count: str = "100",
|
|
@@ -566,7 +547,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
566
547
|
"""
|
|
567
548
|
Retrieves a list of tasks in the specified project.
|
|
568
549
|
|
|
569
|
-
:param project_id: str - Unique identifier of the project.
|
|
570
550
|
:param id: str, optional - ID of the task to filter by.
|
|
571
551
|
:param start: str, optional - Starting index for pagination (default: '0').
|
|
572
552
|
:param count: str, optional - Number of tasks to retrieve (default: '100').
|
|
@@ -577,7 +557,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
577
557
|
endpoint = LIST_TASKS_V2
|
|
578
558
|
headers = {
|
|
579
559
|
"Authorization": self.api_service.token,
|
|
580
|
-
"ProjectId": project_id
|
|
560
|
+
"ProjectId": self.project_id
|
|
581
561
|
}
|
|
582
562
|
params = {
|
|
583
563
|
"start": start,
|
|
@@ -587,18 +567,17 @@ class AgenticProcessClient(BaseClient):
|
|
|
587
567
|
if id:
|
|
588
568
|
params["id"] = id
|
|
589
569
|
|
|
590
|
-
logger.debug(f"Listing tasks for project with ID {project_id}")
|
|
570
|
+
logger.debug(f"Listing tasks for project with ID {self.project_id}")
|
|
591
571
|
|
|
592
572
|
response = self.api_service.get(endpoint=endpoint, headers=headers, params=params)
|
|
593
573
|
try:
|
|
594
574
|
return response.json()
|
|
595
575
|
except JSONDecodeError as e:
|
|
596
|
-
logger.error(f"Unable to list tasks for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
597
|
-
raise InvalidAPIResponseException(f"Unable to list tasks for project {project_id}: {response.text}")
|
|
576
|
+
logger.error(f"Unable to list tasks for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
577
|
+
raise InvalidAPIResponseException(f"Unable to list tasks for project {self.project_id}: {response.text}")
|
|
598
578
|
|
|
599
579
|
def update_task(
|
|
600
580
|
self,
|
|
601
|
-
project_id: str,
|
|
602
581
|
task_id: str,
|
|
603
582
|
name: str = None,
|
|
604
583
|
description: str = None,
|
|
@@ -612,7 +591,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
612
591
|
"""
|
|
613
592
|
Updates an existing task or creates it if upsert is enabled.
|
|
614
593
|
|
|
615
|
-
:param project_id: str - Unique identifier of the project.
|
|
616
594
|
:param task_id: str - Unique identifier of the task to update.
|
|
617
595
|
:param name: str, optional - Updated name of the task, unique within the project, excluding ':' or '/'.
|
|
618
596
|
:param description: str, optional - Updated description of the task purpose.
|
|
@@ -637,7 +615,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
637
615
|
|
|
638
616
|
headers = {
|
|
639
617
|
"Authorization": self.api_service.token,
|
|
640
|
-
"ProjectId": project_id,
|
|
618
|
+
"ProjectId": self.project_id,
|
|
641
619
|
"Content-Type": "application/json",
|
|
642
620
|
"Accept": "application/json"
|
|
643
621
|
}
|
|
@@ -663,19 +641,17 @@ class AgenticProcessClient(BaseClient):
|
|
|
663
641
|
try:
|
|
664
642
|
return response.json()
|
|
665
643
|
except JSONDecodeError as e:
|
|
666
|
-
logger.error(f"Unable to update task {task_id} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
667
|
-
raise InvalidAPIResponseException(f"Unable to update task {task_id} in project {project_id}: {response.text}")
|
|
644
|
+
logger.error(f"Unable to update task {task_id} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
645
|
+
raise InvalidAPIResponseException(f"Unable to update task {task_id} in project {self.project_id}: {response.text}")
|
|
668
646
|
|
|
669
647
|
def delete_task(
|
|
670
648
|
self,
|
|
671
|
-
project_id: str,
|
|
672
649
|
task_id: str,
|
|
673
650
|
task_name: str = None
|
|
674
651
|
) -> dict:
|
|
675
652
|
"""
|
|
676
653
|
Deletes a specific task by its ID or name.
|
|
677
654
|
|
|
678
|
-
:param project_id: str - Unique identifier of the project.
|
|
679
655
|
:param task_id: str, optional - Unique identifier of the task.
|
|
680
656
|
:param task_name: str, optional - Name of the task.
|
|
681
657
|
:return: dict or str - Confirmation of deletion or error message.
|
|
@@ -689,7 +665,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
689
665
|
endpoint = DELETE_TASK_V2.format(taskId=identifier)
|
|
690
666
|
headers = {
|
|
691
667
|
"Authorization": self.api_service.token,
|
|
692
|
-
"ProjectId": project_id
|
|
668
|
+
"ProjectId": self.project_id
|
|
693
669
|
}
|
|
694
670
|
|
|
695
671
|
if task_id:
|
|
@@ -700,14 +676,13 @@ class AgenticProcessClient(BaseClient):
|
|
|
700
676
|
response = self.api_service.delete(endpoint=endpoint, headers=headers)
|
|
701
677
|
|
|
702
678
|
if response.status_code != 204:
|
|
703
|
-
logger.error(f"Unable to delete task {task_id or task_name} from project {project_id}: JSON parsing error (status {response.status_code}). Response: {response.text}")
|
|
704
|
-
raise InvalidAPIResponseException(f"Unable to delete task {task_id or task_name} from project {project_id}: {response.text}")
|
|
679
|
+
logger.error(f"Unable to delete task {task_id or task_name} from project {self.project_id}: JSON parsing error (status {response.status_code}). Response: {response.text}")
|
|
680
|
+
raise InvalidAPIResponseException(f"Unable to delete task {task_id or task_name} from project {self.project_id}: {response.text}")
|
|
705
681
|
else:
|
|
706
682
|
return {}
|
|
707
683
|
|
|
708
684
|
def publish_task_revision(
|
|
709
685
|
self,
|
|
710
|
-
project_id: str,
|
|
711
686
|
task_id: str,
|
|
712
687
|
task_name: str = None,
|
|
713
688
|
revision: str = None
|
|
@@ -715,7 +690,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
715
690
|
"""
|
|
716
691
|
Publishes a specific revision of a task.
|
|
717
692
|
|
|
718
|
-
:param project_id: str - Unique identifier of the project.
|
|
719
693
|
:param task_id: str, optional - Unique identifier of the task.
|
|
720
694
|
:param task_name: str, optional - Name of the task.
|
|
721
695
|
:param revision: str, optional - Revision of the task to publish.
|
|
@@ -732,7 +706,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
732
706
|
endpoint = PUBLISH_TASK_REVISION_V2.format(taskId=identifier)
|
|
733
707
|
headers = {
|
|
734
708
|
"Authorization": self.api_service.token,
|
|
735
|
-
"ProjectId": project_id,
|
|
709
|
+
"ProjectId": self.project_id,
|
|
736
710
|
"Content-Type": "application/json",
|
|
737
711
|
"Accept": "application/json"
|
|
738
712
|
}
|
|
@@ -749,12 +723,11 @@ class AgenticProcessClient(BaseClient):
|
|
|
749
723
|
try:
|
|
750
724
|
return response.json()
|
|
751
725
|
except JSONDecodeError as e:
|
|
752
|
-
logger.error(f"Unable to publish revision {revision} for task {task_id or task_name} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
753
|
-
raise InvalidAPIResponseException(f"Unable to publish revision {revision} for task {task_id or task_name} in project {project_id}: {response.text}")
|
|
726
|
+
logger.error(f"Unable to publish revision {revision} for task {task_id or task_name} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
727
|
+
raise InvalidAPIResponseException(f"Unable to publish revision {revision} for task {task_id or task_name} in project {self.project_id}: {response.text}")
|
|
754
728
|
|
|
755
729
|
def start_instance(
|
|
756
730
|
self,
|
|
757
|
-
project_id: str,
|
|
758
731
|
process_name: str,
|
|
759
732
|
subject: str = None,
|
|
760
733
|
variables: list = None
|
|
@@ -762,7 +735,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
762
735
|
"""
|
|
763
736
|
Starts a new process instance.
|
|
764
737
|
|
|
765
|
-
:param project_id: str - Unique identifier of the project.
|
|
766
738
|
:param process_name: str - Name of the process to start.
|
|
767
739
|
:param subject: str, optional - Subject of the process instance.
|
|
768
740
|
:param variables: list, optional - List of variables (e.g., [{"key": "location", "value": "Paris"}]).
|
|
@@ -772,7 +744,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
772
744
|
endpoint = START_INSTANCE_V2
|
|
773
745
|
headers = {
|
|
774
746
|
"Authorization": self.api_service.token,
|
|
775
|
-
"ProjectId": project_id,
|
|
747
|
+
"ProjectId": self.project_id,
|
|
776
748
|
"Content-Type": "application/json",
|
|
777
749
|
"Accept": "application/json"
|
|
778
750
|
}
|
|
@@ -792,18 +764,16 @@ class AgenticProcessClient(BaseClient):
|
|
|
792
764
|
try:
|
|
793
765
|
return response.json()
|
|
794
766
|
except JSONDecodeError as e:
|
|
795
|
-
logger.error(f"Unable to start instance for process {process_name} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
796
|
-
raise InvalidAPIResponseException(f"Unable to start instance for process {process_name} in project {project_id}: {response.text}")
|
|
767
|
+
logger.error(f"Unable to start instance for process {process_name} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
768
|
+
raise InvalidAPIResponseException(f"Unable to start instance for process {process_name} in project {self.project_id}: {response.text}")
|
|
797
769
|
|
|
798
770
|
def abort_instance(
|
|
799
771
|
self,
|
|
800
|
-
project_id: str,
|
|
801
772
|
instance_id: str
|
|
802
773
|
) -> dict:
|
|
803
774
|
"""
|
|
804
775
|
Aborts a specific process instance.
|
|
805
776
|
|
|
806
|
-
:param project_id: str - Unique identifier of the project.
|
|
807
777
|
:param instance_id: str - Unique identifier of the instance to abort.
|
|
808
778
|
:return: dict or str - Confirmation of abort operation or error message.
|
|
809
779
|
:raises ValueError: If instance_id is not provided.
|
|
@@ -815,7 +785,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
815
785
|
endpoint = ABORT_INSTANCE_V2.format(instanceId=instance_id)
|
|
816
786
|
headers = {
|
|
817
787
|
"Authorization": self.api_service.token,
|
|
818
|
-
"ProjectId": project_id,
|
|
788
|
+
"ProjectId": self.project_id,
|
|
819
789
|
"Content-Type": "application/json",
|
|
820
790
|
"Accept": "application/json"
|
|
821
791
|
}
|
|
@@ -826,18 +796,16 @@ class AgenticProcessClient(BaseClient):
|
|
|
826
796
|
try:
|
|
827
797
|
return response.json()
|
|
828
798
|
except JSONDecodeError as e:
|
|
829
|
-
logger.error(f"Unable to abort instance {instance_id} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
830
|
-
raise InvalidAPIResponseException(f"Unable to abort instance {instance_id} in project {project_id}: {response.text}")
|
|
799
|
+
logger.error(f"Unable to abort instance {instance_id} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
800
|
+
raise InvalidAPIResponseException(f"Unable to abort instance {instance_id} in project {self.project_id}: {response.text}")
|
|
831
801
|
|
|
832
802
|
def get_instance(
|
|
833
803
|
self,
|
|
834
|
-
project_id: str,
|
|
835
804
|
instance_id: str
|
|
836
805
|
) -> dict:
|
|
837
806
|
"""
|
|
838
807
|
Retrieves details of a specific process instance.
|
|
839
808
|
|
|
840
|
-
:param project_id: str - Unique identifier of the project.
|
|
841
809
|
:param instance_id: str - Unique identifier of the instance.
|
|
842
810
|
:return: dict or str - Instance details or error message.
|
|
843
811
|
:raises ValueError: If instance_id is not provided.
|
|
@@ -849,7 +817,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
849
817
|
endpoint = GET_INSTANCE_V2.format(instanceId=instance_id)
|
|
850
818
|
headers = {
|
|
851
819
|
"Authorization": self.api_service.token,
|
|
852
|
-
"ProjectId": project_id
|
|
820
|
+
"ProjectId": self.project_id
|
|
853
821
|
}
|
|
854
822
|
|
|
855
823
|
logger.info(f"Retrieving instance detail with ID '{instance_id}'")
|
|
@@ -858,18 +826,16 @@ class AgenticProcessClient(BaseClient):
|
|
|
858
826
|
try:
|
|
859
827
|
return response.json()
|
|
860
828
|
except JSONDecodeError as e:
|
|
861
|
-
logger.error(f"Unable to retrieve instance {instance_id} for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
862
|
-
raise InvalidAPIResponseException(f"Unable to retrieve instance {instance_id} for project {project_id}: {response.text}")
|
|
829
|
+
logger.error(f"Unable to retrieve instance {instance_id} for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
830
|
+
raise InvalidAPIResponseException(f"Unable to retrieve instance {instance_id} for project {self.project_id}: {response.text}")
|
|
863
831
|
|
|
864
832
|
def get_instance_history(
|
|
865
833
|
self,
|
|
866
|
-
project_id: str,
|
|
867
834
|
instance_id: str
|
|
868
835
|
) -> dict:
|
|
869
836
|
"""
|
|
870
837
|
Retrieves the history of a specific process instance.
|
|
871
838
|
|
|
872
|
-
:param project_id: str - Unique identifier of the project.
|
|
873
839
|
:param instance_id: str - Unique identifier of the instance.
|
|
874
840
|
:return: dict or str - Instance history or error message.
|
|
875
841
|
:raises ValueError: If instance_id is not provided.
|
|
@@ -881,7 +847,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
881
847
|
endpoint = GET_INSTANCE_HISTORY_V2.format(instanceId=instance_id)
|
|
882
848
|
headers = {
|
|
883
849
|
"Authorization": self.api_service.token,
|
|
884
|
-
"ProjectId": project_id
|
|
850
|
+
"ProjectId": self.project_id
|
|
885
851
|
}
|
|
886
852
|
|
|
887
853
|
logger.info(f"Retrieving instance history with ID '{instance_id}'")
|
|
@@ -890,18 +856,16 @@ class AgenticProcessClient(BaseClient):
|
|
|
890
856
|
try:
|
|
891
857
|
return response.json()
|
|
892
858
|
except JSONDecodeError as e:
|
|
893
|
-
logger.error(f"Unable to retrieve history for instance {instance_id} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
894
|
-
raise InvalidAPIResponseException(f"Unable to retrieve history for instance {instance_id} in project {project_id}: {response.text}")
|
|
859
|
+
logger.error(f"Unable to retrieve history for instance {instance_id} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
860
|
+
raise InvalidAPIResponseException(f"Unable to retrieve history for instance {instance_id} in project {self.project_id}: {response.text}")
|
|
895
861
|
|
|
896
862
|
def get_thread_information(
|
|
897
863
|
self,
|
|
898
|
-
project_id: str,
|
|
899
864
|
thread_id: str
|
|
900
865
|
) -> dict:
|
|
901
866
|
"""
|
|
902
867
|
Retrieves information about a specific thread.
|
|
903
868
|
|
|
904
|
-
:param project_id: str - Unique identifier of the project.
|
|
905
869
|
:param thread_id: str - Unique identifier of the thread.
|
|
906
870
|
:return: dict or str - Thread information or error message.
|
|
907
871
|
:raises ValueError: If thread_id is not provided.
|
|
@@ -913,7 +877,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
913
877
|
endpoint = GET_THREAD_INFORMATION_V2.format(threadId=thread_id)
|
|
914
878
|
headers = {
|
|
915
879
|
"Authorization": self.api_service.token,
|
|
916
|
-
"ProjectId": project_id
|
|
880
|
+
"ProjectId": self.project_id
|
|
917
881
|
}
|
|
918
882
|
|
|
919
883
|
logger.debug(f"Retrieving information about thread with ID {thread_id}")
|
|
@@ -922,19 +886,17 @@ class AgenticProcessClient(BaseClient):
|
|
|
922
886
|
try:
|
|
923
887
|
return response.json()
|
|
924
888
|
except JSONDecodeError as e:
|
|
925
|
-
logger.error(f"Unable to retrieve thread information for thread {thread_id} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
926
|
-
raise InvalidAPIResponseException(f"Unable to retrieve thread information for thread {thread_id} in project {project_id}: {response.text}")
|
|
889
|
+
logger.error(f"Unable to retrieve thread information for thread {thread_id} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
890
|
+
raise InvalidAPIResponseException(f"Unable to retrieve thread information for thread {thread_id} in project {self.project_id}: {response.text}")
|
|
927
891
|
|
|
928
892
|
def send_user_signal(
|
|
929
893
|
self,
|
|
930
|
-
project_id: str,
|
|
931
894
|
instance_id: str,
|
|
932
895
|
signal_name: str
|
|
933
896
|
) -> dict:
|
|
934
897
|
"""
|
|
935
898
|
Sends a user signal to a specific process instance.
|
|
936
899
|
|
|
937
|
-
:param project_id: str - Unique identifier of the project.
|
|
938
900
|
:param instance_id: str - Unique identifier of the instance.
|
|
939
901
|
:param signal_name: str - Name of the user signal (e.g., 'approval').
|
|
940
902
|
:return: dict or str - Confirmation of signal operation or error message.
|
|
@@ -949,7 +911,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
949
911
|
endpoint = SEND_USER_SIGNAL_V2.format(instanceId=instance_id)
|
|
950
912
|
headers = {
|
|
951
913
|
"Authorization": self.api_service.token,
|
|
952
|
-
"ProjectId": project_id,
|
|
914
|
+
"ProjectId": self.project_id,
|
|
953
915
|
"Content-Type": "application/json",
|
|
954
916
|
"Accept": "application/json"
|
|
955
917
|
}
|
|
@@ -963,12 +925,11 @@ class AgenticProcessClient(BaseClient):
|
|
|
963
925
|
try:
|
|
964
926
|
return response.json()
|
|
965
927
|
except JSONDecodeError as e:
|
|
966
|
-
logger.error(f"Unable to send user signal {signal_name} to instance {instance_id} in project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
967
|
-
raise InvalidAPIResponseException(f"Unable to send user signal {signal_name} to instance {instance_id} in project {project_id}: {response.text}")
|
|
928
|
+
logger.error(f"Unable to send user signal {signal_name} to instance {instance_id} in project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
929
|
+
raise InvalidAPIResponseException(f"Unable to send user signal {signal_name} to instance {instance_id} in project {self.project_id}: {response.text}")
|
|
968
930
|
|
|
969
931
|
def create_kb(
|
|
970
932
|
self,
|
|
971
|
-
project_id: str,
|
|
972
933
|
name: str,
|
|
973
934
|
artifacts: List[str] = None,
|
|
974
935
|
metadata: List[str] = None
|
|
@@ -976,7 +937,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
976
937
|
"""
|
|
977
938
|
Creates a new knowledge base (KB) in the specified project.
|
|
978
939
|
|
|
979
|
-
:param project_id: str - Unique identifier of the project.
|
|
980
940
|
:param name: str - Name of the knowledge base.
|
|
981
941
|
:param artifacts: List[str], optional - List of artifact names associated with the KB.
|
|
982
942
|
:param metadata: List[str], optional - List of metadata fields for the KB.
|
|
@@ -986,7 +946,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
986
946
|
endpoint = CREATE_KB_V1
|
|
987
947
|
headers = {
|
|
988
948
|
"Authorization": self.api_service.token,
|
|
989
|
-
"ProjectId": project_id,
|
|
949
|
+
"ProjectId": self.project_id,
|
|
990
950
|
"Content-Type": "application/json",
|
|
991
951
|
"Accept": "application/json"
|
|
992
952
|
}
|
|
@@ -1010,19 +970,17 @@ class AgenticProcessClient(BaseClient):
|
|
|
1010
970
|
try:
|
|
1011
971
|
return response.json()
|
|
1012
972
|
except JSONDecodeError as e:
|
|
1013
|
-
logger.error(f"Unable to create knowledge base for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
1014
|
-
raise InvalidAPIResponseException(f"Unable to create knowledge base for project {project_id}: {response.text}")
|
|
973
|
+
logger.error(f"Unable to create knowledge base for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
974
|
+
raise InvalidAPIResponseException(f"Unable to create knowledge base for project {self.project_id}: {response.text}")
|
|
1015
975
|
|
|
1016
976
|
def get_kb(
|
|
1017
977
|
self,
|
|
1018
|
-
project_id: str,
|
|
1019
978
|
kb_id: str = None,
|
|
1020
979
|
kb_name: str = None
|
|
1021
980
|
) -> dict:
|
|
1022
981
|
"""
|
|
1023
982
|
Retrieves details of a specific knowledge base (KB) by its ID or name.
|
|
1024
983
|
|
|
1025
|
-
:param project_id: str - Unique identifier of the project.
|
|
1026
984
|
:param kb_id: str, optional - Unique identifier of the KB.
|
|
1027
985
|
:param kb_name: str, optional - Name of the KB.
|
|
1028
986
|
:return: dict or str - KB details or error message.
|
|
@@ -1036,7 +994,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
1036
994
|
endpoint = GET_KB_V1.format(kbId=identifier)
|
|
1037
995
|
headers = {
|
|
1038
996
|
"Authorization": self.api_service.token,
|
|
1039
|
-
"ProjectId": project_id
|
|
997
|
+
"ProjectId": self.project_id
|
|
1040
998
|
}
|
|
1041
999
|
|
|
1042
1000
|
if kb_id:
|
|
@@ -1048,12 +1006,11 @@ class AgenticProcessClient(BaseClient):
|
|
|
1048
1006
|
try:
|
|
1049
1007
|
return response.json()
|
|
1050
1008
|
except JSONDecodeError as e:
|
|
1051
|
-
logger.error(f"Unable to retrieve knowledge base {kb_id or kb_name} for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
1052
|
-
raise InvalidAPIResponseException(f"Unable to retrieve knowledge base {kb_id or kb_name} for project {project_id}: {response.text}")
|
|
1009
|
+
logger.error(f"Unable to retrieve knowledge base {kb_id or kb_name} for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
1010
|
+
raise InvalidAPIResponseException(f"Unable to retrieve knowledge base {kb_id or kb_name} for project {self.project_id}: {response.text}")
|
|
1053
1011
|
|
|
1054
1012
|
def list_kbs(
|
|
1055
1013
|
self,
|
|
1056
|
-
project_id: str,
|
|
1057
1014
|
name: str = None,
|
|
1058
1015
|
start: str = "0",
|
|
1059
1016
|
count: str = "100"
|
|
@@ -1061,7 +1018,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
1061
1018
|
"""
|
|
1062
1019
|
Retrieves a list of knowledge bases (KBs) in the specified project.
|
|
1063
1020
|
|
|
1064
|
-
:param project_id: str - Unique identifier of the project.
|
|
1065
1021
|
:param name: str, optional - Name of the KB to filter by.
|
|
1066
1022
|
:param start: str, optional - Starting index for pagination (default: '0').
|
|
1067
1023
|
:param count: str, optional - Number of KBs to retrieve (default: '100').
|
|
@@ -1071,7 +1027,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
1071
1027
|
endpoint = LIST_KBS_V1
|
|
1072
1028
|
headers = {
|
|
1073
1029
|
"Authorization": self.api_service.token,
|
|
1074
|
-
"ProjectId": project_id
|
|
1030
|
+
"ProjectId": self.project_id
|
|
1075
1031
|
}
|
|
1076
1032
|
params = {
|
|
1077
1033
|
"start": start,
|
|
@@ -1080,25 +1036,23 @@ class AgenticProcessClient(BaseClient):
|
|
|
1080
1036
|
if name:
|
|
1081
1037
|
params["name"] = name
|
|
1082
1038
|
|
|
1083
|
-
logger.debug(f"Listing tasks in project with ID {project_id}")
|
|
1039
|
+
logger.debug(f"Listing tasks in project with ID {self.project_id}")
|
|
1084
1040
|
|
|
1085
1041
|
response = self.api_service.get(endpoint=endpoint, headers=headers, params=params)
|
|
1086
1042
|
try:
|
|
1087
1043
|
return response.json()
|
|
1088
1044
|
except JSONDecodeError as e:
|
|
1089
|
-
logger.error(f"Unable to list knowledge bases for project {project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
1090
|
-
raise InvalidAPIResponseException(f"Unable to list knowledge bases for project {project_id}: {response.text}")
|
|
1045
|
+
logger.error(f"Unable to list knowledge bases for project {self.project_id}: JSON parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
1046
|
+
raise InvalidAPIResponseException(f"Unable to list knowledge bases for project {self.project_id}: {response.text}")
|
|
1091
1047
|
|
|
1092
1048
|
def delete_kb(
|
|
1093
1049
|
self,
|
|
1094
|
-
project_id: str,
|
|
1095
1050
|
kb_id: str = None,
|
|
1096
1051
|
kb_name: str = None
|
|
1097
1052
|
) -> dict:
|
|
1098
1053
|
"""
|
|
1099
1054
|
Deletes a specific knowledge base (KB) by its ID or name.
|
|
1100
1055
|
|
|
1101
|
-
:param project_id: str - Unique identifier of the project.
|
|
1102
1056
|
:param kb_id: str, optional - Unique identifier of the KB.
|
|
1103
1057
|
:param kb_name: str, optional - Name of the KB.
|
|
1104
1058
|
:return: dict or str - Confirmation of deletion or error message.
|
|
@@ -1112,7 +1066,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
1112
1066
|
endpoint = DELETE_KB_V1.format(kbId=identifier)
|
|
1113
1067
|
headers = {
|
|
1114
1068
|
"Authorization": self.api_service.token,
|
|
1115
|
-
"ProjectId": project_id
|
|
1069
|
+
"ProjectId": self.project_id
|
|
1116
1070
|
}
|
|
1117
1071
|
|
|
1118
1072
|
if kb_id:
|
|
@@ -1123,14 +1077,13 @@ class AgenticProcessClient(BaseClient):
|
|
|
1123
1077
|
response = self.api_service.delete(endpoint=endpoint, headers=headers)
|
|
1124
1078
|
|
|
1125
1079
|
if response.status_code != 204:
|
|
1126
|
-
logger.error(f"Unable to delete knowledge base {kb_id or kb_name} from project {project_id}: JSONDecodeError parsing error (status {response.status_code}). Response: {response.text}")
|
|
1127
|
-
raise InvalidAPIResponseException(f"Unable to delete knowledge base {kb_id or kb_name} from project {project_id}: {response.text}")
|
|
1080
|
+
logger.error(f"Unable to delete knowledge base {kb_id or kb_name} from project {self.project_id}: JSONDecodeError parsing error (status {response.status_code}). Response: {response.text}")
|
|
1081
|
+
raise InvalidAPIResponseException(f"Unable to delete knowledge base {kb_id or kb_name} from project {self.project_id}: {response.text}")
|
|
1128
1082
|
else:
|
|
1129
1083
|
return {}
|
|
1130
1084
|
|
|
1131
1085
|
def list_jobs(
|
|
1132
1086
|
self,
|
|
1133
|
-
project_id: str,
|
|
1134
1087
|
start: str = "0",
|
|
1135
1088
|
count: str = "100",
|
|
1136
1089
|
topic: str = None,
|
|
@@ -1140,7 +1093,6 @@ class AgenticProcessClient(BaseClient):
|
|
|
1140
1093
|
"""
|
|
1141
1094
|
Retrieves a specific list of jobs in the specified project.
|
|
1142
1095
|
|
|
1143
|
-
:param project_id: str - Unique identifier of the project.
|
|
1144
1096
|
:param start: str, optional - Starting index for pagination (default: '0').
|
|
1145
1097
|
:param count: str, optional - Number of jobs to retrieve (default: '100').
|
|
1146
1098
|
:param topic: str - optional - Topiccollege of the jobs to filter by.
|
|
@@ -1152,7 +1104,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
1152
1104
|
endpoint = LIST_JOBS_V1
|
|
1153
1105
|
headers = {
|
|
1154
1106
|
"Authorization": self.api_service.token,
|
|
1155
|
-
"ProjectId": project_id
|
|
1107
|
+
"ProjectId": self.project_id
|
|
1156
1108
|
}
|
|
1157
1109
|
params = {
|
|
1158
1110
|
"start": start,
|
|
@@ -1165,7 +1117,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
1165
1117
|
if name:
|
|
1166
1118
|
params["name"] = name
|
|
1167
1119
|
|
|
1168
|
-
logger.debug(f"Listing jobs for project with ID {project_id}")
|
|
1120
|
+
logger.debug(f"Listing jobs for project with ID {self.project_id}")
|
|
1169
1121
|
|
|
1170
1122
|
response = self.api_service.get(
|
|
1171
1123
|
endpoint=endpoint,
|
|
@@ -1175,7 +1127,7 @@ class AgenticProcessClient(BaseClient):
|
|
|
1175
1127
|
try:
|
|
1176
1128
|
result = response.json()
|
|
1177
1129
|
except JSONDecodeError as e:
|
|
1178
|
-
logger.error(f"Unable to list jobs for project {project_id}: JSONDecodeError parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
1179
|
-
raise InvalidAPIResponseException(f"Unable to list jobs for project {project_id}: {response.text}")
|
|
1130
|
+
logger.error(f"Unable to list jobs for project {self.project_id}: JSONDecodeError parsing error (status {response.status_code}): {e}. Response: {response.text}")
|
|
1131
|
+
raise InvalidAPIResponseException(f"Unable to list jobs for project {self.project_id}: {response.text}")
|
|
1180
1132
|
|
|
1181
1133
|
return result
|