pygeai 0.4.0b3__py3-none-any.whl → 0.5.0__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/assistant/rag/models.py +1 -1
- pygeai/chat/ui.py +0 -1
- pygeai/cli/__init__.py +1 -1
- pygeai/cli/commands/chat.py +54 -56
- pygeai/cli/commands/lab/ai_lab.py +129 -466
- pygeai/cli/commands/lab/options.py +8 -0
- pygeai/cli/commands/lab/utils.py +13 -0
- pygeai/cli/geai.py +5 -2
- pygeai/cli/texts/help.py +12 -0
- pygeai/core/base/session.py +1 -1
- pygeai/core/common/config.py +0 -2
- pygeai/core/common/exceptions.py +6 -0
- pygeai/lab/agents/clients.py +30 -61
- pygeai/lab/clients.py +20 -0
- pygeai/lab/managers.py +6 -58
- pygeai/lab/models.py +1 -1
- pygeai/lab/processes/clients.py +81 -129
- pygeai/lab/processes/mappers.py +2 -2
- pygeai/lab/strategies/clients.py +11 -17
- pygeai/lab/tools/clients.py +59 -59
- pygeai/lab/tools/mappers.py +5 -5
- pygeai/tests/cli/docker/__init__.py +0 -0
- pygeai/tests/integration/assistants/__init__.py +0 -0
- pygeai/tests/integration/assistants/rag/__init__.py +0 -0
- pygeai/tests/integration/assistants/rag/test_create_rag.py +91 -0
- pygeai/tests/integration/chat/__init__.py +0 -0
- pygeai/tests/integration/chat/test_generate_image.py +158 -0
- pygeai/tests/integration/lab/agents/test_create_agent.py +21 -19
- pygeai/tests/integration/lab/agents/test_create_sharing_link.py +4 -1
- pygeai/tests/integration/lab/agents/test_publish_agent_revision.py +0 -1
- pygeai/tests/integration/lab/agents/test_update_agent.py +19 -31
- 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_get_process.py +201 -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 +14 -20
- pygeai/tests/integration/lab/tools/test_delete_tool.py +3 -3
- pygeai/tests/integration/lab/tools/test_get_parameter.py +98 -0
- pygeai/tests/integration/lab/tools/test_get_tool.py +3 -3
- pygeai/tests/integration/lab/tools/test_list_tools.py +106 -0
- pygeai/tests/integration/lab/tools/test_publish_tool_revision.py +119 -0
- pygeai/tests/integration/lab/tools/test_set_parameter.py +114 -0
- pygeai/tests/integration/lab/tools/test_update_tool.py +267 -0
- pygeai/tests/snippets/lab/agentic_flow_example_4.py +23 -23
- pygeai/tests/snippets/lab/agents/get_sharing_link.py +1 -2
- pygeai/tests/snippets/lab/samples/summarize_files.py +3 -3
- pygeai/tests/snippets/lab/tools/create_tool.py +1 -1
- 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.0b3.dist-info → pygeai-0.5.0.dist-info}/METADATA +47 -19
- {pygeai-0.4.0b3.dist-info → pygeai-0.5.0.dist-info}/RECORD +61 -39
- {pygeai-0.4.0b3.dist-info → pygeai-0.5.0.dist-info}/WHEEL +0 -0
- {pygeai-0.4.0b3.dist-info → pygeai-0.5.0.dist-info}/entry_points.txt +0 -0
- {pygeai-0.4.0b3.dist-info → pygeai-0.5.0.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.4.0b3.dist-info → pygeai-0.5.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
import uuid
|
|
3
|
+
from pygeai.core.common.exceptions import APIResponseError
|
|
4
|
+
from pygeai.lab.managers import AILabManager
|
|
5
|
+
from pygeai.lab.models import Tool, ToolParameter
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestAILabUpdateToolIntegration(TestCase):
|
|
9
|
+
def setUp(self):
|
|
10
|
+
"""
|
|
11
|
+
Set up the test environment.
|
|
12
|
+
"""
|
|
13
|
+
self.ai_lab_manager = AILabManager(alias="beta")
|
|
14
|
+
self.tool_to_update = self.__load_tool()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def __load_tool(self):
|
|
18
|
+
self.random_str = str(uuid.uuid4())
|
|
19
|
+
return Tool(
|
|
20
|
+
id="c77e1f2e-0322-4dd0-b6ec-aff217f1cb32",
|
|
21
|
+
name=f"sdk_project_updated_tool_{self.random_str}",
|
|
22
|
+
description=f"Tool updated for sdk testing purposes {self.random_str}",
|
|
23
|
+
scope="builtin",
|
|
24
|
+
openApi="https://raw.usercontent.com//openapi.json",
|
|
25
|
+
openApiJson={"openapi": "3.0.0","info": {"title": f"Simple API overview {self.random_str}","version": "3.0.0"}},
|
|
26
|
+
accessScope="private",
|
|
27
|
+
reportEvents="None",
|
|
28
|
+
parameters=[{
|
|
29
|
+
"key": "param",
|
|
30
|
+
"description": f"param description {self.random_str}",
|
|
31
|
+
"type":"app",
|
|
32
|
+
"value": f"value {self.random_str}",
|
|
33
|
+
"data_type": "String",
|
|
34
|
+
"isRequired": False
|
|
35
|
+
}]
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def __update_tool(self, tool: Tool = None, automatic_publish: bool = False, upsert: bool = False):
|
|
40
|
+
"""
|
|
41
|
+
Helper method to update a tool.
|
|
42
|
+
"""
|
|
43
|
+
return self.ai_lab_manager.update_tool(
|
|
44
|
+
tool = self.tool_to_update if tool is None else tool,
|
|
45
|
+
automatic_publish=automatic_publish,
|
|
46
|
+
upsert=upsert
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_update_tool_all_fields_success(self):
|
|
51
|
+
updated_tool = self.__update_tool()
|
|
52
|
+
self.assertEqual(updated_tool.name, self.tool_to_update.name)
|
|
53
|
+
self.assertEqual(updated_tool.description, self.tool_to_update.description)
|
|
54
|
+
self.assertEqual(updated_tool.open_api_json, self.tool_to_update.open_api_json)
|
|
55
|
+
self.assertEqual(updated_tool.parameters[0].description, self.tool_to_update.parameters[0].description)
|
|
56
|
+
self.assertEqual(updated_tool.parameters[0].value, self.tool_to_update.parameters[0].value)
|
|
57
|
+
self.assertTrue(updated_tool.is_draft, "Expected tool to be in draft state after update")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_update_tool_invalid_name(self):
|
|
61
|
+
test_params = [ True, False ]
|
|
62
|
+
|
|
63
|
+
for auto_publish in test_params:
|
|
64
|
+
with self.subTest(input=auto_publish):
|
|
65
|
+
tool = self.__load_tool()
|
|
66
|
+
tool2 = self.__load_tool()
|
|
67
|
+
|
|
68
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
69
|
+
tool.name = f"{tool.name}:invalid"
|
|
70
|
+
self.__update_tool(tool=tool, automatic_publish=auto_publish)
|
|
71
|
+
self.assertIn(
|
|
72
|
+
"Invalid character in name (: is not allowed).",
|
|
73
|
+
str(exception.exception),
|
|
74
|
+
f"Expected an error about invalid character (:) in tool name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
78
|
+
tool2.name = f"{tool2.name}/invalid"
|
|
79
|
+
self.__update_tool(tool=tool2, automatic_publish=auto_publish)
|
|
80
|
+
self.assertIn(
|
|
81
|
+
"Invalid character in name (/ is not allowed).",
|
|
82
|
+
str(exception.exception),
|
|
83
|
+
f"Expected an error about invalid character (/) in tool name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_update_tool_duplicated_name(self):
|
|
88
|
+
test_params = [ True, False ]
|
|
89
|
+
|
|
90
|
+
for auto_publish in test_params:
|
|
91
|
+
|
|
92
|
+
with self.subTest(input=auto_publish):
|
|
93
|
+
self.tool_to_update.name = "sdk_project_gemini_tool"
|
|
94
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
95
|
+
self.__update_tool(automatic_publish=auto_publish)
|
|
96
|
+
self.assertIn(
|
|
97
|
+
"Tool already exists",
|
|
98
|
+
str(exception.exception),
|
|
99
|
+
f"Expected an error about duplicated tool name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_update_tool_no_name(self):
|
|
104
|
+
test_params = [ True, False ]
|
|
105
|
+
|
|
106
|
+
for auto_publish in test_params:
|
|
107
|
+
|
|
108
|
+
with self.subTest(input=auto_publish):
|
|
109
|
+
self.tool_to_update.name = ""
|
|
110
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
111
|
+
self.__update_tool(automatic_publish=auto_publish)
|
|
112
|
+
self.assertIn(
|
|
113
|
+
"Tool name cannot be empty",
|
|
114
|
+
str(exception.exception),
|
|
115
|
+
f"Expected an error when tool name is not provided with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def test_update_tool_invalid_id(self):
|
|
120
|
+
test_params = [ True, False ]
|
|
121
|
+
|
|
122
|
+
for auto_publish in test_params:
|
|
123
|
+
with self.subTest(input=auto_publish):
|
|
124
|
+
invalid_id = "0026e53d-ea78-4cac-af9f-12650invalid"
|
|
125
|
+
self.tool_to_update.id = invalid_id
|
|
126
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
127
|
+
self.__update_tool(automatic_publish=auto_publish)
|
|
128
|
+
self.assertIn(
|
|
129
|
+
f"Tool not found [IdOrName= {invalid_id}",
|
|
130
|
+
str(exception.exception),
|
|
131
|
+
f"Expected an error when tool id is invalid and autopublish is {'enabled' if auto_publish else 'disabled'}"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def test_update_tool_scope(self):
|
|
136
|
+
for scope in ["builtin", "external", "api"]:
|
|
137
|
+
tool = self.__load_tool()
|
|
138
|
+
tool.scope = scope
|
|
139
|
+
result = self.__update_tool(tool=tool)
|
|
140
|
+
self.assertEqual(result.scope, scope)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def test_update_tool_invalid_scope(self):
|
|
144
|
+
test_params = [ True, False ]
|
|
145
|
+
self.tool_to_update.scope = "project"
|
|
146
|
+
for auto_publish in test_params:
|
|
147
|
+
with self.subTest(input=auto_publish):
|
|
148
|
+
with self.assertRaises(ValueError) as exception:
|
|
149
|
+
self.__update_tool(automatic_publish=auto_publish)
|
|
150
|
+
self.assertIn(
|
|
151
|
+
f"Scope must be one of builtin, external, api, proxied",
|
|
152
|
+
str(exception.exception),
|
|
153
|
+
f"Expected an error when tool scope is invalid and autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def test_update_tool_access_scope(self):
|
|
158
|
+
for access_scope in ["public", "private"]:
|
|
159
|
+
tool = self.__load_tool()
|
|
160
|
+
tool.access_scope = access_scope
|
|
161
|
+
|
|
162
|
+
if access_scope == "public":
|
|
163
|
+
tool.public_name = f"com.sdk.testing.{self.random_str}"
|
|
164
|
+
|
|
165
|
+
updated_tool = self.__update_tool(tool=tool)
|
|
166
|
+
self.assertEqual(updated_tool.access_scope, access_scope)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_update_tool_invalid_public_name(self):
|
|
170
|
+
test_params = [ True, False ]
|
|
171
|
+
self.tool_to_update.access_scope = "public"
|
|
172
|
+
self.tool_to_update.public_name = "invalid#name"
|
|
173
|
+
for auto_publish in test_params:
|
|
174
|
+
with self.subTest(input=auto_publish):
|
|
175
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
176
|
+
self.__update_tool(automatic_publish=auto_publish)
|
|
177
|
+
self.assertIn(
|
|
178
|
+
"Invalid public name, it can only contain lowercase letters, numbers, periods (.), dashes (-), and underscores (_). Please remove any other characters.",
|
|
179
|
+
str(exception.exception),
|
|
180
|
+
f"Expected error when invalid public name is sent and autopublish is {'enabled' if auto_publish else 'disabled'}"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
def test_update_tool_duplicate_public_name(self):
|
|
184
|
+
test_params = [ True, False ]
|
|
185
|
+
self.tool_to_update.access_scope = "public"
|
|
186
|
+
self.tool_to_update.public_name = "test.sdk.beta.tool"
|
|
187
|
+
for auto_publish in test_params:
|
|
188
|
+
with self.subTest(input=auto_publish):
|
|
189
|
+
with self.assertRaises(Exception) as exc:
|
|
190
|
+
self.__update_tool(automatic_publish=auto_publish)
|
|
191
|
+
self.assertIn(
|
|
192
|
+
"Tool already exists",
|
|
193
|
+
str(exc.exception),
|
|
194
|
+
f"Expected error when public name is duplicated and autopublish is {'enabled' if auto_publish else 'disabled'}"
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def test_update_tool_no_public_name(self):
|
|
199
|
+
test_params = [ True, False ]
|
|
200
|
+
self.tool_to_update.access_scope = "public"
|
|
201
|
+
self.tool_to_update.public_name = ""
|
|
202
|
+
|
|
203
|
+
for auto_publish in test_params:
|
|
204
|
+
with self.subTest(input=auto_publish):
|
|
205
|
+
with self.assertRaises(Exception) as exc:
|
|
206
|
+
self.__update_tool(automatic_publish=auto_publish)
|
|
207
|
+
self.assertIn(
|
|
208
|
+
"Tool publicName is required for tools with accessScope=public.",
|
|
209
|
+
str(exc.exception),
|
|
210
|
+
f"Expected error when public name is not provided and autopublish is {'enabled' if auto_publish else 'disabled'}"
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def test_update_tool_no_open_api_nor_json(self):
|
|
215
|
+
test_params = [ True, False ]
|
|
216
|
+
self.tool_to_update.scope = "api"
|
|
217
|
+
self.tool_to_update.open_api = ""
|
|
218
|
+
self.tool_to_update.open_api_json = None
|
|
219
|
+
|
|
220
|
+
for auto_publish in test_params:
|
|
221
|
+
with self.subTest(input=auto_publish):
|
|
222
|
+
with self.assertRaises(APIResponseError) as exc:
|
|
223
|
+
self.__update_tool(automatic_publish=auto_publish)
|
|
224
|
+
self.assertIn(
|
|
225
|
+
"Either openApi (URL with the OpenAPI definition) or the openApiJson (with the conent) are required for api-tools.",
|
|
226
|
+
str(exc.exception),
|
|
227
|
+
f"Expected error when no openApi or openApiJson are provided and autopublish is {'enabled' if auto_publish else 'disabled'}"
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def test_update_tool_parameters(self):
|
|
232
|
+
self.tool_to_update.parameters = [
|
|
233
|
+
ToolParameter(key="paramA", data_type="String", description="descA", is_required=True),
|
|
234
|
+
ToolParameter(key="paramB", data_type="String", description="descB", is_required=False)
|
|
235
|
+
]
|
|
236
|
+
result = self.__update_tool()
|
|
237
|
+
self.assertEqual(len(result.parameters), 2)
|
|
238
|
+
self.assertEqual(result.parameters[0].key, "paramA")
|
|
239
|
+
self.assertEqual(result.parameters[1].key, "paramB")
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def test_update_tool_automatic_publish(self):
|
|
243
|
+
result = self.__update_tool(automatic_publish=True)
|
|
244
|
+
self.assertFalse(result.is_draft, "Expected tool to be published after update with automatic_publish=True")
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def test_update_tool_upsert(self):
|
|
248
|
+
self.tool_to_update.id = str(uuid.uuid4())
|
|
249
|
+
self.tool_to_update.name = str(uuid.uuid4())
|
|
250
|
+
result = self.__update_tool(upsert=True)
|
|
251
|
+
|
|
252
|
+
if isinstance(result, Tool):
|
|
253
|
+
self.ai_lab_manager.delete_tool(result.id)
|
|
254
|
+
|
|
255
|
+
self.assertEqual(result.name, self.tool_to_update.name)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_update_tool_upsert_false_not_exists(self):
|
|
259
|
+
new_id = str(uuid.uuid4())
|
|
260
|
+
self.tool_to_update.id = new_id
|
|
261
|
+
with self.assertRaises(Exception) as exc:
|
|
262
|
+
self.__update_tool(upsert=False)
|
|
263
|
+
self.assertIn(f"Tool not found [IdOrName= {new_id}]", str(exc.exception))
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
@@ -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")
|