pygeai 0.5.0__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/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/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 +1 -1
- pygeai/tests/integration/chat/test_generate_image.py +1 -1
- pygeai/tests/integration/lab/agents/test_agents_list.py +1 -1
- pygeai/tests/integration/lab/agents/test_create_agent.py +3 -3
- pygeai/tests/integration/lab/agents/test_create_sharing_link.py +1 -1
- 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 +3 -3
- pygeai/tests/integration/lab/processes/test_create_process.py +1 -1
- 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 +1 -1
- 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 +1 -1
- pygeai/tests/integration/lab/reasoning_strategies/test_get_reasoning_strategy.py +1 -1
- pygeai/tests/integration/lab/reasoning_strategies/test_list_reasoning_strategies.py +1 -1
- pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -1
- pygeai/tests/integration/lab/tools/test_create_tool.py +1 -1
- pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
- pygeai/tests/integration/lab/tools/test_get_parameter.py +1 -1
- pygeai/tests/integration/lab/tools/test_get_tool.py +1 -1
- 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 +1 -1
- 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-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/METADATA +1 -1
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/RECORD +79 -53
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/WHEEL +0 -0
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/entry_points.txt +0 -0
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from unittest.mock import patch, MagicMock, mock_open
|
|
3
|
+
import json
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from pygeai.evaluation.dataset.clients import EvaluationDatasetClient
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TestEvaluationDatasetClient(unittest.TestCase):
|
|
10
|
+
"""
|
|
11
|
+
python -m unittest pygeai.tests.evaluation.dataset.test_clients.TestEvaluationDatasetClient
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def setUp(self):
|
|
15
|
+
self.client = EvaluationDatasetClient()
|
|
16
|
+
self.mock_response = MagicMock()
|
|
17
|
+
self.mock_response.json.return_value = {"id": "dataset-123", "status": "success"}
|
|
18
|
+
|
|
19
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
20
|
+
def test_list_datasets(self, mock_get):
|
|
21
|
+
mock_get.return_value = self.mock_response
|
|
22
|
+
result = self.client.list_datasets()
|
|
23
|
+
mock_get.assert_called_once()
|
|
24
|
+
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
25
|
+
|
|
26
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
27
|
+
def test_create_dataset_minimal(self, mock_post):
|
|
28
|
+
mock_post.return_value = self.mock_response
|
|
29
|
+
result = self.client.create_dataset(
|
|
30
|
+
dataset_name="Test Dataset",
|
|
31
|
+
dataset_description="Test Description",
|
|
32
|
+
dataset_type="T"
|
|
33
|
+
)
|
|
34
|
+
mock_post.assert_called_once()
|
|
35
|
+
call_args = mock_post.call_args
|
|
36
|
+
self.assertEqual(call_args[1]['data']['dataSetName'], "Test Dataset")
|
|
37
|
+
self.assertEqual(call_args[1]['data']['dataSetDescription'], "Test Description")
|
|
38
|
+
self.assertEqual(call_args[1]['data']['dataSetType'], "T")
|
|
39
|
+
self.assertTrue(call_args[1]['data']['dataSetActive'])
|
|
40
|
+
|
|
41
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
42
|
+
def test_create_dataset_with_rows(self, mock_post):
|
|
43
|
+
mock_post.return_value = self.mock_response
|
|
44
|
+
rows = [{"dataSetRowInput": "input1", "dataSetRowExpectedAnswer": "answer1"}]
|
|
45
|
+
result = self.client.create_dataset(
|
|
46
|
+
dataset_name="Test Dataset",
|
|
47
|
+
dataset_description="Test Description",
|
|
48
|
+
dataset_type="T",
|
|
49
|
+
dataset_active=False,
|
|
50
|
+
rows=rows
|
|
51
|
+
)
|
|
52
|
+
mock_post.assert_called_once()
|
|
53
|
+
call_args = mock_post.call_args
|
|
54
|
+
self.assertEqual(call_args[1]['data']['rows'], rows)
|
|
55
|
+
self.assertFalse(call_args[1]['data']['dataSetActive'])
|
|
56
|
+
|
|
57
|
+
@patch('pathlib.Path.is_file')
|
|
58
|
+
@patch('pathlib.Path.open')
|
|
59
|
+
@patch('pygeai.core.services.rest.ApiService.post_file_binary')
|
|
60
|
+
def test_create_dataset_from_file_success(self, mock_post, mock_open_file, mock_is_file):
|
|
61
|
+
mock_is_file.return_value = True
|
|
62
|
+
mock_file = MagicMock()
|
|
63
|
+
mock_open_file.return_value = mock_file
|
|
64
|
+
mock_post.return_value = self.mock_response
|
|
65
|
+
|
|
66
|
+
result = self.client.create_dataset_from_file("/path/to/dataset.json")
|
|
67
|
+
|
|
68
|
+
mock_is_file.assert_called_once()
|
|
69
|
+
mock_open_file.assert_called_once_with("rb")
|
|
70
|
+
mock_post.assert_called_once()
|
|
71
|
+
mock_file.close.assert_called_once()
|
|
72
|
+
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
73
|
+
|
|
74
|
+
@patch('pathlib.Path.is_file')
|
|
75
|
+
def test_create_dataset_from_file_not_found(self, mock_is_file):
|
|
76
|
+
mock_is_file.return_value = False
|
|
77
|
+
with self.assertRaises(FileNotFoundError):
|
|
78
|
+
self.client.create_dataset_from_file("/path/to/nonexistent.json")
|
|
79
|
+
|
|
80
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
81
|
+
def test_get_dataset(self, mock_get):
|
|
82
|
+
mock_get.return_value = self.mock_response
|
|
83
|
+
result = self.client.get_dataset("dataset-123")
|
|
84
|
+
mock_get.assert_called_once()
|
|
85
|
+
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
86
|
+
|
|
87
|
+
@patch('pygeai.core.services.rest.ApiService.put')
|
|
88
|
+
def test_update_dataset(self, mock_put):
|
|
89
|
+
mock_put.return_value = self.mock_response
|
|
90
|
+
rows = [{"dataSetRowInput": "updated"}]
|
|
91
|
+
result = self.client.update_dataset(
|
|
92
|
+
dataset_id="dataset-123",
|
|
93
|
+
dataset_name="Updated Dataset",
|
|
94
|
+
dataset_description="Updated Description",
|
|
95
|
+
dataset_type="E",
|
|
96
|
+
dataset_active=False,
|
|
97
|
+
rows=rows
|
|
98
|
+
)
|
|
99
|
+
mock_put.assert_called_once()
|
|
100
|
+
call_args = mock_put.call_args
|
|
101
|
+
self.assertEqual(call_args[1]['data']['dataSetName'], "Updated Dataset")
|
|
102
|
+
self.assertEqual(call_args[1]['data']['rows'], rows)
|
|
103
|
+
|
|
104
|
+
@patch('pygeai.core.services.rest.ApiService.delete')
|
|
105
|
+
def test_delete_dataset(self, mock_delete):
|
|
106
|
+
mock_delete.return_value = self.mock_response
|
|
107
|
+
result = self.client.delete_dataset("dataset-123")
|
|
108
|
+
mock_delete.assert_called_once()
|
|
109
|
+
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
110
|
+
|
|
111
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
112
|
+
def test_create_dataset_row(self, mock_post):
|
|
113
|
+
mock_post.return_value = self.mock_response
|
|
114
|
+
row = {
|
|
115
|
+
"dataSetRowInput": "input",
|
|
116
|
+
"dataSetRowExpectedAnswer": "answer",
|
|
117
|
+
"dataSetRowContextDocument": "context"
|
|
118
|
+
}
|
|
119
|
+
result = self.client.create_dataset_row("dataset-123", row)
|
|
120
|
+
mock_post.assert_called_once()
|
|
121
|
+
call_args = mock_post.call_args
|
|
122
|
+
self.assertEqual(call_args[1]['data'], row)
|
|
123
|
+
|
|
124
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
125
|
+
def test_list_dataset_rows(self, mock_get):
|
|
126
|
+
mock_get.return_value = self.mock_response
|
|
127
|
+
result = self.client.list_dataset_rows("dataset-123")
|
|
128
|
+
mock_get.assert_called_once()
|
|
129
|
+
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
130
|
+
|
|
131
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
132
|
+
def test_get_dataset_row(self, mock_get):
|
|
133
|
+
mock_get.return_value = self.mock_response
|
|
134
|
+
result = self.client.get_dataset_row("dataset-123", "row-456")
|
|
135
|
+
mock_get.assert_called_once()
|
|
136
|
+
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
137
|
+
|
|
138
|
+
@patch('pygeai.core.services.rest.ApiService.put')
|
|
139
|
+
def test_update_dataset_row(self, mock_put):
|
|
140
|
+
mock_put.return_value = self.mock_response
|
|
141
|
+
row = {"dataSetRowInput": "updated input"}
|
|
142
|
+
result = self.client.update_dataset_row("dataset-123", "row-456", row)
|
|
143
|
+
mock_put.assert_called_once()
|
|
144
|
+
|
|
145
|
+
@patch('pygeai.core.services.rest.ApiService.delete')
|
|
146
|
+
def test_delete_dataset_row(self, mock_delete):
|
|
147
|
+
mock_delete.return_value = self.mock_response
|
|
148
|
+
result = self.client.delete_dataset_row("dataset-123", "row-456")
|
|
149
|
+
mock_delete.assert_called_once()
|
|
150
|
+
|
|
151
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
152
|
+
def test_create_dataset_row_expected_source(self, mock_post):
|
|
153
|
+
mock_post.return_value = self.mock_response
|
|
154
|
+
result = self.client.create_expected_source(
|
|
155
|
+
dataset_id="dataset-123",
|
|
156
|
+
dataset_row_id="row-456",
|
|
157
|
+
expected_source_name="source1",
|
|
158
|
+
expected_source_value="value1",
|
|
159
|
+
expected_source_extension="txt"
|
|
160
|
+
)
|
|
161
|
+
mock_post.assert_called_once()
|
|
162
|
+
|
|
163
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
164
|
+
def test_list_dataset_row_expected_sources(self, mock_get):
|
|
165
|
+
mock_get.return_value = self.mock_response
|
|
166
|
+
result = self.client.list_expected_sources("dataset-123", "row-456")
|
|
167
|
+
mock_get.assert_called_once()
|
|
168
|
+
|
|
169
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
170
|
+
def test_get_expected_source(self, mock_get):
|
|
171
|
+
mock_get.return_value = self.mock_response
|
|
172
|
+
result = self.client.get_expected_source("dataset-123", "row-456", "source-789")
|
|
173
|
+
mock_get.assert_called_once()
|
|
174
|
+
|
|
175
|
+
@patch('pygeai.core.services.rest.ApiService.put')
|
|
176
|
+
def test_update_expected_source(self, mock_put):
|
|
177
|
+
mock_put.return_value = self.mock_response
|
|
178
|
+
result = self.client.update_expected_source(
|
|
179
|
+
dataset_id="dataset-123",
|
|
180
|
+
dataset_row_id="row-456",
|
|
181
|
+
expected_source_id="source-789",
|
|
182
|
+
expected_source_name="updated source",
|
|
183
|
+
expected_source_value="updated value",
|
|
184
|
+
expected_source_extension="pdf"
|
|
185
|
+
)
|
|
186
|
+
mock_put.assert_called_once()
|
|
187
|
+
|
|
188
|
+
@patch('pygeai.core.services.rest.ApiService.delete')
|
|
189
|
+
def test_delete_expected_source(self, mock_delete):
|
|
190
|
+
mock_delete.return_value = self.mock_response
|
|
191
|
+
result = self.client.delete_expected_source("dataset-123", "row-456", "source-789")
|
|
192
|
+
mock_delete.assert_called_once()
|
|
193
|
+
|
|
194
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
195
|
+
def test_create_dataset_row_filter_variable(self, mock_post):
|
|
196
|
+
mock_post.return_value = self.mock_response
|
|
197
|
+
result = self.client.create_filter_variable(
|
|
198
|
+
dataset_id="dataset-123",
|
|
199
|
+
dataset_row_id="row-456",
|
|
200
|
+
metadata_type="type1",
|
|
201
|
+
filter_variable_key="key1",
|
|
202
|
+
filter_variable_value="value1",
|
|
203
|
+
filter_variable_operator="eq"
|
|
204
|
+
)
|
|
205
|
+
mock_post.assert_called_once()
|
|
206
|
+
|
|
207
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
208
|
+
def test_list_dataset_row_filter_variables(self, mock_get):
|
|
209
|
+
mock_get.return_value = self.mock_response
|
|
210
|
+
result = self.client.list_filter_variables("dataset-123", "row-456")
|
|
211
|
+
mock_get.assert_called_once()
|
|
212
|
+
|
|
213
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
214
|
+
def test_get_filter_variable(self, mock_get):
|
|
215
|
+
mock_get.return_value = self.mock_response
|
|
216
|
+
result = self.client.get_filter_variable("dataset-123", "row-456", "var-789")
|
|
217
|
+
mock_get.assert_called_once()
|
|
218
|
+
|
|
219
|
+
@patch('pygeai.core.services.rest.ApiService.put')
|
|
220
|
+
def test_update_filter_variable(self, mock_put):
|
|
221
|
+
mock_put.return_value = self.mock_response
|
|
222
|
+
result = self.client.update_filter_variable(
|
|
223
|
+
dataset_id="dataset-123",
|
|
224
|
+
dataset_row_id="row-456",
|
|
225
|
+
filter_variable_id="var-789",
|
|
226
|
+
metadata_type="type2",
|
|
227
|
+
filter_variable_key="updated key",
|
|
228
|
+
filter_variable_value="updated value",
|
|
229
|
+
filter_variable_operator="ne"
|
|
230
|
+
)
|
|
231
|
+
mock_put.assert_called_once()
|
|
232
|
+
|
|
233
|
+
@patch('pygeai.core.services.rest.ApiService.delete')
|
|
234
|
+
def test_delete_filter_variable(self, mock_delete):
|
|
235
|
+
mock_delete.return_value = self.mock_response
|
|
236
|
+
result = self.client.delete_filter_variable("dataset-123", "row-456", "var-789")
|
|
237
|
+
mock_delete.assert_called_once()
|
|
238
|
+
|
|
239
|
+
@patch('pathlib.Path.is_file')
|
|
240
|
+
@patch('pathlib.Path.open')
|
|
241
|
+
@patch('pygeai.core.services.rest.ApiService.post_file_binary')
|
|
242
|
+
def test_upload_dataset_rows_file_success(self, mock_post, mock_open_file, mock_is_file):
|
|
243
|
+
mock_is_file.return_value = True
|
|
244
|
+
mock_file = MagicMock()
|
|
245
|
+
mock_open_file.return_value = mock_file
|
|
246
|
+
mock_post.return_value = self.mock_response
|
|
247
|
+
|
|
248
|
+
result = self.client.upload_dataset_rows_file("dataset-123", "/path/to/rows.json")
|
|
249
|
+
|
|
250
|
+
mock_is_file.assert_called_once()
|
|
251
|
+
mock_open_file.assert_called_once_with("rb")
|
|
252
|
+
mock_post.assert_called_once()
|
|
253
|
+
mock_file.close.assert_called_once()
|
|
254
|
+
|
|
255
|
+
@patch('pathlib.Path.is_file')
|
|
256
|
+
def test_upload_dataset_rows_file_not_found(self, mock_is_file):
|
|
257
|
+
mock_is_file.return_value = False
|
|
258
|
+
with self.assertRaises(FileNotFoundError):
|
|
259
|
+
self.client.upload_dataset_rows_file("dataset-123", "/path/to/nonexistent.json")
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
if __name__ == '__main__':
|
|
263
|
+
unittest.main()
|
|
File without changes
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from unittest.mock import patch, MagicMock
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
from pygeai.evaluation.plan.clients import EvaluationPlanClient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestEvaluationPlanClient(unittest.TestCase):
|
|
9
|
+
"""
|
|
10
|
+
python -m unittest pygeai.tests.evaluation.plan.test_clients.TestEvaluationPlanClient
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def setUp(self):
|
|
14
|
+
self.client = EvaluationPlanClient()
|
|
15
|
+
self.mock_response = MagicMock()
|
|
16
|
+
self.mock_response.content = json.dumps({"id": "plan-123", "status": "success"})
|
|
17
|
+
|
|
18
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
19
|
+
def test_list_evaluation_plans(self, mock_get):
|
|
20
|
+
mock_get.return_value = self.mock_response
|
|
21
|
+
result = self.client.list_evaluation_plans()
|
|
22
|
+
mock_get.assert_called_once()
|
|
23
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
24
|
+
|
|
25
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
26
|
+
def test_create_evaluation_plan_minimal(self, mock_post):
|
|
27
|
+
mock_post.return_value = self.mock_response
|
|
28
|
+
result = self.client.create_evaluation_plan(
|
|
29
|
+
name="Test Plan",
|
|
30
|
+
type="TextPromptAssistant"
|
|
31
|
+
)
|
|
32
|
+
mock_post.assert_called_once()
|
|
33
|
+
call_args = mock_post.call_args
|
|
34
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanName'], "Test Plan")
|
|
35
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanType'], "TextPromptAssistant")
|
|
36
|
+
|
|
37
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
38
|
+
def test_create_evaluation_plan_with_assistant(self, mock_post):
|
|
39
|
+
mock_post.return_value = self.mock_response
|
|
40
|
+
result = self.client.create_evaluation_plan(
|
|
41
|
+
name="Test Plan",
|
|
42
|
+
type="TextPromptAssistant",
|
|
43
|
+
assistant_id="asst-123",
|
|
44
|
+
assistant_name="Test Assistant",
|
|
45
|
+
assistant_revision="1.0"
|
|
46
|
+
)
|
|
47
|
+
mock_post.assert_called_once()
|
|
48
|
+
call_args = mock_post.call_args
|
|
49
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanAssistantId'], "asst-123")
|
|
50
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanAssistantName'], "Test Assistant")
|
|
51
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanAssistantRevision'], "1.0")
|
|
52
|
+
|
|
53
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
54
|
+
def test_create_evaluation_plan_with_all_params(self, mock_post):
|
|
55
|
+
mock_post.return_value = self.mock_response
|
|
56
|
+
system_metrics = [{"systemMetricId": "metric-1", "systemMetricWeight": 0.5}]
|
|
57
|
+
result = self.client.create_evaluation_plan(
|
|
58
|
+
name="Test Plan",
|
|
59
|
+
type="RAG Assistant",
|
|
60
|
+
profile_name="Test Profile",
|
|
61
|
+
dataset_id="dataset-123",
|
|
62
|
+
system_metrics=system_metrics
|
|
63
|
+
)
|
|
64
|
+
mock_post.assert_called_once()
|
|
65
|
+
call_args = mock_post.call_args
|
|
66
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanProfileName'], "Test Profile")
|
|
67
|
+
self.assertEqual(call_args[1]['data']['dataSetId'], "dataset-123")
|
|
68
|
+
self.assertEqual(call_args[1]['data']['systemMetrics'], system_metrics)
|
|
69
|
+
|
|
70
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
71
|
+
def test_get_evaluation_plan(self, mock_get):
|
|
72
|
+
mock_get.return_value = self.mock_response
|
|
73
|
+
result = self.client.get_evaluation_plan("plan-123")
|
|
74
|
+
mock_get.assert_called_once()
|
|
75
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
76
|
+
|
|
77
|
+
@patch('pygeai.core.services.rest.ApiService.put')
|
|
78
|
+
def test_update_evaluation_plan_name_only(self, mock_put):
|
|
79
|
+
mock_put.return_value = self.mock_response
|
|
80
|
+
result = self.client.update_evaluation_plan(
|
|
81
|
+
evaluation_plan_id="plan-123",
|
|
82
|
+
name="Updated Plan"
|
|
83
|
+
)
|
|
84
|
+
mock_put.assert_called_once()
|
|
85
|
+
call_args = mock_put.call_args
|
|
86
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanName'], "Updated Plan")
|
|
87
|
+
self.assertEqual(len(call_args[1]['data']), 1)
|
|
88
|
+
|
|
89
|
+
@patch('pygeai.core.services.rest.ApiService.put')
|
|
90
|
+
def test_update_evaluation_plan_multiple_fields(self, mock_put):
|
|
91
|
+
mock_put.return_value = self.mock_response
|
|
92
|
+
system_metrics = [{"systemMetricId": "metric-1", "systemMetricWeight": 0.8}]
|
|
93
|
+
result = self.client.update_evaluation_plan(
|
|
94
|
+
evaluation_plan_id="plan-123",
|
|
95
|
+
name="Updated Plan",
|
|
96
|
+
type="RAG Assistant",
|
|
97
|
+
assistant_id="asst-456",
|
|
98
|
+
assistant_name="Updated Assistant",
|
|
99
|
+
assistant_revision="2.0",
|
|
100
|
+
profile_name="Updated Profile",
|
|
101
|
+
dataset_id="dataset-456",
|
|
102
|
+
system_metrics=system_metrics
|
|
103
|
+
)
|
|
104
|
+
mock_put.assert_called_once()
|
|
105
|
+
call_args = mock_put.call_args
|
|
106
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanName'], "Updated Plan")
|
|
107
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanType'], "RAG Assistant")
|
|
108
|
+
self.assertEqual(call_args[1]['data']['evaluationPlanAssistantId'], "asst-456")
|
|
109
|
+
self.assertEqual(call_args[1]['data']['systemMetrics'], system_metrics)
|
|
110
|
+
|
|
111
|
+
@patch('pygeai.core.services.rest.ApiService.delete')
|
|
112
|
+
def test_delete_evaluation_plan(self, mock_delete):
|
|
113
|
+
mock_delete.return_value = self.mock_response
|
|
114
|
+
result = self.client.delete_evaluation_plan("plan-123")
|
|
115
|
+
mock_delete.assert_called_once()
|
|
116
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
117
|
+
|
|
118
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
119
|
+
def test_list_evaluation_plan_system_metrics(self, mock_get):
|
|
120
|
+
mock_get.return_value = self.mock_response
|
|
121
|
+
result = self.client.list_evaluation_plan_system_metrics("plan-123")
|
|
122
|
+
mock_get.assert_called_once()
|
|
123
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
124
|
+
|
|
125
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
126
|
+
def test_add_evaluation_plan_system_metric(self, mock_post):
|
|
127
|
+
mock_post.return_value = self.mock_response
|
|
128
|
+
result = self.client.add_evaluation_plan_system_metric(
|
|
129
|
+
evaluation_plan_id="plan-123",
|
|
130
|
+
system_metric_id="metric-456",
|
|
131
|
+
system_metric_weight=0.75
|
|
132
|
+
)
|
|
133
|
+
mock_post.assert_called_once()
|
|
134
|
+
call_args = mock_post.call_args
|
|
135
|
+
self.assertEqual(call_args[1]['data']['systemMetricId'], "metric-456")
|
|
136
|
+
self.assertEqual(call_args[1]['data']['systemMetricWeight'], 0.75)
|
|
137
|
+
|
|
138
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
139
|
+
def test_get_evaluation_plan_system_metric(self, mock_get):
|
|
140
|
+
mock_get.return_value = self.mock_response
|
|
141
|
+
result = self.client.get_evaluation_plan_system_metric(
|
|
142
|
+
evaluation_plan_id="plan-123",
|
|
143
|
+
system_metric_id="metric-456"
|
|
144
|
+
)
|
|
145
|
+
mock_get.assert_called_once()
|
|
146
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
147
|
+
|
|
148
|
+
@patch('pygeai.core.services.rest.ApiService.put')
|
|
149
|
+
def test_update_evaluation_plan_system_metric(self, mock_put):
|
|
150
|
+
mock_put.return_value = self.mock_response
|
|
151
|
+
result = self.client.update_evaluation_plan_system_metric(
|
|
152
|
+
evaluation_plan_id="plan-123",
|
|
153
|
+
system_metric_id="metric-456",
|
|
154
|
+
system_metric_weight=0.9
|
|
155
|
+
)
|
|
156
|
+
mock_put.assert_called_once()
|
|
157
|
+
call_args = mock_put.call_args
|
|
158
|
+
self.assertEqual(call_args[1]['data']['systemMetricWeight'], 0.9)
|
|
159
|
+
|
|
160
|
+
@patch('pygeai.core.services.rest.ApiService.delete')
|
|
161
|
+
def test_delete_evaluation_plan_system_metric(self, mock_delete):
|
|
162
|
+
mock_delete.return_value = self.mock_response
|
|
163
|
+
result = self.client.delete_evaluation_plan_system_metric(
|
|
164
|
+
evaluation_plan_id="plan-123",
|
|
165
|
+
system_metric_id="metric-456"
|
|
166
|
+
)
|
|
167
|
+
mock_delete.assert_called_once()
|
|
168
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
169
|
+
|
|
170
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
171
|
+
def test_list_system_metrics(self, mock_get):
|
|
172
|
+
mock_get.return_value = self.mock_response
|
|
173
|
+
result = self.client.list_system_metrics()
|
|
174
|
+
mock_get.assert_called_once()
|
|
175
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
176
|
+
|
|
177
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
178
|
+
def test_get_system_metric(self, mock_get):
|
|
179
|
+
mock_get.return_value = self.mock_response
|
|
180
|
+
result = self.client.get_system_metric("metric-456")
|
|
181
|
+
mock_get.assert_called_once()
|
|
182
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
183
|
+
|
|
184
|
+
@patch('pygeai.core.services.rest.ApiService.post')
|
|
185
|
+
def test_execute_evaluation_plan(self, mock_post):
|
|
186
|
+
mock_post.return_value = self.mock_response
|
|
187
|
+
result = self.client.execute_evaluation_plan("plan-123")
|
|
188
|
+
mock_post.assert_called_once()
|
|
189
|
+
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
if __name__ == '__main__':
|
|
193
|
+
unittest.main()
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
from unittest.mock import patch, MagicMock
|
|
3
|
+
|
|
4
|
+
from pygeai.evaluation.result.clients import EvaluationResultClient
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TestEvaluationResultClient(unittest.TestCase):
|
|
8
|
+
"""
|
|
9
|
+
python -m unittest pygeai.tests.evaluation.result.test_clients.TestEvaluationResultClient
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def setUp(self):
|
|
13
|
+
self.client = EvaluationResultClient()
|
|
14
|
+
self.mock_response = MagicMock()
|
|
15
|
+
|
|
16
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
17
|
+
def test_list_evaluation_results_success(self, mock_get):
|
|
18
|
+
self.mock_response.content = b'[{"id": "result-1", "status": "completed"}, {"id": "result-2", "status": "pending"}]'
|
|
19
|
+
mock_get.return_value = self.mock_response
|
|
20
|
+
|
|
21
|
+
result = self.client.list_evaluation_results("plan-123")
|
|
22
|
+
|
|
23
|
+
mock_get.assert_called_once()
|
|
24
|
+
self.assertEqual(len(result), 2)
|
|
25
|
+
self.assertEqual(result[0]["id"], "result-1")
|
|
26
|
+
self.assertEqual(result[1]["id"], "result-2")
|
|
27
|
+
|
|
28
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
29
|
+
def test_list_evaluation_results_empty(self, mock_get):
|
|
30
|
+
self.mock_response.content = b'[]'
|
|
31
|
+
mock_get.return_value = self.mock_response
|
|
32
|
+
|
|
33
|
+
result = self.client.list_evaluation_results("plan-456")
|
|
34
|
+
|
|
35
|
+
mock_get.assert_called_once()
|
|
36
|
+
self.assertEqual(result, [])
|
|
37
|
+
|
|
38
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
39
|
+
def test_get_evaluation_result_success(self, mock_get):
|
|
40
|
+
self.mock_response.content = b'{"id": "result-123", "status": "completed", "score": 0.95}'
|
|
41
|
+
mock_get.return_value = self.mock_response
|
|
42
|
+
|
|
43
|
+
result = self.client.get_evaluation_result("result-123")
|
|
44
|
+
|
|
45
|
+
mock_get.assert_called_once()
|
|
46
|
+
self.assertEqual(result["id"], "result-123")
|
|
47
|
+
self.assertEqual(result["status"], "completed")
|
|
48
|
+
self.assertEqual(result["score"], 0.95)
|
|
49
|
+
|
|
50
|
+
@patch('pygeai.core.services.rest.ApiService.get')
|
|
51
|
+
def test_get_evaluation_result_with_details(self, mock_get):
|
|
52
|
+
self.mock_response.content = b'{"id": "result-789", "status": "failed", "error": "Test error"}'
|
|
53
|
+
mock_get.return_value = self.mock_response
|
|
54
|
+
|
|
55
|
+
result = self.client.get_evaluation_result("result-789")
|
|
56
|
+
|
|
57
|
+
mock_get.assert_called_once()
|
|
58
|
+
self.assertEqual(result["id"], "result-789")
|
|
59
|
+
self.assertEqual(result["status"], "failed")
|
|
60
|
+
self.assertEqual(result["error"], "Test error")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
if __name__ == '__main__':
|
|
64
|
+
unittest.main()
|
|
@@ -18,7 +18,7 @@ class TestAssistantCreateRagIntegration(TestCase):
|
|
|
18
18
|
"""
|
|
19
19
|
Set up the test environment.
|
|
20
20
|
"""
|
|
21
|
-
self.assistant_manager = AssistantManager(
|
|
21
|
+
self.assistant_manager = AssistantManager()
|
|
22
22
|
|
|
23
23
|
self.new_rag = self.__load_rag()
|
|
24
24
|
self.created_rag: RAGAssistant = None
|
|
@@ -12,7 +12,7 @@ class TestAILabCreateAgentIntegration(TestCase):
|
|
|
12
12
|
"""
|
|
13
13
|
Set up the test environment.
|
|
14
14
|
"""
|
|
15
|
-
self.ai_lab_manager = AILabManager(
|
|
15
|
+
self.ai_lab_manager = AILabManager()
|
|
16
16
|
self.new_agent = self.__load_agent()
|
|
17
17
|
self.created_agent: Agent = None
|
|
18
18
|
|
|
@@ -51,7 +51,7 @@ class TestAILabCreateAgentIntegration(TestCase):
|
|
|
51
51
|
timeout=0,
|
|
52
52
|
sampling=Sampling(temperature=0.3, top_k=0, top_p=0)
|
|
53
53
|
),
|
|
54
|
-
models=[Model(name="gpt-
|
|
54
|
+
models=[Model(name="gpt-4o")]
|
|
55
55
|
)
|
|
56
56
|
)
|
|
57
57
|
|
|
@@ -118,7 +118,7 @@ class TestAILabCreateAgentIntegration(TestCase):
|
|
|
118
118
|
max_tokens=1800,
|
|
119
119
|
timeout=0
|
|
120
120
|
),
|
|
121
|
-
models=[Model(name="gpt-
|
|
121
|
+
models=[Model(name="gpt-4o")]
|
|
122
122
|
)
|
|
123
123
|
)
|
|
124
124
|
self.created_agent = self.__create_agent()
|
|
@@ -9,7 +9,7 @@ ai_lab_manager: AILabManager
|
|
|
9
9
|
class TestAILabCreateSharingLinkIntegration(TestCase):
|
|
10
10
|
|
|
11
11
|
def setUp(self):
|
|
12
|
-
self.ai_lab_manager = AILabManager(
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
13
13
|
self.agent_id = "0026e53d-ea78-4cac-af9f-12650e5bb6d9"
|
|
14
14
|
|
|
15
15
|
def __create_sharing_link(self, agent_id=None):
|
|
@@ -9,7 +9,7 @@ ai_lab_manager: AILabManager
|
|
|
9
9
|
class TestAILabDeleteAgentIntegration(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_agent(self):
|
|
@@ -29,7 +29,7 @@ class TestAILabDeleteAgentIntegration(TestCase):
|
|
|
29
29
|
max_tokens=1800,
|
|
30
30
|
timeout=0
|
|
31
31
|
),
|
|
32
|
-
models=[Model(name="gpt-
|
|
32
|
+
models=[Model(name="gpt-4o")]
|
|
33
33
|
)
|
|
34
34
|
)
|
|
35
35
|
|
|
@@ -14,7 +14,7 @@ class TestAILabGetAgentIntegration(TestCase):
|
|
|
14
14
|
]
|
|
15
15
|
|
|
16
16
|
def setUp(self):
|
|
17
|
-
self.ai_lab_manager = AILabManager(
|
|
17
|
+
self.ai_lab_manager = AILabManager()
|
|
18
18
|
self.agent_id = "0026e53d-ea78-4cac-af9f-12650e5bb6d9"
|
|
19
19
|
self.filter_settings = FilterSettings(
|
|
20
20
|
revision="0",
|
|
@@ -9,7 +9,7 @@ ai_lab_manager: AILabManager
|
|
|
9
9
|
class TestAILabPublishAgentRevisionIntegration(TestCase):
|
|
10
10
|
|
|
11
11
|
def setUp(self):
|
|
12
|
-
self.ai_lab_manager = AILabManager(
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
13
13
|
self.agent_id = "b4b09935-2ad2-42c0-bd55-1ee6fa4b6034"
|
|
14
14
|
|
|
15
15
|
|
|
@@ -46,7 +46,7 @@ class TestAILabPublishAgentRevisionIntegration(TestCase):
|
|
|
46
46
|
timeout=0,
|
|
47
47
|
sampling=Sampling(temperature=0.3, top_k=0, top_p=0)
|
|
48
48
|
),
|
|
49
|
-
models=[Model(name="openai/gpt-
|
|
49
|
+
models=[Model(name="openai/gpt-4o")]
|
|
50
50
|
)
|
|
51
51
|
)
|
|
52
52
|
|
|
@@ -11,7 +11,7 @@ class TestAILabUpdateAgentIntegration(TestCase):
|
|
|
11
11
|
"""
|
|
12
12
|
Set up the test environment.
|
|
13
13
|
"""
|
|
14
|
-
self.ai_lab_manager = AILabManager(
|
|
14
|
+
self.ai_lab_manager = AILabManager()
|
|
15
15
|
|
|
16
16
|
load_agent = self.__load_agent()
|
|
17
17
|
self.agent_to_update = load_agent["agent"]
|
|
@@ -43,7 +43,7 @@ class TestAILabUpdateAgentIntegration(TestCase):
|
|
|
43
43
|
timeout=0,
|
|
44
44
|
sampling=Sampling(temperature=0.3, top_k=0, top_p=0)
|
|
45
45
|
),
|
|
46
|
-
models=[Model(name="openai/gpt-
|
|
46
|
+
models=[Model(name="openai/gpt-4o")]
|
|
47
47
|
)
|
|
48
48
|
)
|
|
49
49
|
|
|
@@ -81,7 +81,7 @@ class TestAILabUpdateAgentIntegration(TestCase):
|
|
|
81
81
|
self.assertEqual(updated_agent.agent_data.models[0].name, "gemini/gemini-1.5-flash-8b-exp-0827")
|
|
82
82
|
self.assertTrue(updated_agent.is_draft, "gemini/gemini-1.5-flash-8b-exp-0827")
|
|
83
83
|
|
|
84
|
-
self.agent_to_update.agent_data.models[0].name = "openai/gpt-
|
|
84
|
+
self.agent_to_update.agent_data.models[0].name = "openai/gpt-4o"
|
|
85
85
|
self.__update_agent()
|
|
86
86
|
|
|
87
87
|
|