pygeai 0.4.0b12__py3-none-any.whl → 0.6.0b3__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/__init__.py +1 -1
- pygeai/auth/__init__.py +0 -0
- pygeai/auth/clients.py +55 -0
- pygeai/auth/endpoints.py +2 -0
- pygeai/cli/__init__.py +0 -1
- pygeai/cli/commands/auth.py +123 -0
- pygeai/cli/commands/base.py +22 -1
- pygeai/cli/commands/docs.py +105 -0
- pygeai/cli/texts/help.py +157 -24
- pygeai/core/base/session.py +1 -1
- pygeai/core/files/responses.py +4 -3
- pygeai/lab/clients.py +3 -3
- pygeai/lab/tools/clients.py +4 -4
- pygeai/tests/admin/test_clients.py +143 -0
- pygeai/tests/auth/__init__.py +0 -0
- pygeai/tests/auth/test_clients.py +105 -0
- pygeai/tests/cli/commands/lab/test_ai_lab.py +41 -35
- pygeai/tests/cli/commands/lab/test_spec.py +24 -56
- pygeai/tests/cli/commands/test_chat.py +21 -3
- pygeai/tests/cli/commands/test_evaluation.py +649 -0
- pygeai/tests/cli/commands/test_secrets.py +171 -0
- pygeai/tests/cli/docker/__init__.py +0 -0
- pygeai/tests/core/base/data/models.py +7 -0
- pygeai/tests/core/base/test_mappers.py +43 -11
- pygeai/tests/core/base/test_models.py +3 -1
- pygeai/tests/core/base/test_responses.py +53 -0
- pygeai/tests/core/common/test_config.py +2 -3
- pygeai/tests/core/files/test_mappers.py +137 -0
- pygeai/tests/core/plugins/__init__.py +0 -0
- pygeai/tests/core/plugins/test_clients.py +64 -0
- pygeai/tests/evaluation/__init__.py +0 -0
- pygeai/tests/evaluation/dataset/__init__.py +0 -0
- pygeai/tests/evaluation/dataset/test_clients.py +263 -0
- pygeai/tests/evaluation/plan/__init__.py +0 -0
- pygeai/tests/evaluation/plan/test_clients.py +193 -0
- pygeai/tests/evaluation/result/__init__.py +0 -0
- pygeai/tests/evaluation/result/test_clients.py +64 -0
- pygeai/tests/integration/assistants/rag/test_create_rag.py +24 -5
- pygeai/tests/integration/chat/test_generate_image.py +2 -6
- pygeai/tests/integration/lab/agents/test_agents_list.py +1 -1
- pygeai/tests/integration/lab/agents/test_create_agent.py +16 -10
- pygeai/tests/integration/lab/agents/test_create_sharing_link.py +5 -2
- pygeai/tests/integration/lab/agents/test_delete_agent.py +2 -2
- pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
- pygeai/tests/integration/lab/agents/test_publish_agent_revision.py +2 -2
- pygeai/tests/integration/lab/agents/test_update_agent.py +18 -21
- pygeai/tests/integration/lab/processes/__init__.py +0 -0
- pygeai/tests/integration/lab/processes/test_create_process.py +345 -0
- pygeai/tests/integration/lab/processes/test_create_task.py +211 -0
- pygeai/tests/integration/lab/processes/test_delete_process.py +111 -0
- pygeai/tests/integration/lab/processes/test_get_process.py +201 -0
- pygeai/tests/integration/lab/processes/test_list_process_instances.py +91 -0
- pygeai/tests/integration/lab/processes/test_list_processes.py +138 -0
- pygeai/tests/integration/lab/processes/test_publish_process_revision.py +232 -0
- pygeai/tests/integration/lab/processes/test_update_process.py +289 -0
- pygeai/tests/integration/lab/reasoning_strategies/__init__.py +0 -0
- pygeai/tests/integration/lab/reasoning_strategies/test_get_reasoning_strategy.py +70 -0
- pygeai/tests/integration/lab/reasoning_strategies/test_list_reasoning_strategies.py +93 -0
- pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +149 -0
- pygeai/tests/integration/lab/tools/test_create_tool.py +13 -17
- pygeai/tests/integration/lab/tools/test_delete_tool.py +4 -4
- pygeai/tests/integration/lab/tools/test_get_parameter.py +1 -1
- pygeai/tests/integration/lab/tools/test_get_tool.py +4 -4
- pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
- pygeai/tests/integration/lab/tools/test_publish_tool_revision.py +1 -1
- pygeai/tests/integration/lab/tools/test_set_parameter.py +1 -1
- pygeai/tests/integration/lab/tools/test_update_tool.py +9 -10
- pygeai/tests/lab/agents/test_clients.py +17 -34
- pygeai/tests/lab/processes/test_clients.py +30 -93
- pygeai/tests/lab/processes/test_mappers.py +12 -71
- pygeai/tests/lab/strategies/test_clients.py +63 -63
- pygeai/tests/lab/test_managers.py +3 -6
- pygeai/tests/lab/test_models.py +9 -8
- pygeai/tests/lab/tools/test_clients.py +22 -45
- pygeai/tests/migration/test_strategies.py +16 -16
- pygeai/tests/organization/test_mappers.py +11 -4
- pygeai/tests/organization/test_responses.py +137 -0
- pygeai/tests/snippets/lab/agentic_flow_example_4.py +23 -23
- pygeai/tests/snippets/lab/samples/summarize_files.py +3 -3
- pygeai/tests/snippets/lab/use_cases/file_summarizer_example.py +3 -3
- pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +11 -11
- pygeai/tests/snippets/lab/use_cases/update_web_reader.py +1 -2
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/METADATA +44 -16
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/RECORD +88 -53
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/WHEEL +0 -0
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/entry_points.txt +0 -0
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/top_level.txt +0 -0
|
@@ -184,8 +184,8 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
184
184
|
)
|
|
185
185
|
strategy.migrate()
|
|
186
186
|
|
|
187
|
-
mock_source.get_agent.assert_called_with(
|
|
188
|
-
mock_destination.create_agent.assert_called_with(
|
|
187
|
+
mock_source.get_agent.assert_called_with(agent_id=self.agent_id)
|
|
188
|
+
mock_destination.create_agent.assert_called_with(agent=mock_agent)
|
|
189
189
|
mock_stdout.assert_called_once()
|
|
190
190
|
self.assertIn("New agent detail:", mock_stdout.call_args[0][0])
|
|
191
191
|
mock_stderr.assert_not_called()
|
|
@@ -211,7 +211,7 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
211
211
|
)
|
|
212
212
|
strategy.migrate()
|
|
213
213
|
|
|
214
|
-
mock_source.get_agent.assert_called_with(
|
|
214
|
+
mock_source.get_agent.assert_called_with(agent_id=self.agent_id)
|
|
215
215
|
mock_destination.create_agent.assert_not_called()
|
|
216
216
|
mock_stderr.assert_called_once()
|
|
217
217
|
self.assertIn("Agent migration failed:", mock_stderr.call_args[0][0])
|
|
@@ -240,7 +240,7 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
240
240
|
)
|
|
241
241
|
strategy.migrate()
|
|
242
242
|
|
|
243
|
-
mock_source.get_agent.assert_called_with(
|
|
243
|
+
mock_source.get_agent.assert_called_with(agent_id=self.agent_id)
|
|
244
244
|
mock_destination.create_agent.assert_not_called()
|
|
245
245
|
mock_stderr.assert_called_once()
|
|
246
246
|
mock_stdout.assert_called_once()
|
|
@@ -290,8 +290,8 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
290
290
|
)
|
|
291
291
|
strategy.migrate()
|
|
292
292
|
|
|
293
|
-
mock_source.get_tool.assert_called_with(
|
|
294
|
-
mock_destination.create_tool.assert_called_with(
|
|
293
|
+
mock_source.get_tool.assert_called_with(tool_id=self.tool_id)
|
|
294
|
+
mock_destination.create_tool.assert_called_with(tool=mock_tool)
|
|
295
295
|
mock_stdout.assert_called_once()
|
|
296
296
|
self.assertIn("New tool detail:", mock_stdout.call_args[0][0])
|
|
297
297
|
mock_stderr.assert_not_called()
|
|
@@ -317,7 +317,7 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
317
317
|
)
|
|
318
318
|
strategy.migrate()
|
|
319
319
|
|
|
320
|
-
mock_source.get_tool.assert_called_with(
|
|
320
|
+
mock_source.get_tool.assert_called_with(tool_id=self.tool_id)
|
|
321
321
|
mock_destination.create_tool.assert_not_called()
|
|
322
322
|
mock_stderr.assert_called_once()
|
|
323
323
|
self.assertIn("Tool migration failed:", mock_stderr.call_args[0][0])
|
|
@@ -346,7 +346,7 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
346
346
|
)
|
|
347
347
|
strategy.migrate()
|
|
348
348
|
|
|
349
|
-
mock_source.get_tool.assert_called_with(
|
|
349
|
+
mock_source.get_tool.assert_called_with(tool_id=self.tool_id)
|
|
350
350
|
mock_destination.create_tool.assert_not_called()
|
|
351
351
|
mock_stderr.assert_called_once()
|
|
352
352
|
mock_stdout.assert_called_once()
|
|
@@ -396,8 +396,8 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
396
396
|
)
|
|
397
397
|
strategy.migrate()
|
|
398
398
|
|
|
399
|
-
mock_source.get_process.assert_called_with(
|
|
400
|
-
mock_destination.create_process.assert_called_with(
|
|
399
|
+
mock_source.get_process.assert_called_with(process_id=self.process_id)
|
|
400
|
+
mock_destination.create_process.assert_called_with(process=mock_process)
|
|
401
401
|
mock_stdout.assert_called_once()
|
|
402
402
|
self.assertIn("New process detail:", mock_stdout.call_args[0][0])
|
|
403
403
|
mock_stderr.assert_not_called()
|
|
@@ -423,7 +423,7 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
423
423
|
)
|
|
424
424
|
strategy.migrate()
|
|
425
425
|
|
|
426
|
-
mock_source.get_process.assert_called_with(
|
|
426
|
+
mock_source.get_process.assert_called_with(process_id=self.process_id)
|
|
427
427
|
mock_destination.create_process.assert_not_called()
|
|
428
428
|
mock_stderr.assert_called_once()
|
|
429
429
|
self.assertIn("Process migration failed:", mock_stderr.call_args[0][0])
|
|
@@ -452,7 +452,7 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
452
452
|
)
|
|
453
453
|
strategy.migrate()
|
|
454
454
|
|
|
455
|
-
mock_source.get_process.assert_called_with(
|
|
455
|
+
mock_source.get_process.assert_called_with(process_id=self.process_id)
|
|
456
456
|
mock_destination.create_process.assert_not_called()
|
|
457
457
|
mock_stdout.assert_called_once()
|
|
458
458
|
mock_stderr.assert_called_once()
|
|
@@ -502,8 +502,8 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
502
502
|
)
|
|
503
503
|
strategy.migrate()
|
|
504
504
|
|
|
505
|
-
mock_source.get_task.assert_called_with(
|
|
506
|
-
mock_destination.create_task.assert_called_with(
|
|
505
|
+
mock_source.get_task.assert_called_with(task_id=self.task_id)
|
|
506
|
+
mock_destination.create_task.assert_called_with(task=mock_task)
|
|
507
507
|
mock_stdout.assert_called_once()
|
|
508
508
|
self.assertIn("New task detail:", mock_stdout.call_args[0][0])
|
|
509
509
|
mock_stderr.assert_not_called()
|
|
@@ -529,7 +529,7 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
529
529
|
)
|
|
530
530
|
strategy.migrate()
|
|
531
531
|
|
|
532
|
-
mock_source.get_task.assert_called_with(
|
|
532
|
+
mock_source.get_task.assert_called_with(task_id=self.task_id)
|
|
533
533
|
mock_destination.create_task.assert_not_called()
|
|
534
534
|
mock_stderr.assert_called_once()
|
|
535
535
|
self.assertIn("Task migration failed:", mock_stderr.call_args[0][0])
|
|
@@ -558,7 +558,7 @@ class TestMigrationStrategies(unittest.TestCase):
|
|
|
558
558
|
)
|
|
559
559
|
strategy.migrate()
|
|
560
560
|
|
|
561
|
-
mock_source.get_task.assert_called_with(
|
|
561
|
+
mock_source.get_task.assert_called_with(task_id=self.task_id)
|
|
562
562
|
mock_destination.create_task.assert_not_called()
|
|
563
563
|
mock_stderr.assert_called_once()
|
|
564
564
|
mock_stdout.assert_called_once()
|
|
@@ -129,11 +129,18 @@ class TestOrganizationResponseMapper(unittest.TestCase):
|
|
|
129
129
|
self.assertEqual(result.tokens[0].name, "Token1")
|
|
130
130
|
|
|
131
131
|
def test_map_to_item_list_response_with_valid_data(self):
|
|
132
|
-
data = {"items": [{"assistant": "Assistant1", "timestamp": "2023-01-01T00:00:00", "status": "
|
|
132
|
+
data = {"items": [{"assistant": "Assistant1", "timestamp": "2023-01-01T00:00:00", "status": "succeeded"}]}
|
|
133
133
|
expected_item = RequestItem(
|
|
134
|
+
api_token="token123",
|
|
134
135
|
assistant="Assistant1",
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
cost=0.5,
|
|
137
|
+
elapsed_time_ms=1000,
|
|
138
|
+
end_timestamp="2023-01-01T00:01:00",
|
|
139
|
+
module="test_module",
|
|
140
|
+
session_id="session123",
|
|
141
|
+
start_timestamp="2023-01-01T00:00:00",
|
|
142
|
+
status="succeeded",
|
|
143
|
+
timestamp="2023-01-01T00:00:00"
|
|
137
144
|
)
|
|
138
145
|
|
|
139
146
|
with patch('pygeai.core.base.mappers.ModelMapper.map_to_item_list', return_value=[expected_item]):
|
|
@@ -142,5 +149,5 @@ class TestOrganizationResponseMapper(unittest.TestCase):
|
|
|
142
149
|
self.assertIsInstance(result, ProjectItemListResponse)
|
|
143
150
|
self.assertEqual(len(result.items), 1)
|
|
144
151
|
self.assertEqual(result.items[0].assistant, "Assistant1")
|
|
145
|
-
self.assertEqual(result.items[0].status, "
|
|
152
|
+
self.assertEqual(result.items[0].status, "succeeded")
|
|
146
153
|
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from unittest.mock import MagicMock
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from pygeai.organization.responses import (
|
|
6
|
+
AssistantListResponse,
|
|
7
|
+
ProjectListResponse,
|
|
8
|
+
ProjectDataResponse,
|
|
9
|
+
ProjectTokensResponse,
|
|
10
|
+
ProjectItemListResponse
|
|
11
|
+
)
|
|
12
|
+
from pygeai.core.models import Assistant, Project, ProjectToken, RequestItem
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TestOrganizationResponses(unittest.TestCase):
|
|
16
|
+
"""
|
|
17
|
+
python -m unittest pygeai.tests.organization.test_responses.TestOrganizationResponses
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def _create_request_item(self, index=1):
|
|
21
|
+
"""Helper method to create a valid RequestItem for testing"""
|
|
22
|
+
return RequestItem(
|
|
23
|
+
apiToken=f"token-{index}",
|
|
24
|
+
assistant=f"assistant-{index}",
|
|
25
|
+
cost=0.01 * index,
|
|
26
|
+
elapsedTimeMs=100 * index,
|
|
27
|
+
endTimestamp=datetime.now(),
|
|
28
|
+
module=f"module-{index}",
|
|
29
|
+
sessionId=f"session-{index}",
|
|
30
|
+
startTimestamp=datetime.now(),
|
|
31
|
+
status="succeeded",
|
|
32
|
+
timestamp=datetime.now()
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def test_assistant_list_response(self):
|
|
36
|
+
assistant1 = MagicMock(spec=Assistant)
|
|
37
|
+
assistant2 = MagicMock(spec=Assistant)
|
|
38
|
+
|
|
39
|
+
response = AssistantListResponse(assistants=[assistant1, assistant2])
|
|
40
|
+
|
|
41
|
+
self.assertEqual(len(response.assistants), 2)
|
|
42
|
+
self.assertEqual(response.assistants[0], assistant1)
|
|
43
|
+
|
|
44
|
+
def test_project_list_response(self):
|
|
45
|
+
project1 = MagicMock(spec=Project)
|
|
46
|
+
project2 = MagicMock(spec=Project)
|
|
47
|
+
|
|
48
|
+
response = ProjectListResponse(projects=[project1, project2])
|
|
49
|
+
|
|
50
|
+
self.assertEqual(len(response.projects), 2)
|
|
51
|
+
self.assertEqual(response.projects[0], project1)
|
|
52
|
+
|
|
53
|
+
def test_project_data_response(self):
|
|
54
|
+
project = MagicMock(spec=Project)
|
|
55
|
+
|
|
56
|
+
response = ProjectDataResponse(project=project)
|
|
57
|
+
|
|
58
|
+
self.assertEqual(response.project, project)
|
|
59
|
+
|
|
60
|
+
def test_project_tokens_response(self):
|
|
61
|
+
token1 = MagicMock(spec=ProjectToken)
|
|
62
|
+
token2 = MagicMock(spec=ProjectToken)
|
|
63
|
+
|
|
64
|
+
response = ProjectTokensResponse(tokens=[token1, token2])
|
|
65
|
+
|
|
66
|
+
self.assertEqual(len(response.tokens), 2)
|
|
67
|
+
self.assertEqual(response.tokens[0], token1)
|
|
68
|
+
|
|
69
|
+
def test_project_item_list_response_to_list(self):
|
|
70
|
+
item1 = self._create_request_item(1)
|
|
71
|
+
item2 = self._create_request_item(2)
|
|
72
|
+
|
|
73
|
+
response = ProjectItemListResponse(items=[item1, item2])
|
|
74
|
+
result = response.to_list()
|
|
75
|
+
|
|
76
|
+
self.assertEqual(len(result), 2)
|
|
77
|
+
self.assertIsInstance(result[0], dict)
|
|
78
|
+
self.assertIsInstance(result[1], dict)
|
|
79
|
+
|
|
80
|
+
def test_project_item_list_response_to_list_empty(self):
|
|
81
|
+
response = ProjectItemListResponse(items=[])
|
|
82
|
+
result = response.to_list()
|
|
83
|
+
|
|
84
|
+
self.assertEqual(result, [])
|
|
85
|
+
|
|
86
|
+
def test_project_item_list_response_to_list_none(self):
|
|
87
|
+
response = ProjectItemListResponse(items=[])
|
|
88
|
+
result = response.to_list()
|
|
89
|
+
|
|
90
|
+
self.assertEqual(result, [])
|
|
91
|
+
|
|
92
|
+
def test_project_item_list_response_getitem(self):
|
|
93
|
+
item1 = self._create_request_item(1)
|
|
94
|
+
item2 = self._create_request_item(2)
|
|
95
|
+
|
|
96
|
+
response = ProjectItemListResponse(items=[item1, item2])
|
|
97
|
+
|
|
98
|
+
self.assertEqual(response[0], item1)
|
|
99
|
+
self.assertEqual(response[1], item2)
|
|
100
|
+
|
|
101
|
+
def test_project_item_list_response_len(self):
|
|
102
|
+
item1 = self._create_request_item(1)
|
|
103
|
+
item2 = self._create_request_item(2)
|
|
104
|
+
|
|
105
|
+
response = ProjectItemListResponse(items=[item1, item2])
|
|
106
|
+
|
|
107
|
+
self.assertEqual(len(response), 2)
|
|
108
|
+
|
|
109
|
+
def test_project_item_list_response_len_empty(self):
|
|
110
|
+
response = ProjectItemListResponse(items=[])
|
|
111
|
+
|
|
112
|
+
self.assertEqual(len(response), 0)
|
|
113
|
+
|
|
114
|
+
def test_project_item_list_response_iter(self):
|
|
115
|
+
item1 = self._create_request_item(1)
|
|
116
|
+
item2 = self._create_request_item(2)
|
|
117
|
+
|
|
118
|
+
response = ProjectItemListResponse(items=[item1, item2])
|
|
119
|
+
|
|
120
|
+
items = list(response)
|
|
121
|
+
self.assertEqual(len(items), 2)
|
|
122
|
+
self.assertEqual(items[0], item1)
|
|
123
|
+
self.assertEqual(items[1], item2)
|
|
124
|
+
|
|
125
|
+
def test_project_item_list_response_append(self):
|
|
126
|
+
item1 = self._create_request_item(1)
|
|
127
|
+
item2 = self._create_request_item(2)
|
|
128
|
+
|
|
129
|
+
response = ProjectItemListResponse(items=[item1])
|
|
130
|
+
response.append(item2)
|
|
131
|
+
|
|
132
|
+
self.assertEqual(len(response.items), 2)
|
|
133
|
+
self.assertEqual(response.items[1], item2)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
if __name__ == '__main__':
|
|
137
|
+
unittest.main()
|
|
@@ -22,23 +22,23 @@ def rollback():
|
|
|
22
22
|
print("\n=== Initiating Rollback ===")
|
|
23
23
|
if created_entities["instance_id"]:
|
|
24
24
|
print(f"Deleting instance {created_entities['instance_id']}...")
|
|
25
|
-
result = manager.abort_instance(
|
|
25
|
+
result = manager.abort_instance(instance_id=created_entities["instance_id"])
|
|
26
26
|
print(f"Rollback: {result}")
|
|
27
27
|
if created_entities["process_id"]:
|
|
28
28
|
print(f"Deleting process {created_entities['process_id']}...")
|
|
29
|
-
result = manager.delete_process(
|
|
29
|
+
result = manager.delete_process(process_id=created_entities["process_id"])
|
|
30
30
|
print(f"Rollback: {result}")
|
|
31
31
|
if created_entities["task_id"]:
|
|
32
32
|
print(f"Deleting task {created_entities['task_id']}...")
|
|
33
|
-
result = manager.delete_task(
|
|
33
|
+
result = manager.delete_task(task_id=created_entities["task_id"])
|
|
34
34
|
print(f"Rollback: {result}")
|
|
35
35
|
if created_entities["tool_id"]:
|
|
36
36
|
print(f"Deleting tool {created_entities['tool_id']}...")
|
|
37
|
-
result = manager.delete_tool(
|
|
37
|
+
result = manager.delete_tool(tool_id=created_entities["tool_id"])
|
|
38
38
|
print(f"Rollback: {result}")
|
|
39
39
|
if created_entities["agent_id"]:
|
|
40
40
|
print(f"Deleting agent {created_entities['agent_id']}...")
|
|
41
|
-
result = manager.delete_agent(
|
|
41
|
+
result = manager.delete_agent(agent_id=created_entities["agent_id"])
|
|
42
42
|
print(f"Rollback: {result}")
|
|
43
43
|
print("Rollback complete.")
|
|
44
44
|
|
|
@@ -82,7 +82,7 @@ def main():
|
|
|
82
82
|
revision=1,
|
|
83
83
|
status="pending"
|
|
84
84
|
)
|
|
85
|
-
create_tool_result = manager.create_tool(
|
|
85
|
+
create_tool_result = manager.create_tool(tool=tool, automatic_publish=False)
|
|
86
86
|
if isinstance(create_tool_result, Tool):
|
|
87
87
|
print(f"Success: Created Tool: {create_tool_result.name}, ID: {create_tool_result.id}")
|
|
88
88
|
created_entities["tool_id"] = create_tool_result.id
|
|
@@ -107,7 +107,7 @@ def main():
|
|
|
107
107
|
value="English"
|
|
108
108
|
)
|
|
109
109
|
)
|
|
110
|
-
update_tool_result = manager.update_tool(
|
|
110
|
+
update_tool_result = manager.update_tool(tool=tool, automatic_publish=False)
|
|
111
111
|
if isinstance(update_tool_result, Tool):
|
|
112
112
|
print(f"Success: Updated Tool: {update_tool_result.description}")
|
|
113
113
|
else:
|
|
@@ -116,7 +116,7 @@ def main():
|
|
|
116
116
|
exit()
|
|
117
117
|
|
|
118
118
|
print("Publishing tool revision '1'...")
|
|
119
|
-
publish_tool_result = manager.publish_tool_revision(
|
|
119
|
+
publish_tool_result = manager.publish_tool_revision(tool_id=created_entities["tool_id"], revision="1")
|
|
120
120
|
if isinstance(publish_tool_result, Tool):
|
|
121
121
|
print(f"Success: Published Tool Revision: {publish_tool_result.name}")
|
|
122
122
|
else:
|
|
@@ -125,7 +125,7 @@ def main():
|
|
|
125
125
|
exit()
|
|
126
126
|
|
|
127
127
|
print("Retrieving latest tool version...")
|
|
128
|
-
latest_tool = manager.get_tool(
|
|
128
|
+
latest_tool = manager.get_tool(tool_id=created_entities["tool_id"])
|
|
129
129
|
if isinstance(latest_tool, Tool):
|
|
130
130
|
print(f"Success: Latest Tool: {latest_tool.name}, Description: {latest_tool.description}")
|
|
131
131
|
else:
|
|
@@ -184,7 +184,7 @@ def main():
|
|
|
184
184
|
revision=1,
|
|
185
185
|
status="pending"
|
|
186
186
|
)
|
|
187
|
-
create_agent_result = manager.create_agent(
|
|
187
|
+
create_agent_result = manager.create_agent(agent=agent, automatic_publish=False)
|
|
188
188
|
if isinstance(create_agent_result, Agent):
|
|
189
189
|
print(f"Success: Created Agent: {create_agent_result.name}, ID: {create_agent_result.id}")
|
|
190
190
|
created_entities["agent_id"] = create_agent_result.id
|
|
@@ -200,7 +200,7 @@ def main():
|
|
|
200
200
|
agent.description = "Improved agent for text summarization tasks"
|
|
201
201
|
agent.job_description = "Summarizes text and extracts key insights"
|
|
202
202
|
|
|
203
|
-
update_agent_result = manager.update_agent(
|
|
203
|
+
update_agent_result = manager.update_agent(agent=agent, automatic_publish=False)
|
|
204
204
|
if isinstance(update_agent_result, Agent):
|
|
205
205
|
print(f"Success: Updated Agent: {update_agent_result.description}")
|
|
206
206
|
else:
|
|
@@ -209,7 +209,7 @@ def main():
|
|
|
209
209
|
exit()
|
|
210
210
|
|
|
211
211
|
print("Publishing agent revision '1'...")
|
|
212
|
-
publish_agent_result = manager.publish_agent_revision(
|
|
212
|
+
publish_agent_result = manager.publish_agent_revision(agent_id=created_entities["agent_id"], revision="1")
|
|
213
213
|
if isinstance(publish_agent_result, Agent):
|
|
214
214
|
print(f"Success: Published Agent Revision: {publish_agent_result.name}")
|
|
215
215
|
else:
|
|
@@ -218,7 +218,7 @@ def main():
|
|
|
218
218
|
exit()
|
|
219
219
|
|
|
220
220
|
print("Retrieving latest agent version...")
|
|
221
|
-
latest_agent = manager.get_agent(
|
|
221
|
+
latest_agent = manager.get_agent(agent_id=created_entities["agent_id"])
|
|
222
222
|
if isinstance(latest_agent, Agent):
|
|
223
223
|
print(f"Success: Latest Agent: {latest_agent.name}, Description: {latest_agent.description}")
|
|
224
224
|
else:
|
|
@@ -259,7 +259,7 @@ def main():
|
|
|
259
259
|
revision=1,
|
|
260
260
|
status="pending"
|
|
261
261
|
)
|
|
262
|
-
create_task_result = manager.create_task(
|
|
262
|
+
create_task_result = manager.create_task(task=task, automatic_publish=False)
|
|
263
263
|
if isinstance(create_task_result, Task):
|
|
264
264
|
print(f"Success: Created Task: {create_task_result.name}, ID: {create_task_result.id}")
|
|
265
265
|
created_entities["task_id"] = create_task_result.id
|
|
@@ -275,7 +275,7 @@ def main():
|
|
|
275
275
|
task.description = "Enhanced task for text summarization and analysis"
|
|
276
276
|
task.prompt_data.instructions = "Summarize text and highlight key insights."
|
|
277
277
|
|
|
278
|
-
update_task_result = manager.update_task(
|
|
278
|
+
update_task_result = manager.update_task(task=task, automatic_publish=False)
|
|
279
279
|
if isinstance(update_task_result, Task):
|
|
280
280
|
print(f"Success: Updated Task: {update_task_result.description}")
|
|
281
281
|
else:
|
|
@@ -284,7 +284,7 @@ def main():
|
|
|
284
284
|
exit()
|
|
285
285
|
|
|
286
286
|
print("Publishing task revision '1'...")
|
|
287
|
-
publish_task_result = manager.publish_task_revision(
|
|
287
|
+
publish_task_result = manager.publish_task_revision(task_id=created_entities["task_id"], revision="1")
|
|
288
288
|
if isinstance(publish_task_result, Task):
|
|
289
289
|
print(f"Success: Published Task Revision: {publish_task_result.name}")
|
|
290
290
|
else:
|
|
@@ -293,7 +293,7 @@ def main():
|
|
|
293
293
|
exit()
|
|
294
294
|
|
|
295
295
|
print("Retrieving latest task version...")
|
|
296
|
-
latest_task = manager.get_task(
|
|
296
|
+
latest_task = manager.get_task(task_id=created_entities["task_id"])
|
|
297
297
|
if isinstance(latest_task, Task):
|
|
298
298
|
print(f"Success: Latest Task: {latest_task.name}, Description: {latest_task.description}")
|
|
299
299
|
else:
|
|
@@ -358,7 +358,7 @@ def main():
|
|
|
358
358
|
revision=1,
|
|
359
359
|
status="pending"
|
|
360
360
|
)
|
|
361
|
-
create_process_result = manager.create_process(
|
|
361
|
+
create_process_result = manager.create_process(process=process, automatic_publish=False)
|
|
362
362
|
if isinstance(create_process_result, AgenticProcess):
|
|
363
363
|
print(f"Success: Created Process: {create_process_result.name}, ID: {create_process_result.id}")
|
|
364
364
|
created_entities["process_id"] = create_process_result.id
|
|
@@ -373,7 +373,7 @@ def main():
|
|
|
373
373
|
process.description = "Optimized process for text summarization workflows"
|
|
374
374
|
process.agentic_activities[0].name = "Advanced Text Summarization"
|
|
375
375
|
|
|
376
|
-
update_process_result = manager.update_process(
|
|
376
|
+
update_process_result = manager.update_process(process=process, automatic_publish=False)
|
|
377
377
|
if isinstance(update_process_result, AgenticProcess):
|
|
378
378
|
print(f"Success: Updated Process: {update_process_result.description}")
|
|
379
379
|
else:
|
|
@@ -382,7 +382,7 @@ def main():
|
|
|
382
382
|
exit()
|
|
383
383
|
|
|
384
384
|
print("Publishing process revision '1'...")
|
|
385
|
-
publish_process_result = manager.publish_process_revision(
|
|
385
|
+
publish_process_result = manager.publish_process_revision(process_id=created_entities["process_id"], revision="1")
|
|
386
386
|
if isinstance(publish_process_result, AgenticProcess):
|
|
387
387
|
print(f"Success: Published Process Revision: {publish_process_result.name}")
|
|
388
388
|
else:
|
|
@@ -391,7 +391,7 @@ def main():
|
|
|
391
391
|
exit()
|
|
392
392
|
|
|
393
393
|
print("Retrieving latest process version...")
|
|
394
|
-
latest_process = manager.get_process(
|
|
394
|
+
latest_process = manager.get_process(process_id=created_entities["process_id"])
|
|
395
395
|
if isinstance(latest_process, AgenticProcess):
|
|
396
396
|
print(f"Success: Latest Process: {latest_process.name}, Description: {latest_process.description}")
|
|
397
397
|
else:
|
|
@@ -417,7 +417,7 @@ def main():
|
|
|
417
417
|
exit()
|
|
418
418
|
|
|
419
419
|
print("Retrieving instance information...")
|
|
420
|
-
instance_info = manager.get_instance(
|
|
420
|
+
instance_info = manager.get_instance(instance_id=created_entities["instance_id"])
|
|
421
421
|
if isinstance(instance_info, ProcessInstance):
|
|
422
422
|
print(f"Success: Instance Info: Process: {instance_info.process.name}, Subject: {instance_info.subject}")
|
|
423
423
|
else:
|
|
@@ -426,7 +426,7 @@ def main():
|
|
|
426
426
|
exit()
|
|
427
427
|
|
|
428
428
|
print("Retrieving instance history...")
|
|
429
|
-
history = manager.get_instance_history(
|
|
429
|
+
history = manager.get_instance_history(instance_id=created_entities["instance_id"])
|
|
430
430
|
if isinstance(history, dict):
|
|
431
431
|
print(f"Success: Instance History: {history}")
|
|
432
432
|
else:
|
|
@@ -31,7 +31,7 @@ def rollback():
|
|
|
31
31
|
print("\n=== Initiating Rollback ===")
|
|
32
32
|
if created_entities["agent_id"]:
|
|
33
33
|
print(f"Deleting agent {created_entities['agent_id']}...")
|
|
34
|
-
result = lab_manager.delete_agent(
|
|
34
|
+
result = lab_manager.delete_agent(agent_id=created_entities["agent_id"])
|
|
35
35
|
print(f"Rollback: {result}")
|
|
36
36
|
if created_entities["file_id"]:
|
|
37
37
|
print(f"Deleting file {created_entities['file_id']}...")
|
|
@@ -107,7 +107,7 @@ def main():
|
|
|
107
107
|
revision=1,
|
|
108
108
|
status="pending"
|
|
109
109
|
)
|
|
110
|
-
create_agent_result = lab_manager.create_agent(
|
|
110
|
+
create_agent_result = lab_manager.create_agent(agent=agent, automatic_publish=False)
|
|
111
111
|
if isinstance(create_agent_result, Agent):
|
|
112
112
|
print(f"Success: Created Agent: {create_agent_result.name}, ID: {create_agent_result.id}")
|
|
113
113
|
created_entities["agent_id"] = create_agent_result.id
|
|
@@ -117,7 +117,7 @@ def main():
|
|
|
117
117
|
exit()
|
|
118
118
|
|
|
119
119
|
print("Publishing agent revision '1'...")
|
|
120
|
-
publish_agent_result = lab_manager.publish_agent_revision(
|
|
120
|
+
publish_agent_result = lab_manager.publish_agent_revision(agent_id=created_entities["agent_id"], revision="1")
|
|
121
121
|
if isinstance(publish_agent_result, Agent):
|
|
122
122
|
print(f"Success: Published Agent Revision: {publish_agent_result.name}")
|
|
123
123
|
else:
|
|
@@ -27,7 +27,7 @@ def rollback():
|
|
|
27
27
|
print("\n=== Initiating Rollback ===")
|
|
28
28
|
if created_entities["agent_id"]:
|
|
29
29
|
print(f"Deleting agent {created_entities['agent_id']}...")
|
|
30
|
-
result = lab_manager.delete_agent(
|
|
30
|
+
result = lab_manager.delete_agent(agent_id=created_entities["agent_id"])
|
|
31
31
|
print(f"Rollback: {result}")
|
|
32
32
|
if created_entities["file_id"]:
|
|
33
33
|
print(f"Deleting file {created_entities['file_id']}...")
|
|
@@ -102,7 +102,7 @@ def main():
|
|
|
102
102
|
revision=1,
|
|
103
103
|
status="pending"
|
|
104
104
|
)
|
|
105
|
-
create_agent_result = lab_manager.create_agent(
|
|
105
|
+
create_agent_result = lab_manager.create_agent(agent=agent, automatic_publish=False)
|
|
106
106
|
if isinstance(create_agent_result, Agent):
|
|
107
107
|
print(f"Success: Created Agent: {create_agent_result.name}, ID: {create_agent_result.id}")
|
|
108
108
|
created_entities["agent_id"] = create_agent_result.id
|
|
@@ -112,7 +112,7 @@ def main():
|
|
|
112
112
|
exit()
|
|
113
113
|
|
|
114
114
|
print("Publishing agent revision '1'...")
|
|
115
|
-
publish_agent_result = lab_manager.publish_agent_revision(
|
|
115
|
+
publish_agent_result = lab_manager.publish_agent_revision(agent_id=created_entities["agent_id"], revision="1")
|
|
116
116
|
if isinstance(publish_agent_result, Agent):
|
|
117
117
|
print(f"Success: Published Agent Revision: {publish_agent_result.name}")
|
|
118
118
|
else:
|
|
@@ -27,7 +27,7 @@ def rollback():
|
|
|
27
27
|
print("\n=== Initiating Rollback ===")
|
|
28
28
|
if created_entities["agent_id"]:
|
|
29
29
|
print(f"Deleting agent {created_entities['agent_id']}...")
|
|
30
|
-
result = lab_manager.delete_agent(
|
|
30
|
+
result = lab_manager.delete_agent(agent_id=created_entities["agent_id"])
|
|
31
31
|
print(f"Rollback: {result}")
|
|
32
32
|
if created_entities["file_id"]:
|
|
33
33
|
print(f"Deleting file {created_entities['file_id']}...")
|
|
@@ -37,8 +37,8 @@ def rollback():
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def main():
|
|
40
|
-
# File Upload
|
|
41
|
-
print("\n=== File Upload
|
|
40
|
+
# File Upload Step
|
|
41
|
+
print("\n=== File Upload Step ===")
|
|
42
42
|
print("Uploading file 'test.txt'...")
|
|
43
43
|
file_to_upload = UploadFile(
|
|
44
44
|
name="test.txt",
|
|
@@ -65,8 +65,8 @@ def main():
|
|
|
65
65
|
rollback()
|
|
66
66
|
exit()
|
|
67
67
|
|
|
68
|
-
# Agent
|
|
69
|
-
print("\n=== Agent
|
|
68
|
+
# Agent Step
|
|
69
|
+
print("\n=== Agent Step ===")
|
|
70
70
|
print("Creating agent 'FileSummaryAgent2' as draft...")
|
|
71
71
|
agent_id = str(uuid4())
|
|
72
72
|
agent = Agent(
|
|
@@ -95,14 +95,14 @@ def main():
|
|
|
95
95
|
sampling=Sampling(temperature=0.8)
|
|
96
96
|
),
|
|
97
97
|
models=ModelList(models=[
|
|
98
|
-
Model(name="
|
|
98
|
+
Model(name="openai/gpt-4o")
|
|
99
99
|
])
|
|
100
100
|
),
|
|
101
101
|
is_draft=True,
|
|
102
102
|
revision=1,
|
|
103
103
|
status="pending"
|
|
104
104
|
)
|
|
105
|
-
create_agent_result = lab_manager.create_agent(
|
|
105
|
+
create_agent_result = lab_manager.create_agent(agent=agent, automatic_publish=False)
|
|
106
106
|
if isinstance(create_agent_result, Agent):
|
|
107
107
|
print(f"Success: Created Agent: {create_agent_result.name}, ID: {create_agent_result.id}")
|
|
108
108
|
created_entities["agent_id"] = create_agent_result.id
|
|
@@ -112,7 +112,7 @@ def main():
|
|
|
112
112
|
exit()
|
|
113
113
|
|
|
114
114
|
print("Publishing agent revision '1'...")
|
|
115
|
-
publish_agent_result = lab_manager.publish_agent_revision(
|
|
115
|
+
publish_agent_result = lab_manager.publish_agent_revision(agent_id=created_entities["agent_id"], revision="1")
|
|
116
116
|
if isinstance(publish_agent_result, Agent):
|
|
117
117
|
print(f"Success: Published Agent Revision: {publish_agent_result.name}")
|
|
118
118
|
else:
|
|
@@ -120,8 +120,8 @@ def main():
|
|
|
120
120
|
rollback()
|
|
121
121
|
exit()
|
|
122
122
|
|
|
123
|
-
# Chat Completion
|
|
124
|
-
print("\n=== Chat Completion
|
|
123
|
+
# Chat Completion Step
|
|
124
|
+
print("\n=== Chat Completion Step ===")
|
|
125
125
|
print(f"Asking agent about the uploaded file '{file_name}'...")
|
|
126
126
|
messages = ChatMessageList(messages=[
|
|
127
127
|
ChatMessage(
|
|
@@ -154,4 +154,4 @@ if __name__ == "__main__":
|
|
|
154
154
|
rollback()
|
|
155
155
|
except Exception as e:
|
|
156
156
|
rollback()
|
|
157
|
-
print(f"\n# Critical error: {e}")
|
|
157
|
+
print(f"\n# Critical error: {e}")
|
|
@@ -185,7 +185,6 @@ WEB_READING_GUIDE:
|
|
|
185
185
|
# Update the agent
|
|
186
186
|
manager = AILabManager()
|
|
187
187
|
result = manager.update_agent(
|
|
188
|
-
project_id="2ca6883f-6778-40bb-bcc1-85451fb11107",
|
|
189
188
|
agent=agent,
|
|
190
189
|
automatic_publish=True
|
|
191
190
|
)
|
|
@@ -193,4 +192,4 @@ result = manager.update_agent(
|
|
|
193
192
|
if isinstance(result, Agent):
|
|
194
193
|
print(f"Agent updated successfully: {agent.to_dict()}")
|
|
195
194
|
else:
|
|
196
|
-
print("Errors:", result.errors if hasattr(result, 'errors') else "Unknown error occurred")
|
|
195
|
+
print("Errors:", result.errors if hasattr(result, 'errors') else "Unknown error occurred")
|