pygeai 0.6.0b13__py3-none-any.whl → 0.6.1__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 -2
- pygeai/_docs/source/content/api_reference/project.rst +392 -0
- pygeai/_docs/source/content/authentication.rst +130 -1
- pygeai/_docs/source/content/debugger.rst +327 -157
- pygeai/_docs/source/content/migration.rst +391 -7
- pygeai/_docs/source/pygeai.core.common.rst +8 -0
- pygeai/_docs/source/pygeai.tests.auth.rst +56 -0
- pygeai/_docs/source/pygeai.tests.cli.rst +8 -0
- pygeai/admin/clients.py +1 -3
- pygeai/analytics/clients.py +1 -1
- pygeai/assistant/clients.py +2 -7
- pygeai/assistant/data/clients.py +0 -8
- pygeai/assistant/data_analyst/clients.py +0 -2
- pygeai/assistant/managers.py +1 -1
- pygeai/assistant/rag/clients.py +0 -2
- pygeai/assistant/rag/mappers.py +9 -11
- pygeai/auth/clients.py +26 -7
- pygeai/auth/endpoints.py +2 -1
- pygeai/chat/clients.py +2 -2
- pygeai/chat/managers.py +1 -1
- pygeai/cli/commands/admin.py +13 -25
- pygeai/cli/commands/analytics.py +56 -88
- pygeai/cli/commands/assistant.py +84 -138
- pygeai/cli/commands/auth.py +23 -46
- pygeai/cli/commands/base.py +0 -1
- pygeai/cli/commands/chat.py +218 -209
- pygeai/cli/commands/common.py +5 -5
- pygeai/cli/commands/configuration.py +79 -29
- pygeai/cli/commands/docs.py +3 -4
- pygeai/cli/commands/embeddings.py +13 -19
- pygeai/cli/commands/evaluation.py +133 -344
- pygeai/cli/commands/feedback.py +7 -15
- pygeai/cli/commands/files.py +26 -53
- pygeai/cli/commands/gam.py +28 -69
- pygeai/cli/commands/lab/ai_lab.py +96 -142
- pygeai/cli/commands/lab/common.py +1 -1
- pygeai/cli/commands/lab/spec.py +12 -32
- pygeai/cli/commands/llm.py +9 -18
- pygeai/cli/commands/migrate.py +43 -99
- pygeai/cli/commands/organization.py +223 -196
- pygeai/cli/commands/rag.py +35 -58
- pygeai/cli/commands/rerank.py +21 -25
- pygeai/cli/commands/secrets.py +39 -67
- pygeai/cli/commands/usage_limits.py +50 -136
- pygeai/cli/commands/validators.py +1 -1
- pygeai/cli/geai.py +32 -3
- pygeai/cli/geai_proxy.py +6 -2
- pygeai/cli/install_man.py +1 -1
- pygeai/cli/parsers.py +1 -1
- pygeai/core/base/clients.py +90 -21
- pygeai/core/base/mappers.py +39 -55
- pygeai/core/base/session.py +134 -22
- pygeai/core/common/config.py +50 -13
- pygeai/core/common/constants.py +8 -0
- pygeai/core/common/exceptions.py +6 -0
- pygeai/core/embeddings/clients.py +0 -1
- pygeai/core/embeddings/managers.py +0 -1
- pygeai/core/feedback/clients.py +0 -2
- pygeai/core/feedback/models.py +1 -1
- pygeai/core/files/clients.py +0 -3
- pygeai/core/files/managers.py +1 -1
- pygeai/core/files/mappers.py +4 -5
- pygeai/core/llm/clients.py +0 -1
- pygeai/core/models.py +4 -4
- pygeai/core/plugins/clients.py +0 -3
- pygeai/core/plugins/models.py +2 -2
- pygeai/core/rerank/clients.py +0 -2
- pygeai/core/secrets/clients.py +0 -2
- pygeai/core/services/rest.py +80 -14
- pygeai/core/singleton.py +24 -0
- pygeai/dbg/__init__.py +2 -2
- pygeai/dbg/debugger.py +276 -38
- pygeai/evaluation/clients.py +2 -4
- pygeai/evaluation/dataset/clients.py +0 -1
- pygeai/evaluation/plan/clients.py +0 -2
- pygeai/evaluation/result/clients.py +0 -2
- pygeai/gam/clients.py +1 -3
- pygeai/health/clients.py +1 -3
- pygeai/lab/clients.py +0 -1
- pygeai/lab/managers.py +0 -1
- pygeai/lab/models.py +0 -1
- pygeai/lab/strategies/clients.py +1 -2
- pygeai/lab/tools/clients.py +2 -2
- pygeai/lab/tools/mappers.py +1 -1
- pygeai/migration/strategies.py +5 -6
- pygeai/migration/tools.py +1 -1
- pygeai/organization/clients.py +118 -12
- pygeai/organization/endpoints.py +1 -0
- pygeai/organization/limits/clients.py +4 -6
- pygeai/organization/limits/managers.py +1 -4
- pygeai/organization/managers.py +2 -2
- pygeai/proxy/config.py +1 -0
- pygeai/proxy/managers.py +6 -5
- pygeai/tests/admin/test_clients.py +11 -11
- pygeai/tests/assistants/rag/test_clients.py +1 -1
- pygeai/tests/assistants/rag/test_models.py +1 -2
- pygeai/tests/assistants/test_clients.py +1 -1
- pygeai/tests/assistants/test_managers.py +1 -3
- pygeai/tests/auth/test_cli_configuration.py +252 -0
- pygeai/tests/auth/test_client_initialization.py +411 -0
- pygeai/tests/auth/test_clients.py +29 -27
- pygeai/tests/auth/test_config_manager.py +305 -0
- pygeai/tests/auth/test_header_injection.py +294 -0
- pygeai/tests/auth/test_oauth.py +3 -1
- pygeai/tests/auth/test_session_logging.py +119 -0
- pygeai/tests/auth/test_session_validation.py +408 -0
- pygeai/tests/auth/test_singleton_reset.py +201 -0
- pygeai/tests/chat/test_clients.py +1 -1
- pygeai/tests/chat/test_iris.py +1 -1
- pygeai/tests/chat/test_ui.py +0 -2
- pygeai/tests/cli/commands/lab/test_ai_lab.py +1 -3
- pygeai/tests/cli/commands/lab/test_common.py +0 -1
- pygeai/tests/cli/commands/test_chat.py +1 -1
- pygeai/tests/cli/commands/test_common.py +0 -1
- pygeai/tests/cli/commands/test_embeddings.py +2 -2
- pygeai/tests/cli/commands/test_evaluation.py +1 -9
- pygeai/tests/cli/commands/test_llm.py +1 -1
- pygeai/tests/cli/commands/test_migrate.py +1 -1
- pygeai/tests/cli/commands/test_rerank.py +0 -1
- pygeai/tests/cli/commands/test_secrets.py +1 -1
- pygeai/tests/cli/commands/test_show_help.py +0 -1
- pygeai/tests/cli/commands/test_validators.py +0 -1
- pygeai/tests/cli/test_credentials_flag.py +312 -0
- pygeai/tests/cli/test_error_handler.py +0 -1
- pygeai/tests/core/base/test_mappers.py +2 -2
- pygeai/tests/core/base/test_models.py +4 -4
- pygeai/tests/core/common/test_config.py +2 -7
- pygeai/tests/core/common/test_decorators.py +0 -1
- pygeai/tests/core/embeddings/test_managers.py +1 -1
- pygeai/tests/core/feedback/test_clients.py +2 -2
- pygeai/tests/core/files/test_clients.py +6 -6
- pygeai/tests/core/files/test_models.py +0 -1
- pygeai/tests/core/files/test_responses.py +0 -1
- pygeai/tests/core/llm/test_clients.py +1 -1
- pygeai/tests/core/plugins/test_clients.py +4 -4
- pygeai/tests/core/rerank/test_mappers.py +1 -3
- pygeai/tests/core/secrets/test_clients.py +2 -3
- pygeai/tests/core/services/test_rest.py +10 -10
- pygeai/tests/core/utils/test_console.py +0 -1
- pygeai/tests/dbg/test_debugger.py +95 -8
- pygeai/tests/evaluation/dataset/test_clients.py +24 -27
- pygeai/tests/evaluation/plan/test_clients.py +16 -18
- pygeai/tests/evaluation/result/test_clients.py +4 -5
- pygeai/tests/health/test_clients.py +2 -2
- pygeai/tests/integration/lab/agents/test_create_agent.py +1 -3
- pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
- pygeai/tests/integration/lab/processes/test_create_process.py +2 -2
- pygeai/tests/integration/lab/processes/test_create_task.py +2 -3
- pygeai/tests/integration/lab/processes/test_delete_process.py +0 -1
- pygeai/tests/integration/lab/processes/test_get_process.py +2 -4
- pygeai/tests/integration/lab/processes/test_list_process_instances.py +1 -3
- pygeai/tests/integration/lab/processes/test_update_process.py +3 -9
- pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -2
- pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
- pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
- pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
- pygeai/tests/lab/agents/test_clients.py +17 -17
- pygeai/tests/lab/processes/test_clients.py +67 -67
- pygeai/tests/lab/processes/test_mappers.py +23 -23
- pygeai/tests/lab/spec/test_loader.py +0 -2
- pygeai/tests/lab/spec/test_parsers.py +1 -2
- pygeai/tests/lab/strategies/test_clients.py +10 -10
- pygeai/tests/lab/test_managers.py +3 -5
- pygeai/tests/lab/test_mappers.py +1 -4
- pygeai/tests/lab/tools/test_clients.py +21 -21
- pygeai/tests/lab/tools/test_mappers.py +0 -1
- pygeai/tests/organization/limits/test_clients.py +33 -33
- pygeai/tests/organization/limits/test_managers.py +7 -7
- pygeai/tests/organization/test_clients.py +78 -60
- pygeai/tests/proxy/test_clients.py +1 -1
- pygeai/tests/proxy/test_integration.py +1 -4
- pygeai/tests/proxy/test_managers.py +1 -2
- pygeai/tests/proxy/test_servers.py +1 -2
- pygeai/tests/snippets/assistants/rag/delete_rag_assistant.py +0 -1
- pygeai/tests/snippets/assistants/rag/get_documents.py +0 -1
- pygeai/tests/snippets/assistants/rag/get_rag_assistant_data.py +0 -1
- pygeai/tests/snippets/chat/get_request_status.py +0 -1
- pygeai/tests/snippets/dbg/file_debugging.py +72 -0
- pygeai/tests/snippets/dbg/module_debugging.py +60 -0
- pygeai/tests/snippets/embeddings/cohere_example.py +2 -2
- pygeai/tests/snippets/embeddings/openai_base64_example.py +1 -1
- pygeai/tests/snippets/evaluation/dataset/complete_workflow_example.py +8 -8
- pygeai/tests/snippets/evaluation/plan/complete_workflow_example.py +5 -5
- pygeai/tests/snippets/evaluation/result/complete_workflow_example.py +3 -3
- pygeai/tests/snippets/lab/agentic_flow_example_1.py +1 -1
- pygeai/tests/snippets/lab/agentic_flow_example_2.py +3 -4
- pygeai/tests/snippets/lab/agents/create_agent_with_permissions.py +2 -2
- pygeai/tests/snippets/lab/agents/delete_agent.py +1 -2
- pygeai/tests/snippets/lab/agents/get_agent.py +1 -1
- pygeai/tests/snippets/lab/agents/get_agent_with_new_fields.py +10 -10
- pygeai/tests/snippets/lab/agents/get_sharing_link.py +0 -1
- pygeai/tests/snippets/lab/agents/list_agents.py +1 -1
- pygeai/tests/snippets/lab/agents/publish_agent_revision.py +0 -1
- pygeai/tests/snippets/lab/agents/update_agent_properties.py +1 -1
- pygeai/tests/snippets/lab/crud_ui.py +3 -5
- pygeai/tests/snippets/lab/processes/kbs/get_kb.py +0 -1
- pygeai/tests/snippets/lab/processes/kbs/list_kbs.py +0 -1
- pygeai/tests/snippets/lab/processes/list_processes.py +1 -1
- pygeai/tests/snippets/lab/samples/summarize_files.py +0 -3
- pygeai/tests/snippets/lab/strategies/get_reasoning_strategy.py +0 -1
- pygeai/tests/snippets/lab/strategies/list_reasoning_strategies.py +1 -1
- pygeai/tests/snippets/lab/tools/get_tool.py +1 -1
- pygeai/tests/snippets/lab/tools/publish_tool_revision.py +0 -1
- pygeai/tests/snippets/lab/tools/set_parameters.py +1 -2
- pygeai/tests/snippets/lab/use_cases/c_code_fixer_agent_flow.py +2 -3
- pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +1 -1
- pygeai/tests/snippets/lab/use_cases/update_cli_expert.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_lab_expert.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_web_designer.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_web_reader.py +0 -1
- pygeai/tests/snippets/migrate/orchestrator_examples.py +1 -1
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/METADATA +32 -7
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/RECORD +217 -206
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/WHEEL +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/entry_points.txt +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/top_level.txt +0 -0
pygeai/migration/tools.py
CHANGED
pygeai/organization/clients.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
1
|
from pygeai import logger
|
|
3
|
-
from pygeai.
|
|
2
|
+
from pygeai.admin.clients import AdminClient
|
|
3
|
+
from pygeai.core.common.exceptions import APIError
|
|
4
4
|
from pygeai.organization.endpoints import GET_ASSISTANT_LIST_V1, GET_PROJECT_LIST_V1, GET_PROJECT_V1, \
|
|
5
5
|
CREATE_PROJECT_V1, UPDATE_PROJECT_V1, DELETE_PROJECT_V1, GET_PROJECT_TOKENS_V1, GET_REQUEST_DATA_V1, \
|
|
6
6
|
GET_MEMBERSHIPS_V2, GET_PROJECT_MEMBERSHIPS_V2, GET_PROJECT_ROLES_V2, GET_PROJECT_MEMBERS_V2, \
|
|
7
|
-
GET_ORGANIZATION_MEMBERS_V2, ADD_PROJECT_MEMBER_V2, CREATE_ORGANIZATION_V2,
|
|
8
|
-
DELETE_ORGANIZATION_V2
|
|
7
|
+
GET_ORGANIZATION_MEMBERS_V2, GET_PLUGIN_RUNTIME_POLICIES_V2, ADD_PROJECT_MEMBER_V2, CREATE_ORGANIZATION_V2, \
|
|
8
|
+
GET_ORGANIZATION_LIST_V2, DELETE_ORGANIZATION_V2
|
|
9
9
|
from pygeai.core.base.clients import BaseClient
|
|
10
10
|
from pygeai.core.utils.validators import validate_status_code
|
|
11
11
|
from pygeai.core.utils.parsers import parse_json_response
|
|
@@ -13,6 +13,27 @@ from pygeai.core.utils.parsers import parse_json_response
|
|
|
13
13
|
|
|
14
14
|
class OrganizationClient(BaseClient):
|
|
15
15
|
|
|
16
|
+
def _get_token_information(self):
|
|
17
|
+
return AdminClient(self.api_service.token, base_url=self.api_service.base_url).validate_api_token()
|
|
18
|
+
|
|
19
|
+
def _get_project_id(self):
|
|
20
|
+
response = None
|
|
21
|
+
try:
|
|
22
|
+
response = self._get_token_information()
|
|
23
|
+
return response.get("projectId")
|
|
24
|
+
except Exception as e:
|
|
25
|
+
logger.error(f"Error retrieving project_id from GEAI. Response: {response}: {e}")
|
|
26
|
+
raise APIError(f"Error retrieving project_id from GEAI: {e}")
|
|
27
|
+
|
|
28
|
+
def _get_organization_id(self):
|
|
29
|
+
response = None
|
|
30
|
+
try:
|
|
31
|
+
response = self._get_token_information()
|
|
32
|
+
return response.get("organizationId")
|
|
33
|
+
except Exception as e:
|
|
34
|
+
logger.error(f"Error retrieving organization_id from GEAI. Response: {response}: {e}")
|
|
35
|
+
raise APIError(f"Error retrieving organization_id from GEAI: {e}")
|
|
36
|
+
|
|
16
37
|
def get_assistant_list(
|
|
17
38
|
self,
|
|
18
39
|
detail: str = "summary"
|
|
@@ -261,58 +282,143 @@ class OrganizationClient(BaseClient):
|
|
|
261
282
|
"orderDirection": order_direction
|
|
262
283
|
}
|
|
263
284
|
if email:
|
|
264
|
-
params["
|
|
285
|
+
params["userEmail"] = email
|
|
265
286
|
if order_key:
|
|
266
287
|
params["orderKey"] = order_key
|
|
267
288
|
if role_types:
|
|
268
289
|
params["roleTypes"] = role_types
|
|
269
290
|
|
|
270
|
-
|
|
291
|
+
organization_id = self._get_organization_id()
|
|
292
|
+
headers = {"organization-id": organization_id}
|
|
293
|
+
|
|
294
|
+
response = self.api_service.get(endpoint=GET_PROJECT_MEMBERSHIPS_V2, params=params, headers=headers)
|
|
271
295
|
validate_status_code(response)
|
|
272
296
|
return parse_json_response(response, "get project memberships")
|
|
273
297
|
|
|
274
298
|
def get_project_roles(
|
|
275
299
|
self,
|
|
276
|
-
project_id: str
|
|
300
|
+
project_id: str,
|
|
301
|
+
start_page: int = 1,
|
|
302
|
+
page_size: int = 20,
|
|
303
|
+
order_key: str = None,
|
|
304
|
+
order_direction: str = "desc",
|
|
305
|
+
role_types: str = None
|
|
277
306
|
) -> dict:
|
|
278
307
|
"""
|
|
279
308
|
Retrieves all Roles supported by a specific Project.
|
|
280
309
|
|
|
281
310
|
:param project_id: str - The unique identifier (GUID) of the project (required).
|
|
311
|
+
:param start_page: int - The page number for pagination (default is 1).
|
|
312
|
+
:param page_size: int - The number of items per page (default is 20).
|
|
313
|
+
:param order_key: str - Field for sorting. Only 'name' is supported (optional).
|
|
314
|
+
:param order_direction: str - Sort direction: 'asc' or 'desc' (default is 'desc').
|
|
315
|
+
:param role_types: str - Comma-separated list of role types: 'backend', 'frontend' (optional, case-insensitive).
|
|
282
316
|
:return: dict - The API response containing the list of roles for the project, in JSON format.
|
|
283
317
|
"""
|
|
284
|
-
|
|
318
|
+
params = {
|
|
319
|
+
"startPage": start_page,
|
|
320
|
+
"pageSize": page_size,
|
|
321
|
+
"orderDirection": order_direction
|
|
322
|
+
}
|
|
323
|
+
if order_key:
|
|
324
|
+
params["orderKey"] = order_key
|
|
325
|
+
if role_types:
|
|
326
|
+
params["roleTypes"] = role_types
|
|
327
|
+
|
|
328
|
+
headers = {"project-id": project_id}
|
|
329
|
+
response = self.api_service.get(endpoint=GET_PROJECT_ROLES_V2, params=params, headers=headers)
|
|
285
330
|
validate_status_code(response)
|
|
286
331
|
return parse_json_response(response, "get project roles for project", project_id=project_id)
|
|
287
332
|
|
|
288
333
|
def get_project_members(
|
|
289
334
|
self,
|
|
290
|
-
project_id: str
|
|
335
|
+
project_id: str,
|
|
336
|
+
start_page: int = 1,
|
|
337
|
+
page_size: int = 20,
|
|
338
|
+
order_key: str = None,
|
|
339
|
+
order_direction: str = "desc",
|
|
340
|
+
role_types: str = None
|
|
291
341
|
) -> dict:
|
|
292
342
|
"""
|
|
293
343
|
Retrieves all members and their Roles for a specific Project.
|
|
294
344
|
|
|
295
345
|
:param project_id: str - The unique identifier (GUID) of the project (required).
|
|
346
|
+
:param start_page: int - The page number for pagination (default is 1).
|
|
347
|
+
:param page_size: int - The number of items per page (default is 20).
|
|
348
|
+
:param order_key: str - Field for sorting. Only 'name' is supported (optional).
|
|
349
|
+
:param order_direction: str - Sort direction: 'asc' or 'desc' (default is 'desc').
|
|
350
|
+
:param role_types: str - Comma-separated list of role types: 'backend', 'frontend' (optional, case-insensitive).
|
|
296
351
|
:return: dict - The API response containing the list of members with their roles, in JSON format.
|
|
297
352
|
"""
|
|
298
|
-
|
|
353
|
+
params = {
|
|
354
|
+
"startPage": start_page,
|
|
355
|
+
"pageSize": page_size,
|
|
356
|
+
"orderDirection": order_direction
|
|
357
|
+
}
|
|
358
|
+
if order_key:
|
|
359
|
+
params["orderKey"] = order_key
|
|
360
|
+
if role_types:
|
|
361
|
+
params["roleTypes"] = role_types
|
|
362
|
+
|
|
363
|
+
headers = {"project-id": project_id}
|
|
364
|
+
response = self.api_service.get(endpoint=GET_PROJECT_MEMBERS_V2, params=params, headers=headers)
|
|
299
365
|
validate_status_code(response)
|
|
300
366
|
return parse_json_response(response, "get project members for project", project_id=project_id)
|
|
301
367
|
|
|
302
368
|
def get_organization_members(
|
|
303
369
|
self,
|
|
304
|
-
organization_id: str
|
|
370
|
+
organization_id: str,
|
|
371
|
+
start_page: int = 1,
|
|
372
|
+
page_size: int = 20,
|
|
373
|
+
order_key: str = None,
|
|
374
|
+
order_direction: str = "desc",
|
|
375
|
+
role_types: str = None
|
|
305
376
|
) -> dict:
|
|
306
377
|
"""
|
|
307
378
|
Retrieves all members and their Roles for a specific Organization.
|
|
308
379
|
|
|
309
380
|
:param organization_id: str - The unique identifier (GUID) of the organization (required).
|
|
381
|
+
:param start_page: int - The page number for pagination (default is 1).
|
|
382
|
+
:param page_size: int - The number of items per page (default is 20).
|
|
383
|
+
:param order_key: str - Field for sorting. Only 'email' is supported (optional).
|
|
384
|
+
:param order_direction: str - Sort direction: 'asc' or 'desc' (default is 'desc').
|
|
385
|
+
:param role_types: str - Comma-separated list of role types. Only 'backend' is supported for organizations (optional, case-insensitive).
|
|
310
386
|
:return: dict - The API response containing the list of members with their roles, in JSON format.
|
|
311
387
|
"""
|
|
312
|
-
|
|
388
|
+
params = {
|
|
389
|
+
"organizationId": organization_id,
|
|
390
|
+
"startPage": start_page,
|
|
391
|
+
"pageSize": page_size,
|
|
392
|
+
"orderDirection": order_direction
|
|
393
|
+
}
|
|
394
|
+
if order_key:
|
|
395
|
+
params["orderKey"] = order_key
|
|
396
|
+
if role_types:
|
|
397
|
+
params["roleTypes"] = role_types
|
|
398
|
+
|
|
399
|
+
response = self.api_service.get(endpoint=GET_ORGANIZATION_MEMBERS_V2, params=params)
|
|
313
400
|
validate_status_code(response)
|
|
314
401
|
return parse_json_response(response, "get organization members for organization", organization_id=organization_id)
|
|
315
402
|
|
|
403
|
+
def get_runtime_policies(
|
|
404
|
+
self,
|
|
405
|
+
organization_id: str = None
|
|
406
|
+
) -> dict:
|
|
407
|
+
"""
|
|
408
|
+
Retrieves the plugin runtime policies defined for a given organization.
|
|
409
|
+
|
|
410
|
+
If no policies are defined, the response indicates that individual policies will apply.
|
|
411
|
+
|
|
412
|
+
:param organization_id: str - The unique identifier (GUID) of the organization (optional, defaults to token's organization).
|
|
413
|
+
:return: dict - The API response containing plugin runtime policies or a message indicating no policies are defined, in JSON format.
|
|
414
|
+
"""
|
|
415
|
+
if not organization_id:
|
|
416
|
+
organization_id = self._get_organization_id()
|
|
417
|
+
headers = {"organization-id": organization_id}
|
|
418
|
+
response = self.api_service.get(endpoint=GET_PLUGIN_RUNTIME_POLICIES_V2, headers=headers)
|
|
419
|
+
validate_status_code(response)
|
|
420
|
+
return parse_json_response(response, "get plugin runtime policies for organization", organization_id=organization_id)
|
|
421
|
+
|
|
316
422
|
def add_project_member(
|
|
317
423
|
self,
|
|
318
424
|
project_id: str,
|
pygeai/organization/endpoints.py
CHANGED
|
@@ -11,6 +11,7 @@ GET_PROJECT_MEMBERSHIPS_V2 = "v2/accessControl/projects/memberships" # GET - L
|
|
|
11
11
|
GET_PROJECT_ROLES_V2 = "v2/accessControl/projects/roles" # GET - Lists all Roles supported by a specific Project
|
|
12
12
|
GET_PROJECT_MEMBERS_V2 = "v2/accessControl/projects/members" # GET - Lists all members and their Roles for a specific Project
|
|
13
13
|
GET_ORGANIZATION_MEMBERS_V2 = "v2/accessControl/organizations/members" # GET - Lists all members and their Roles for a specific Organization
|
|
14
|
+
GET_PLUGIN_RUNTIME_POLICIES_V2 = "v2/accessControl/organization/plugin-runtime-policies" # GET - Retrieves plugin runtime policies for an organization
|
|
14
15
|
ADD_PROJECT_MEMBER_V2 = "v2/accessControl/projects/members" # POST - Adds a member to a project by sending an invitation
|
|
15
16
|
CREATE_ORGANIZATION_V2 = "v2/admin/organizations" # POST - Creates a new Organization
|
|
16
17
|
GET_ORGANIZATION_LIST_V2 = "v2/admin/organizations" # GET - Retrieves all the organizations available based on a given search criteria
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
from pygeai import logger
|
|
3
1
|
from pygeai.core.base.clients import BaseClient
|
|
4
|
-
|
|
2
|
+
|
|
5
3
|
from pygeai.core.utils.validators import validate_status_code
|
|
6
4
|
from pygeai.core.utils.parsers import parse_json_response
|
|
7
5
|
from pygeai.organization.limits.endpoints import SET_ORGANIZATION_USAGE_LIMIT_V2, GET_ORGANIZATION_LATEST_USAGE_LIMIT_V2, \
|
|
@@ -35,7 +33,7 @@ class UsageLimitClient(BaseClient):
|
|
|
35
33
|
data=usage_limit
|
|
36
34
|
)
|
|
37
35
|
validate_status_code(response)
|
|
38
|
-
return parse_json_response(response,
|
|
36
|
+
return parse_json_response(response, "set usage limit for organization", organization=organization)
|
|
39
37
|
|
|
40
38
|
def get_organization_latest_usage_limit(self, organization: str) -> dict:
|
|
41
39
|
"""
|
|
@@ -47,7 +45,7 @@ class UsageLimitClient(BaseClient):
|
|
|
47
45
|
endpoint = GET_ORGANIZATION_LATEST_USAGE_LIMIT_V2.format(organization=organization)
|
|
48
46
|
response = self.api_service.get(endpoint=endpoint)
|
|
49
47
|
validate_status_code(response)
|
|
50
|
-
return parse_json_response(response,
|
|
48
|
+
return parse_json_response(response, "get latest usage limit for organization", organization=organization)
|
|
51
49
|
|
|
52
50
|
def get_all_usage_limits_from_organization(self, organization: str) -> dict:
|
|
53
51
|
"""
|
|
@@ -59,7 +57,7 @@ class UsageLimitClient(BaseClient):
|
|
|
59
57
|
endpoint = GET_ALL_ORGANIZATION_USAGE_LIMITS_V2.format(organization=organization)
|
|
60
58
|
response = self.api_service.get(endpoint=endpoint)
|
|
61
59
|
validate_status_code(response)
|
|
62
|
-
return parse_json_response(response,
|
|
60
|
+
return parse_json_response(response, "get all usage limits for organization", organization=organization)
|
|
63
61
|
|
|
64
62
|
def delete_usage_limit_from_organization(self, organization: str, limit_id: str) -> dict:
|
|
65
63
|
"""
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
from pygeai import logger
|
|
2
|
-
from pygeai.core.base.mappers import
|
|
2
|
+
from pygeai.core.base.mappers import ModelMapper
|
|
3
3
|
from pygeai.core.models import UsageLimit
|
|
4
4
|
from pygeai.organization.limits.clients import UsageLimitClient
|
|
5
5
|
from pygeai.core.handlers import ErrorHandler
|
|
6
6
|
from pygeai.core.common.exceptions import APIError
|
|
7
|
-
import logging
|
|
8
|
-
|
|
9
|
-
|
|
10
7
|
|
|
11
8
|
|
|
12
9
|
class UsageLimitManager:
|
pygeai/organization/managers.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from pygeai import logger
|
|
2
|
-
from pygeai.core.base.mappers import
|
|
2
|
+
from pygeai.core.base.mappers import ResponseMapper
|
|
3
3
|
from pygeai.core.handlers import ErrorHandler
|
|
4
|
-
from pygeai.core.models import Project
|
|
4
|
+
from pygeai.core.models import Project
|
|
5
5
|
from pygeai.core.base.responses import EmptyResponse
|
|
6
6
|
from pygeai.organization.clients import OrganizationClient
|
|
7
7
|
from pygeai.organization.mappers import OrganizationResponseMapper
|
pygeai/proxy/config.py
CHANGED
pygeai/proxy/managers.py
CHANGED
|
@@ -2,7 +2,7 @@ from contextlib import AsyncExitStack
|
|
|
2
2
|
from typing import Any, List, Dict, Tuple
|
|
3
3
|
import asyncio
|
|
4
4
|
import json
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import requests
|
|
7
7
|
from urllib3.exceptions import MaxRetryError
|
|
8
8
|
import mcp.types as types
|
|
@@ -12,6 +12,7 @@ from pygeai.proxy.config import ProxySettingsManager
|
|
|
12
12
|
from pygeai.proxy.clients import ProxyClient, ToolProxyData, ToolProxyJobResult
|
|
13
13
|
from pygeai.core.utils.console import Console
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
class ServerManager:
|
|
16
17
|
"""
|
|
17
18
|
Manages multiple MCP servers.
|
|
@@ -89,7 +90,7 @@ class ServerManager:
|
|
|
89
90
|
tools=list(self.tools.values())
|
|
90
91
|
))
|
|
91
92
|
Console.write_stdout("----------------------------------")
|
|
92
|
-
Console.write_stdout(
|
|
93
|
+
Console.write_stdout("Proxy registered successfully:")
|
|
93
94
|
if isinstance(result, dict) and isinstance(result.get("Messages"), list):
|
|
94
95
|
for message in result["Messages"]:
|
|
95
96
|
description = message.get("Description", "")
|
|
@@ -167,7 +168,7 @@ class ServerManager:
|
|
|
167
168
|
try:
|
|
168
169
|
client = await self._initialize_client()
|
|
169
170
|
except (ConnectionError, TimeoutError, RuntimeError) as e:
|
|
170
|
-
Console.write_exception(
|
|
171
|
+
Console.write_exception("Error during client initialization:", e)
|
|
171
172
|
for i in range(15, 0, -1):
|
|
172
173
|
Console.write_stdout(f"\rRetrying in {i} seconds... ",'')
|
|
173
174
|
await asyncio.sleep(1)
|
|
@@ -176,7 +177,7 @@ class ServerManager:
|
|
|
176
177
|
continue
|
|
177
178
|
|
|
178
179
|
retry_count = 0
|
|
179
|
-
Console.write_stdout(
|
|
180
|
+
Console.write_stdout("Waiting for jobs...")
|
|
180
181
|
while True:
|
|
181
182
|
try:
|
|
182
183
|
jobs = client.dequeue()
|
|
@@ -185,7 +186,7 @@ class ServerManager:
|
|
|
185
186
|
retry_count += 1
|
|
186
187
|
if retry_count >= MAX_RETRIES:
|
|
187
188
|
Console.write_stderr(f"Failed to dequeue jobs after {MAX_RETRIES} retries.")
|
|
188
|
-
Console.write_exception(
|
|
189
|
+
Console.write_exception("Exception:", e, "\nExiting...")
|
|
189
190
|
return
|
|
190
191
|
Console.write_stderr(f"Failed to dequeue jobs (attempt {retry_count}/{MAX_RETRIES}):")
|
|
191
192
|
for i in range(15, 0, -1):
|
|
@@ -3,7 +3,7 @@ from unittest.mock import patch, MagicMock
|
|
|
3
3
|
from json import JSONDecodeError
|
|
4
4
|
|
|
5
5
|
from pygeai.admin.clients import AdminClient
|
|
6
|
-
from pygeai.core.common.exceptions import
|
|
6
|
+
from pygeai.core.common.exceptions import APIResponseError
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class TestAdminClient(unittest.TestCase):
|
|
@@ -15,7 +15,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
15
15
|
self.client = AdminClient()
|
|
16
16
|
self.mock_response = MagicMock()
|
|
17
17
|
|
|
18
|
-
@patch('pygeai.core.services.rest.
|
|
18
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
19
19
|
def test_validate_api_token_success(self, mock_get):
|
|
20
20
|
self.mock_response.json.return_value = {"organizationId": "org-123", "projectId": "proj-123"}
|
|
21
21
|
self.mock_response.status_code = 200
|
|
@@ -26,7 +26,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
26
26
|
mock_get.assert_called_once()
|
|
27
27
|
self.assertEqual(result, {"organizationId": "org-123", "projectId": "proj-123"})
|
|
28
28
|
|
|
29
|
-
@patch('pygeai.core.services.rest.
|
|
29
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
30
30
|
def test_validate_api_token_json_decode_error(self, mock_get):
|
|
31
31
|
self.mock_response.json.side_effect = JSONDecodeError("error", "doc", 0)
|
|
32
32
|
self.mock_response.status_code = 500
|
|
@@ -37,7 +37,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
37
37
|
self.client.validate_api_token()
|
|
38
38
|
self.assertIn("API returned an error", str(context.exception)) # "Unable to validate API token", str(context.exception))
|
|
39
39
|
|
|
40
|
-
@patch('pygeai.core.services.rest.
|
|
40
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
41
41
|
def test_get_authorized_organizations_success(self, mock_get):
|
|
42
42
|
self.mock_response.json.return_value = {"organizations": ["org1", "org2"]}
|
|
43
43
|
self.mock_response.status_code = 200
|
|
@@ -48,7 +48,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
48
48
|
mock_get.assert_called_once()
|
|
49
49
|
self.assertEqual(result, {"organizations": ["org1", "org2"]})
|
|
50
50
|
|
|
51
|
-
@patch('pygeai.core.services.rest.
|
|
51
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
52
52
|
def test_get_authorized_organizations_json_decode_error(self, mock_get):
|
|
53
53
|
self.mock_response.json.side_effect = JSONDecodeError("error", "doc", 0)
|
|
54
54
|
self.mock_response.status_code = 500
|
|
@@ -59,7 +59,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
59
59
|
self.client.get_authorized_organizations()
|
|
60
60
|
self.assertIn("API returned an error", str(context.exception)) # "Unable to retrieve authorized organizations", str(context.exception))
|
|
61
61
|
|
|
62
|
-
@patch('pygeai.core.services.rest.
|
|
62
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
63
63
|
def test_get_authorized_projects_by_organization_success(self, mock_get):
|
|
64
64
|
self.mock_response.json.return_value = {"projects": ["proj1", "proj2"]}
|
|
65
65
|
self.mock_response.status_code = 200
|
|
@@ -72,7 +72,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
72
72
|
self.assertEqual(call_args[1]['params']['organization'], "org-123")
|
|
73
73
|
self.assertEqual(result, {"projects": ["proj1", "proj2"]})
|
|
74
74
|
|
|
75
|
-
@patch('pygeai.core.services.rest.
|
|
75
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
76
76
|
def test_get_authorized_projects_by_organization_json_decode_error(self, mock_get):
|
|
77
77
|
self.mock_response.json.side_effect = JSONDecodeError("error", "doc", 0)
|
|
78
78
|
self.mock_response.status_code = 500
|
|
@@ -83,7 +83,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
83
83
|
self.client.get_authorized_projects_by_organization("org-123")
|
|
84
84
|
self.assertIn("API returned an error", str(context.exception)) # "Unable to retrieve authorized projects for organization", str(context.exception))
|
|
85
85
|
|
|
86
|
-
@patch('pygeai.core.services.rest.
|
|
86
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
87
87
|
def test_get_project_visibility_success(self, mock_get):
|
|
88
88
|
self.mock_response.json.return_value = {}
|
|
89
89
|
self.mock_response.status_code = 200
|
|
@@ -102,7 +102,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
102
102
|
self.assertEqual(call_args[1]['params']['accessToken'], "token-789")
|
|
103
103
|
self.assertEqual(result, {})
|
|
104
104
|
|
|
105
|
-
@patch('pygeai.core.services.rest.
|
|
105
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
106
106
|
def test_get_project_visibility_json_decode_error(self, mock_get):
|
|
107
107
|
self.mock_response.json.side_effect = JSONDecodeError("error", "doc", 0)
|
|
108
108
|
self.mock_response.status_code = 403
|
|
@@ -113,7 +113,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
113
113
|
self.client.get_project_visibility("org-123", "proj-456", "token-789")
|
|
114
114
|
self.assertIn("API returned an error", str(context.exception)) # "Unable to retrieve project visibility", str(context.exception))
|
|
115
115
|
|
|
116
|
-
@patch('pygeai.core.services.rest.
|
|
116
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
117
117
|
def test_get_project_api_token_success(self, mock_get):
|
|
118
118
|
self.mock_response.json.return_value = {"apiToken": "api-token-123"}
|
|
119
119
|
self.mock_response.status_code = 200
|
|
@@ -132,7 +132,7 @@ class TestAdminClient(unittest.TestCase):
|
|
|
132
132
|
self.assertEqual(call_args[1]['params']['accessToken'], "token-789")
|
|
133
133
|
self.assertEqual(result, {"apiToken": "api-token-123"})
|
|
134
134
|
|
|
135
|
-
@patch('pygeai.core.services.rest.
|
|
135
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
136
136
|
def test_get_project_api_token_json_decode_error(self, mock_get):
|
|
137
137
|
self.mock_response.json.side_effect = JSONDecodeError("error", "doc", 0)
|
|
138
138
|
self.mock_response.status_code = 401
|
|
@@ -2,7 +2,7 @@ import unittest
|
|
|
2
2
|
from unittest.mock import patch, MagicMock
|
|
3
3
|
from json import JSONDecodeError
|
|
4
4
|
from pygeai.assistant.rag.clients import RAGAssistantClient
|
|
5
|
-
from pygeai.core.common.exceptions import
|
|
5
|
+
from pygeai.core.common.exceptions import APIResponseError
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class TestRAGAssistantClient(unittest.TestCase):
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
|
|
4
|
-
from pydantic import BaseModel
|
|
5
4
|
|
|
6
5
|
from pygeai.assistant.rag.models import (
|
|
7
6
|
DocumentMetadata,
|
|
@@ -20,7 +19,7 @@ from pygeai.assistant.rag.models import (
|
|
|
20
19
|
UploadDocument,
|
|
21
20
|
UploadType
|
|
22
21
|
)
|
|
23
|
-
from pygeai.core.models import LlmSettings, ChatVariableList
|
|
22
|
+
from pygeai.core.models import LlmSettings, ChatVariableList
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
class TestRagModels(unittest.TestCase):
|
|
@@ -2,7 +2,7 @@ import unittest
|
|
|
2
2
|
from unittest.mock import patch, MagicMock
|
|
3
3
|
from json import JSONDecodeError
|
|
4
4
|
from pygeai.assistant.clients import AssistantClient
|
|
5
|
-
from pygeai.core.common.exceptions import
|
|
5
|
+
from pygeai.core.common.exceptions import APIResponseError
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class TestAssistantClient(unittest.TestCase):
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from unittest.mock import MagicMock, patch
|
|
3
|
-
from datetime import datetime
|
|
4
3
|
from pygeai.assistant.managers import AssistantManager
|
|
5
4
|
from pygeai.core.common.exceptions import MissingRequirementException, APIError
|
|
6
|
-
from pygeai.core.models import Assistant,
|
|
7
|
-
ChatMessageList, AssistantRevision, ChatVariableList, LlmSettings, ChatToolList, ToolChoice, ChatMessage
|
|
5
|
+
from pygeai.core.models import Assistant, ChatAssistant, ChatMessageList, LlmSettings, ChatMessage
|
|
8
6
|
from pygeai.assistant.rag.models import Document, UploadDocument, RAGAssistant
|
|
9
7
|
from pygeai.core.feedback.models import FeedbackRequest
|
|
10
8
|
from pygeai.core.responses import NewAssistantResponse, ChatResponse
|