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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
from pygeai.lab.managers import AILabManager
|
|
3
|
+
from pygeai.lab.models import ReasoningStrategy
|
|
4
|
+
from pygeai.core.common.exceptions import APIError
|
|
5
|
+
|
|
6
|
+
ai_lab_manager: AILabManager
|
|
7
|
+
|
|
8
|
+
class TestAILabGetReasoningStrategyIntegration(TestCase):
|
|
9
|
+
|
|
10
|
+
def setUp(self):
|
|
11
|
+
self.ai_lab_manager = AILabManager()
|
|
12
|
+
self.strategy_id = "0a3b039e-25bd-4cf9-ad67-7af2b654874b"
|
|
13
|
+
self.strategy_name = "Chain of Thought"
|
|
14
|
+
|
|
15
|
+
def __get_reasoning_strategy(self, strategy_id = None, strategy_name = None):
|
|
16
|
+
return self.ai_lab_manager.get_reasoning_strategy(
|
|
17
|
+
reasoning_strategy_id= strategy_id if strategy_id is not None else self.strategy_id,
|
|
18
|
+
reasoning_strategy_name=strategy_name if strategy_name is not None else self.strategy_name
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def test_get_reasoning_strategy_by_id(self):
|
|
22
|
+
strategy = self.__get_reasoning_strategy(strategy_name="")
|
|
23
|
+
|
|
24
|
+
self.assertIsInstance(strategy, ReasoningStrategy, "Expected a reasoning strategy")
|
|
25
|
+
self.assertEqual(strategy.id, self.strategy_id, "Expected reasoning strategy ID to match")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_get_reasoning_strategy_by_name(self):
|
|
29
|
+
strategy = self.__get_reasoning_strategy(strategy_id="")
|
|
30
|
+
|
|
31
|
+
self.assertIsInstance(strategy, ReasoningStrategy, "Expected a reasoning strategy")
|
|
32
|
+
self.assertEqual(
|
|
33
|
+
strategy.name,
|
|
34
|
+
self.strategy_name,
|
|
35
|
+
"Expected reasoning strategy name to match"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_get_reasoning_strategy_no_id_or_name(self):
|
|
40
|
+
with self.assertRaises(Exception) as context:
|
|
41
|
+
self.__get_reasoning_strategy(strategy_id="", strategy_name="")
|
|
42
|
+
|
|
43
|
+
self.assertIn(
|
|
44
|
+
"Either reasoning_strategy_id or reasoning_strategy_name must be provided.",
|
|
45
|
+
str(context.exception),
|
|
46
|
+
"Expected error message for missing id and name"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_get_reasoning_strategy_invalid_id(self):
|
|
51
|
+
invalid_id = "invalid-id-1234"
|
|
52
|
+
with self.assertRaises(APIError) as context:
|
|
53
|
+
self.__get_reasoning_strategy(strategy_id=invalid_id)
|
|
54
|
+
self.assertIn(
|
|
55
|
+
f"Reasoning-Strategy not found (idOrName={invalid_id}",
|
|
56
|
+
str(context.exception),
|
|
57
|
+
"Expected an error for invalid reasoning strategy id"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_get_reasoning_strategy_invalid_name(self):
|
|
62
|
+
invalid_name = "Nonexistent Strategy"
|
|
63
|
+
with self.assertRaises(APIError) as context:
|
|
64
|
+
self.__get_reasoning_strategy(strategy_id="", strategy_name=invalid_name)
|
|
65
|
+
|
|
66
|
+
self.assertIn(
|
|
67
|
+
f"Reasoning-Strategy not found (idOrName={invalid_name})",
|
|
68
|
+
str(context.exception),
|
|
69
|
+
"Expected an error for invalid reasoning strategy name"
|
|
70
|
+
)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
from pygeai.lab.managers import AILabManager
|
|
3
|
+
from pygeai.lab.models import FilterSettings, ReasoningStrategyList
|
|
4
|
+
import copy
|
|
5
|
+
|
|
6
|
+
ai_lab_manager: AILabManager
|
|
7
|
+
|
|
8
|
+
class TestAILabListReasoningStrategiesIntegration(TestCase):
|
|
9
|
+
|
|
10
|
+
def setUp(self):
|
|
11
|
+
self.ai_lab_manager = AILabManager()
|
|
12
|
+
self.filter_settings = FilterSettings(
|
|
13
|
+
name="",
|
|
14
|
+
start=0,
|
|
15
|
+
count=100,
|
|
16
|
+
allow_external=True,
|
|
17
|
+
access_scope="public"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def __list_reasoning_strategies(self, filter_settings: FilterSettings = None):
|
|
22
|
+
filter_settings = filter_settings if filter_settings is not None else self.filter_settings
|
|
23
|
+
return self.ai_lab_manager.list_reasoning_strategies(filter_settings=filter_settings)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_public_list_reasoning_strategies(self):
|
|
27
|
+
result = self.__list_reasoning_strategies()
|
|
28
|
+
|
|
29
|
+
self.assertIsInstance(result, ReasoningStrategyList, "Expected a list of reasoning strategies")
|
|
30
|
+
for strategy in result.strategies:
|
|
31
|
+
self.assertTrue(
|
|
32
|
+
strategy.access_scope == "public",
|
|
33
|
+
"Expected all reasoning strategies to be public"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_private_list_reasoning_strategies(self):
|
|
38
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
39
|
+
filter_settings.access_scope = "private"
|
|
40
|
+
result = self.__list_reasoning_strategies(filter_settings=filter_settings)
|
|
41
|
+
|
|
42
|
+
self.assertIsInstance(result, ReasoningStrategyList, "Expected a list of reasoning strategies")
|
|
43
|
+
for strategy in result.strategies:
|
|
44
|
+
self.assertTrue(
|
|
45
|
+
strategy.access_scope == "private",
|
|
46
|
+
"Expected all reasoning strategies to be private"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_list_reasoning_strategies_small_count(self):
|
|
51
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
52
|
+
filter_settings.count = 2
|
|
53
|
+
result = self.__list_reasoning_strategies(filter_settings=filter_settings)
|
|
54
|
+
self.assertEqual(
|
|
55
|
+
len(result), 2,
|
|
56
|
+
"Expected list of reasoning strategies returned to be 2"
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_list_reasoning_strategies_big_count(self):
|
|
61
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
62
|
+
filter_settings.count = 500
|
|
63
|
+
result = self.__list_reasoning_strategies(filter_settings=filter_settings)
|
|
64
|
+
self.assertLessEqual(
|
|
65
|
+
len(result), 500,
|
|
66
|
+
"Expected list of reasoning strategies returned to be 500 or less"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_list_reasoning_strategies_name_filter(self):
|
|
71
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
72
|
+
filter_settings.name = "Chain of Thought"
|
|
73
|
+
result = self.__list_reasoning_strategies(filter_settings=filter_settings)
|
|
74
|
+
|
|
75
|
+
for strategy in result.strategies:
|
|
76
|
+
self.assertIn(
|
|
77
|
+
"Chain of Thought",
|
|
78
|
+
strategy.name,
|
|
79
|
+
"Expected reasoning strategy name to contain filter value"
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_list_reasoning_strategies_invalid_scope(self):
|
|
84
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
85
|
+
filter_settings.access_scope = "project"
|
|
86
|
+
|
|
87
|
+
with self.assertRaises(ValueError) as exception:
|
|
88
|
+
self.__list_reasoning_strategies(filter_settings=filter_settings)
|
|
89
|
+
self.assertIn(
|
|
90
|
+
"Access scope must be either 'public' or 'private'.",
|
|
91
|
+
str(exception.exception),
|
|
92
|
+
"The expected error about invalid scope was not returned"
|
|
93
|
+
)
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
import unittest
|
|
3
|
+
import uuid
|
|
4
|
+
from pygeai.lab.managers import AILabManager
|
|
5
|
+
from pygeai.lab.models import LocalizedDescription, ReasoningStrategy
|
|
6
|
+
from pydantic import ValidationError
|
|
7
|
+
from pygeai.core.common.exceptions import APIError, APIResponseError
|
|
8
|
+
|
|
9
|
+
class TestAILabCreateReasoningStrategyIntegration(TestCase):
|
|
10
|
+
def setUp(self):
|
|
11
|
+
"""
|
|
12
|
+
Set up the test environment.
|
|
13
|
+
"""
|
|
14
|
+
self.ai_lab_manager = AILabManager()
|
|
15
|
+
self.strategy_to_update = self.__load_strategy()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def __load_strategy(self):
|
|
19
|
+
self.random_str = str(uuid.uuid4())
|
|
20
|
+
return ReasoningStrategy(
|
|
21
|
+
id="323f5f94-5a3d-4717-89f3-3554a33c093f",
|
|
22
|
+
name=f"UpdatedStrategy_{self.random_str}",
|
|
23
|
+
system_prompt=f"Let's think step by step. {self.random_str}",
|
|
24
|
+
access_scope="private",
|
|
25
|
+
type="addendum",
|
|
26
|
+
localized_descriptions=[
|
|
27
|
+
LocalizedDescription(language="spanish", description=f"RSName spanish description {self.random_str}"),
|
|
28
|
+
LocalizedDescription(language="english", description=f"RSName english description {self.random_str}"),
|
|
29
|
+
LocalizedDescription(language="japanese", description=f"RSName japanese description {self.random_str}")
|
|
30
|
+
]
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def __update_strategy(self, strategy=None, upsert = False):
|
|
35
|
+
"""
|
|
36
|
+
Helper to create a reasoning strategy using ai_lab_manager.
|
|
37
|
+
"""
|
|
38
|
+
return self.ai_lab_manager.update_reasoning_strategy(
|
|
39
|
+
strategy=self.strategy_to_update if strategy is None else strategy,
|
|
40
|
+
upsert=upsert
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_update_strategy_full_data(self):
|
|
45
|
+
self.updated_strategy = self.__update_strategy()
|
|
46
|
+
|
|
47
|
+
self.assertEqual(self.updated_strategy.name, self.strategy_to_update.name)
|
|
48
|
+
self.assertEqual(self.updated_strategy.system_prompt, self.strategy_to_update.system_prompt)
|
|
49
|
+
|
|
50
|
+
for locale in self.updated_strategy.localized_descriptions:
|
|
51
|
+
self.assertIn(
|
|
52
|
+
self.random_str,
|
|
53
|
+
locale.description,
|
|
54
|
+
"Expected the localized description to be updated correctly"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_update_strategy_no_name(self):
|
|
59
|
+
self.strategy_to_update.name = None
|
|
60
|
+
|
|
61
|
+
with self.assertRaises(APIError) as exception:
|
|
62
|
+
self.__update_strategy()
|
|
63
|
+
self.assertIn(
|
|
64
|
+
"ReasoningStrategy name cannot be empty",
|
|
65
|
+
str(exception.exception),
|
|
66
|
+
"The expected error about empty name was not returned"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_update_strategy_no_system_prompt(self):
|
|
71
|
+
self.strategy_to_update.system_prompt = None
|
|
72
|
+
|
|
73
|
+
with self.assertRaises(APIError) as exception:
|
|
74
|
+
self.__update_strategy()
|
|
75
|
+
self.assertIn(
|
|
76
|
+
"ReasoningStrategy template or systemPrompt are required.",
|
|
77
|
+
str(exception.exception),
|
|
78
|
+
"The expected error about empty system_prompt was not returned"
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_update_strategy_no_public_name(self):
|
|
83
|
+
self.strategy_to_update.access_scope = "public"
|
|
84
|
+
with self.assertRaises(APIError) as exception:
|
|
85
|
+
self.__update_strategy()
|
|
86
|
+
self.assertIn(
|
|
87
|
+
"ReasoningStrategy publicName is required for public strategies",
|
|
88
|
+
str(exception.exception),
|
|
89
|
+
"The expected error about missing public name was not returned"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_update_strategy_no_access_scope(self):
|
|
94
|
+
self.strategy_to_update.access_scope = ""
|
|
95
|
+
with self.assertRaises(ValueError) as exception:
|
|
96
|
+
self.__update_strategy()
|
|
97
|
+
self.assertIn(
|
|
98
|
+
"Access scope must be either 'public' or 'private'",
|
|
99
|
+
str(exception.exception),
|
|
100
|
+
"The expected error about missing access scope was not returned"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def test_update_strategy_no_type(self):
|
|
105
|
+
self.strategy_to_update.type = ""
|
|
106
|
+
with self.assertRaises(ValueError) as exception:
|
|
107
|
+
self.__update_strategy()
|
|
108
|
+
self.assertIn(
|
|
109
|
+
"Type must be 'addendum'",
|
|
110
|
+
str(exception.exception),
|
|
111
|
+
"The expected error about missing type was not returned"
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def test_update_strategy_invalid_type(self):
|
|
116
|
+
self.strategy_to_update.type = "strategy_type"
|
|
117
|
+
|
|
118
|
+
with self.assertRaises(ValueError) as exception:
|
|
119
|
+
self.__update_strategy()
|
|
120
|
+
self.assertIn(
|
|
121
|
+
"Type must be 'addendum'",
|
|
122
|
+
str(exception.exception),
|
|
123
|
+
"The expected error about missing type was not returned"
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def test_update_strategy_no_localized_descriptions(self):
|
|
128
|
+
self.strategy_to_update.localized_descriptions = []
|
|
129
|
+
updated_strategy = self.__update_strategy()
|
|
130
|
+
self.assertIsNone(
|
|
131
|
+
updated_strategy.localized_descriptions,
|
|
132
|
+
"Expected no localized descriptions after update"
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
@unittest.skip("Skipping upsert test to avoid creating new strategies during routine testing before having a cleanup mechanism.")
|
|
136
|
+
def test_update_strategy_upsert(self):
|
|
137
|
+
new_id = str(uuid.uuid4())
|
|
138
|
+
new_strategy = ReasoningStrategy(
|
|
139
|
+
id=new_id,
|
|
140
|
+
name=f"UpsertStrategy_{self.random_str}",
|
|
141
|
+
system_prompt=f"Upsert system prompt {self.random_str}",
|
|
142
|
+
access_scope="private",
|
|
143
|
+
type="addendum",
|
|
144
|
+
localized_descriptions=[
|
|
145
|
+
LocalizedDescription(language="english", description=f"Upsert description {self.random_str}")
|
|
146
|
+
]
|
|
147
|
+
)
|
|
148
|
+
upserted_strategy = self.__update_strategy(strategy=new_strategy, upsert=True)
|
|
149
|
+
self.assertEqual(upserted_strategy.id, new_id, "Expected the reasoning strategy to be created via upsert")
|
|
@@ -2,8 +2,7 @@ from unittest import TestCase
|
|
|
2
2
|
import uuid
|
|
3
3
|
from pygeai.lab.managers import AILabManager
|
|
4
4
|
from pygeai.lab.models import Tool, ToolParameter
|
|
5
|
-
from
|
|
6
|
-
from pygeai.core.common.exceptions import APIError
|
|
5
|
+
from pygeai.core.common.exceptions import APIResponseError
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
class TestAILabCreateToolIntegration(TestCase):
|
|
@@ -11,7 +10,7 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
11
10
|
"""
|
|
12
11
|
Set up the test environment.
|
|
13
12
|
"""
|
|
14
|
-
self.ai_lab_manager = AILabManager(
|
|
13
|
+
self.ai_lab_manager = AILabManager()
|
|
15
14
|
self.new_tool = self.__load_tool()
|
|
16
15
|
self.created_tool: Tool = None
|
|
17
16
|
|
|
@@ -94,15 +93,12 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
94
93
|
|
|
95
94
|
for auto_publish in test_params:
|
|
96
95
|
|
|
97
|
-
with self.subTest(input=auto_publish):
|
|
98
|
-
|
|
99
|
-
self.new_tool = Tool(
|
|
96
|
+
with self.subTest(input=auto_publish):
|
|
97
|
+
self.new_tool = Tool(
|
|
100
98
|
name=str(uuid.uuid4())
|
|
101
99
|
)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
self.assertIn("description", str(context.exception))
|
|
105
|
-
self.assertIn("Field required", str(context.exception))
|
|
100
|
+
created_tool = self.__create_tool(automatic_publish=auto_publish)
|
|
101
|
+
self.assertTrue(isinstance(created_tool, Tool), "Expected a created tool")
|
|
106
102
|
|
|
107
103
|
|
|
108
104
|
def test_create_tool_no_name(self):
|
|
@@ -111,7 +107,7 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
111
107
|
for auto_publish in test_params:
|
|
112
108
|
with self.subTest(input=auto_publish):
|
|
113
109
|
self.new_tool.name = ""
|
|
114
|
-
with self.assertRaises(
|
|
110
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
115
111
|
self.__create_tool(automatic_publish=auto_publish)
|
|
116
112
|
|
|
117
113
|
self.assertIn(
|
|
@@ -128,7 +124,7 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
128
124
|
|
|
129
125
|
with self.subTest(input=auto_publish):
|
|
130
126
|
self.new_tool.name = "sdk_project_gemini_tool"
|
|
131
|
-
with self.assertRaises(
|
|
127
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
132
128
|
self.__create_tool(automatic_publish=auto_publish)
|
|
133
129
|
self.assertIn(
|
|
134
130
|
"Tool already exists [name=sdk_project_gemini_tool]..",
|
|
@@ -145,7 +141,7 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
145
141
|
new_tool = self.__load_tool()
|
|
146
142
|
new_tool2 = self.__load_tool()
|
|
147
143
|
|
|
148
|
-
with self.assertRaises(
|
|
144
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
149
145
|
new_tool.name = f"{new_tool.name}:invalid"
|
|
150
146
|
self.__create_tool(tool=new_tool, automatic_publish=auto_publish)
|
|
151
147
|
self.assertIn(
|
|
@@ -154,7 +150,7 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
154
150
|
f"Expected an error about invalid character (:) in tool name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
155
151
|
)
|
|
156
152
|
|
|
157
|
-
with self.assertRaises(
|
|
153
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
158
154
|
new_tool2.name = f"{new_tool2.name}/invalid"
|
|
159
155
|
self.__create_tool(tool=new_tool2, automatic_publish=auto_publish)
|
|
160
156
|
self.assertIn(
|
|
@@ -190,7 +186,7 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
190
186
|
with self.subTest(input=auto_publish):
|
|
191
187
|
self.new_tool.access_scope = "public"
|
|
192
188
|
self.new_tool.public_name = None
|
|
193
|
-
with self.assertRaises(
|
|
189
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
194
190
|
self.__create_tool(automatic_publish=auto_publish)
|
|
195
191
|
self.assertIn(
|
|
196
192
|
"Tool publicName is required for tools with accessScope=public.",
|
|
@@ -206,7 +202,7 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
206
202
|
with self.subTest(input=auto_publish):
|
|
207
203
|
self.new_tool.access_scope = "public"
|
|
208
204
|
self.new_tool.public_name = "com.sdk.testing#" # Add invalid character to public name
|
|
209
|
-
with self.assertRaises(
|
|
205
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
210
206
|
self.__create_tool(automatic_publish=auto_publish)
|
|
211
207
|
|
|
212
208
|
self.assertIn(
|
|
@@ -232,7 +228,7 @@ class TestAILabCreateToolIntegration(TestCase):
|
|
|
232
228
|
duplicated_pn_tool.access_scope = "public"
|
|
233
229
|
duplicated_pn_tool.public_name = self.created_tool.public_name
|
|
234
230
|
|
|
235
|
-
with self.assertRaises(
|
|
231
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
236
232
|
self.__create_tool(tool=duplicated_pn_tool, automatic_publish=auto_publish)
|
|
237
233
|
self.assertIn(
|
|
238
234
|
f"Tool already exists [publicName={self.created_tool.public_name}].",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
from unittest import TestCase
|
|
2
2
|
import uuid
|
|
3
3
|
from pygeai.lab.managers import AILabManager
|
|
4
|
-
from pygeai.lab.models import Tool
|
|
5
|
-
from pygeai.core.common.exceptions import MissingRequirementException, InvalidAPIResponseException
|
|
4
|
+
from pygeai.lab.models import Tool
|
|
5
|
+
from pygeai.core.common.exceptions import APIResponseError, MissingRequirementException, InvalidAPIResponseException
|
|
6
6
|
|
|
7
7
|
ai_lab_manager: AILabManager
|
|
8
8
|
|
|
9
9
|
class TestAILabDeleteToolIntegration(TestCase):
|
|
10
10
|
|
|
11
11
|
def setUp(self):
|
|
12
|
-
self.ai_lab_manager = AILabManager(
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def __create_tool(self):
|
|
@@ -66,7 +66,7 @@ class TestAILabDeleteToolIntegration(TestCase):
|
|
|
66
66
|
def test_delete_tool_invalid_id_valid_name(self):
|
|
67
67
|
invalid_id = "0026e53d-ea78-4cac-af9f-12650invalid"
|
|
68
68
|
created_tool = self.__create_tool()
|
|
69
|
-
with self.assertRaises(
|
|
69
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
70
70
|
self.__delete_tool(tool_name=created_tool.name, tool_id=invalid_id)
|
|
71
71
|
|
|
72
72
|
self.assertIn(
|
|
@@ -9,7 +9,7 @@ ai_lab_manager: AILabManager
|
|
|
9
9
|
class TestAILabGetParameterIntegration(TestCase):
|
|
10
10
|
|
|
11
11
|
def setUp(self):
|
|
12
|
-
self.ai_lab_manager = AILabManager(
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
13
13
|
self.tool_id = "42610b61-cb47-49bf-9475-36ee652f31f3"
|
|
14
14
|
self.filter_settings = FilterSettings(
|
|
15
15
|
revision="0",
|
|
@@ -2,7 +2,7 @@ from unittest import TestCase
|
|
|
2
2
|
import unittest
|
|
3
3
|
from pygeai.lab.managers import AILabManager
|
|
4
4
|
from pygeai.lab.models import Tool, FilterSettings
|
|
5
|
-
from pygeai.core.common.exceptions import
|
|
5
|
+
from pygeai.core.common.exceptions import APIResponseError
|
|
6
6
|
import copy
|
|
7
7
|
|
|
8
8
|
ai_lab_manager: AILabManager
|
|
@@ -10,7 +10,7 @@ ai_lab_manager: AILabManager
|
|
|
10
10
|
class TestAILabGetToolIntegration(TestCase):
|
|
11
11
|
|
|
12
12
|
def setUp(self):
|
|
13
|
-
self.ai_lab_manager = AILabManager(
|
|
13
|
+
self.ai_lab_manager = AILabManager()
|
|
14
14
|
self.tool_id = "e3e4d64f-ce52-467e-90a9-aa4d08425e82"
|
|
15
15
|
self.filter_settings = FilterSettings(
|
|
16
16
|
revision="0",
|
|
@@ -36,7 +36,7 @@ class TestAILabGetToolIntegration(TestCase):
|
|
|
36
36
|
|
|
37
37
|
def test_get_tool_invalid_tool_id(self):
|
|
38
38
|
invalid_id = "0026e53d-ea78-4cac-af9f-12650invalid"
|
|
39
|
-
with self.assertRaises(
|
|
39
|
+
with self.assertRaises(APIResponseError) as context:
|
|
40
40
|
self.__get_tool(tool_id=invalid_id)
|
|
41
41
|
self.assertIn(
|
|
42
42
|
f"Tool not found [IdOrName= {invalid_id}].",
|
|
@@ -65,7 +65,7 @@ class TestAILabGetToolIntegration(TestCase):
|
|
|
65
65
|
def test_get_tool_by_earlier_revision(self):
|
|
66
66
|
filter_settings = copy.deepcopy(self.filter_settings)
|
|
67
67
|
filter_settings.revision = "2"
|
|
68
|
-
with self.assertRaises(
|
|
68
|
+
with self.assertRaises(APIResponseError) as context:
|
|
69
69
|
self.__get_tool(filter_settings=filter_settings)
|
|
70
70
|
self.assertIn(
|
|
71
71
|
f"Requested revision not found [revision={filter_settings.revision}].",
|
|
@@ -8,7 +8,7 @@ ai_lab_manager: AILabManager
|
|
|
8
8
|
class TestAILabListToolsIntegration(TestCase):
|
|
9
9
|
|
|
10
10
|
def setUp(self):
|
|
11
|
-
self.ai_lab_manager = AILabManager(
|
|
11
|
+
self.ai_lab_manager = AILabManager()
|
|
12
12
|
self.filter_settings = FilterSettings(
|
|
13
13
|
allow_external=False,
|
|
14
14
|
allow_drafts=True,
|
|
@@ -9,7 +9,7 @@ ai_lab_manager: AILabManager
|
|
|
9
9
|
class TestAILabPublishToolRevisionIntegration(TestCase):
|
|
10
10
|
|
|
11
11
|
def setUp(self):
|
|
12
|
-
self.ai_lab_manager = AILabManager(
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
13
13
|
self.tool_id = "c77e1f2e-0322-4dd0-b6ec-aff217f1cb32"
|
|
14
14
|
|
|
15
15
|
|
|
@@ -8,7 +8,7 @@ ai_lab_manager: AILabManager
|
|
|
8
8
|
|
|
9
9
|
class TestAILabSetParameterIntegration(TestCase):
|
|
10
10
|
def setUp(self):
|
|
11
|
-
self.ai_lab_manager = AILabManager(
|
|
11
|
+
self.ai_lab_manager = AILabManager()
|
|
12
12
|
self.tool_id = "42610b61-cb47-49bf-9475-36ee652f31f3"
|
|
13
13
|
self.tool_parameters = self.__load_parameters()
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from unittest import TestCase
|
|
2
2
|
import uuid
|
|
3
|
-
from pygeai.core.common.exceptions import
|
|
3
|
+
from pygeai.core.common.exceptions import APIResponseError
|
|
4
4
|
from pygeai.lab.managers import AILabManager
|
|
5
5
|
from pygeai.lab.models import Tool, ToolParameter
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
10
10
|
"""
|
|
11
11
|
Set up the test environment.
|
|
12
12
|
"""
|
|
13
|
-
self.ai_lab_manager = AILabManager(
|
|
13
|
+
self.ai_lab_manager = AILabManager()
|
|
14
14
|
self.tool_to_update = self.__load_tool()
|
|
15
15
|
|
|
16
16
|
|
|
@@ -65,7 +65,7 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
65
65
|
tool = self.__load_tool()
|
|
66
66
|
tool2 = self.__load_tool()
|
|
67
67
|
|
|
68
|
-
with self.assertRaises(
|
|
68
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
69
69
|
tool.name = f"{tool.name}:invalid"
|
|
70
70
|
self.__update_tool(tool=tool, automatic_publish=auto_publish)
|
|
71
71
|
self.assertIn(
|
|
@@ -74,7 +74,7 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
74
74
|
f"Expected an error about invalid character (:) in tool name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
75
75
|
)
|
|
76
76
|
|
|
77
|
-
with self.assertRaises(
|
|
77
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
78
78
|
tool2.name = f"{tool2.name}/invalid"
|
|
79
79
|
self.__update_tool(tool=tool2, automatic_publish=auto_publish)
|
|
80
80
|
self.assertIn(
|
|
@@ -91,7 +91,7 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
91
91
|
|
|
92
92
|
with self.subTest(input=auto_publish):
|
|
93
93
|
self.tool_to_update.name = "sdk_project_gemini_tool"
|
|
94
|
-
with self.assertRaises(
|
|
94
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
95
95
|
self.__update_tool(automatic_publish=auto_publish)
|
|
96
96
|
self.assertIn(
|
|
97
97
|
"Tool already exists",
|
|
@@ -107,7 +107,7 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
107
107
|
|
|
108
108
|
with self.subTest(input=auto_publish):
|
|
109
109
|
self.tool_to_update.name = ""
|
|
110
|
-
with self.assertRaises(
|
|
110
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
111
111
|
self.__update_tool(automatic_publish=auto_publish)
|
|
112
112
|
self.assertIn(
|
|
113
113
|
"Tool name cannot be empty",
|
|
@@ -123,7 +123,7 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
123
123
|
with self.subTest(input=auto_publish):
|
|
124
124
|
invalid_id = "0026e53d-ea78-4cac-af9f-12650invalid"
|
|
125
125
|
self.tool_to_update.id = invalid_id
|
|
126
|
-
with self.assertRaises(
|
|
126
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
127
127
|
self.__update_tool(automatic_publish=auto_publish)
|
|
128
128
|
self.assertIn(
|
|
129
129
|
f"Tool not found [IdOrName= {invalid_id}",
|
|
@@ -172,7 +172,7 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
172
172
|
self.tool_to_update.public_name = "invalid#name"
|
|
173
173
|
for auto_publish in test_params:
|
|
174
174
|
with self.subTest(input=auto_publish):
|
|
175
|
-
with self.assertRaises(
|
|
175
|
+
with self.assertRaises(APIResponseError) as exception:
|
|
176
176
|
self.__update_tool(automatic_publish=auto_publish)
|
|
177
177
|
self.assertIn(
|
|
178
178
|
"Invalid public name, it can only contain lowercase letters, numbers, periods (.), dashes (-), and underscores (_). Please remove any other characters.",
|
|
@@ -219,7 +219,7 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
219
219
|
|
|
220
220
|
for auto_publish in test_params:
|
|
221
221
|
with self.subTest(input=auto_publish):
|
|
222
|
-
with self.assertRaises(
|
|
222
|
+
with self.assertRaises(APIResponseError) as exc:
|
|
223
223
|
self.__update_tool(automatic_publish=auto_publish)
|
|
224
224
|
self.assertIn(
|
|
225
225
|
"Either openApi (URL with the OpenAPI definition) or the openApiJson (with the conent) are required for api-tools.",
|
|
@@ -245,7 +245,6 @@ class TestAILabUpdateToolIntegration(TestCase):
|
|
|
245
245
|
|
|
246
246
|
|
|
247
247
|
def test_update_tool_upsert(self):
|
|
248
|
-
print(self.tool_to_update)
|
|
249
248
|
self.tool_to_update.id = str(uuid.uuid4())
|
|
250
249
|
self.tool_to_update.name = str(uuid.uuid4())
|
|
251
250
|
result = self.__update_tool(upsert=True)
|