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/auth/clients.py
CHANGED
|
@@ -2,7 +2,6 @@ from pygeai import logger
|
|
|
2
2
|
from pygeai.auth.endpoints import GET_USER_PROFILE_INFO, GET_OAUTH2_ACCESS_TOKEN, \
|
|
3
3
|
CREATE_PROJECT_API_TOKEN_V2, DELETE_PROJECT_API_TOKEN_V2, UPDATE_PROJECT_API_TOKEN_V2, GET_PROJECT_API_TOKEN_V2
|
|
4
4
|
from pygeai.core.base.clients import BaseClient
|
|
5
|
-
from pygeai.core.common.exceptions import InvalidAPIResponseException, APIResponseError
|
|
6
5
|
from pygeai.core.utils.validators import validate_status_code
|
|
7
6
|
from pygeai.core.utils.parsers import parse_json_response
|
|
8
7
|
|
|
@@ -37,15 +36,35 @@ class AuthClient(BaseClient):
|
|
|
37
36
|
validate_status_code(response)
|
|
38
37
|
return parse_json_response(response, "obtain Oauth2 access token")
|
|
39
38
|
|
|
40
|
-
def get_user_profile_information(self, access_token: str) -> dict:
|
|
39
|
+
def get_user_profile_information(self, access_token: str, project_id: str = None) -> dict:
|
|
41
40
|
"""
|
|
42
|
-
Get user profile information
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
Get user profile information using an OAuth access token.
|
|
42
|
+
|
|
43
|
+
This method creates a temporary API service to avoid mutating the session state.
|
|
44
|
+
|
|
45
|
+
:param access_token: str - OAuth 2.0 access token
|
|
46
|
+
:param project_id: str - Project ID for OAuth context (optional, uses session project_id if available)
|
|
45
47
|
:return: dict - The API response containing the user profile information
|
|
48
|
+
:raises: MissingRequirementException - If project_id is not provided and not in session
|
|
46
49
|
"""
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
# Determine project_id to use
|
|
51
|
+
effective_project_id = project_id or self.session.project_id
|
|
52
|
+
|
|
53
|
+
if not effective_project_id:
|
|
54
|
+
logger.warning(
|
|
55
|
+
"No project_id provided for get_user_profile_information. "
|
|
56
|
+
"This may cause authentication issues."
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Create a temporary API service without mutating session
|
|
60
|
+
from pygeai.core.services.rest import GEAIApiService
|
|
61
|
+
temp_service = GEAIApiService(
|
|
62
|
+
base_url=self.session.base_url,
|
|
63
|
+
token=access_token,
|
|
64
|
+
project_id=effective_project_id
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
response = temp_service.get(endpoint=GET_USER_PROFILE_INFO)
|
|
49
68
|
validate_status_code(response)
|
|
50
69
|
return parse_json_response(response, "retrieve user profile information")
|
|
51
70
|
|
pygeai/auth/endpoints.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
GET_OAUTH2_ACCESS_TOKEN = "/oauth/access_token" # POST -> Obtain an OAuth 2.0 access token
|
|
1
|
+
# GET_OAUTH2_ACCESS_TOKEN = "/oauth/access_token" # POST -> Obtain an OAuth 2.0 access token
|
|
2
|
+
GET_OAUTH2_ACCESS_TOKEN = "/oauth/gam/v2.0/access_token" # POST -> Obtain an OAuth 2.0 access token
|
|
2
3
|
GET_USER_PROFILE_INFO = "/openid/userinfo" # GET -> Retrieve user profile information
|
|
3
4
|
CREATE_PROJECT_API_TOKEN_V2 = "v2/projects/tokens" # POST -> Create a new API token for a project
|
|
4
5
|
DELETE_PROJECT_API_TOKEN_V2 = "v2/projects/tokens/{id}" # DELETE -> Revoke an API token
|
pygeai/chat/clients.py
CHANGED
|
@@ -197,7 +197,7 @@ class ChatClient(BaseClient):
|
|
|
197
197
|
):
|
|
198
198
|
content = json_data["choices"][0]["delta"]["content"]
|
|
199
199
|
yield content
|
|
200
|
-
except JSONDecodeError
|
|
200
|
+
except JSONDecodeError:
|
|
201
201
|
continue
|
|
202
202
|
except Exception as e:
|
|
203
203
|
raise InvalidAPIResponseException(f"Unable to process streaming chat response: {e}")
|
|
@@ -225,7 +225,7 @@ class ChatClient(BaseClient):
|
|
|
225
225
|
):
|
|
226
226
|
content = json_data["choices"][0]["delta"]["content"]
|
|
227
227
|
yield content
|
|
228
|
-
except JSONDecodeError
|
|
228
|
+
except JSONDecodeError:
|
|
229
229
|
continue
|
|
230
230
|
except Exception as e:
|
|
231
231
|
raise InvalidAPIResponseException(f"Unable to process streaming response: {e}")
|
pygeai/chat/managers.py
CHANGED
|
@@ -5,7 +5,7 @@ from pygeai.core.models import ChatMessageList, \
|
|
|
5
5
|
ChatVariableList, LlmSettings, ChatToolList, ToolChoice
|
|
6
6
|
from pygeai.assistant.mappers import AssistantResponseMapper
|
|
7
7
|
from pygeai.chat.clients import ChatClient
|
|
8
|
-
from pygeai.core.responses import
|
|
8
|
+
from pygeai.core.responses import ProviderResponse
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class ChatManager:
|
pygeai/cli/commands/admin.py
CHANGED
|
@@ -2,7 +2,7 @@ from pygeai.admin.clients import AdminClient
|
|
|
2
2
|
from pygeai.cli.commands import Command, Option, ArgumentsEnum
|
|
3
3
|
from pygeai.cli.commands.builders import build_help_text
|
|
4
4
|
from pygeai.cli.texts.help import ADMIN_HELP_TEXT
|
|
5
|
-
from pygeai.core.common.exceptions import MissingRequirementException
|
|
5
|
+
from pygeai.core.common.exceptions import MissingRequirementException
|
|
6
6
|
from pygeai.core.utils.console import Console
|
|
7
7
|
|
|
8
8
|
|
|
@@ -27,10 +27,8 @@ def get_authorized_organizations():
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
def get_authorized_projects_by_organization(option_list: list):
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if option_flag.name == "organization":
|
|
33
|
-
organization = option_arg
|
|
30
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
31
|
+
organization = opts.get('organization')
|
|
34
32
|
|
|
35
33
|
if not organization:
|
|
36
34
|
raise MissingRequirementException("Cannot get authorized projects within organization without organization id")
|
|
@@ -53,16 +51,11 @@ authorized_projects_by_organization_options = [
|
|
|
53
51
|
|
|
54
52
|
|
|
55
53
|
def get_project_visibility(option_list: list):
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
organization = option_arg
|
|
62
|
-
if option_flag.name == "project":
|
|
63
|
-
project = option_arg
|
|
64
|
-
if option_flag.name == "access_token":
|
|
65
|
-
access_token = option_arg
|
|
54
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
55
|
+
|
|
56
|
+
organization = opts.get('organization')
|
|
57
|
+
project = opts.get('project')
|
|
58
|
+
access_token = opts.get('access_token')
|
|
66
59
|
|
|
67
60
|
if not (organization and project and access_token):
|
|
68
61
|
raise MissingRequirementException("Cannot get project visibility for access token without specifying "
|
|
@@ -100,16 +93,11 @@ project_visibility_options = [
|
|
|
100
93
|
|
|
101
94
|
|
|
102
95
|
def get_project_api_token(option_list: list):
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
organization = option_arg
|
|
109
|
-
if option_flag.name == "project":
|
|
110
|
-
project = option_arg
|
|
111
|
-
if option_flag.name == "access_token":
|
|
112
|
-
access_token = option_arg
|
|
96
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
97
|
+
|
|
98
|
+
organization = opts.get('organization')
|
|
99
|
+
project = opts.get('project')
|
|
100
|
+
access_token = opts.get('access_token')
|
|
113
101
|
|
|
114
102
|
if not (organization and project and access_token):
|
|
115
103
|
raise MissingRequirementException("Cannot get project API Token without specifying "
|
pygeai/cli/commands/analytics.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from pygeai.cli.commands import Command, Option, ArgumentsEnum
|
|
2
2
|
from pygeai.cli.commands.builders import build_help_text
|
|
3
3
|
from pygeai.cli.texts.help import ANALYTICS_HELP_TEXT
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
from pygeai.core.utils.console import Console
|
|
6
6
|
from pygeai.analytics.managers import AnalyticsManager
|
|
7
7
|
import csv
|
|
@@ -55,16 +55,13 @@ CSV_EXPORT_OPTION = Option(
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
def get_agents_created_and_modified(option_list: list):
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if option_flag.name == "start_date":
|
|
62
|
-
start_date = option_arg
|
|
63
|
-
if option_flag.name == "end_date":
|
|
64
|
-
end_date = option_arg
|
|
58
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
59
|
+
start_date = opts.get("start_date")
|
|
60
|
+
end_date = opts.get("end_date")
|
|
65
61
|
|
|
66
|
-
if not
|
|
67
|
-
|
|
62
|
+
if not start_date or not end_date:
|
|
63
|
+
start_date, end_date = get_default_date_range()
|
|
64
|
+
Console.write_stdout(f"Using default date range: {start_date} to {end_date}")
|
|
68
65
|
|
|
69
66
|
manager = AnalyticsManager()
|
|
70
67
|
result = manager.get_agents_created_and_modified(start_date, end_date)
|
|
@@ -75,23 +72,18 @@ agents_created_options = [START_DATE_OPTION, END_DATE_OPTION]
|
|
|
75
72
|
|
|
76
73
|
|
|
77
74
|
def get_total_requests_per_day(option_list: list):
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if option_flag.name == "agent_name":
|
|
87
|
-
agent_name = option_arg
|
|
88
|
-
|
|
89
|
-
if not (start_date and end_date):
|
|
90
|
-
raise MissingRequirementException("Cannot retrieve total requests per day without start-date and end-date")
|
|
75
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
76
|
+
start_date = opts.get("start_date")
|
|
77
|
+
end_date = opts.get("end_date")
|
|
78
|
+
agent_name = opts.get("agent_name")
|
|
79
|
+
|
|
80
|
+
if not start_date or not end_date:
|
|
81
|
+
start_date, end_date = get_default_date_range()
|
|
82
|
+
Console.write_stdout(f"Using default date range: {start_date} to {end_date}")
|
|
91
83
|
|
|
92
84
|
manager = AnalyticsManager()
|
|
93
85
|
result = manager.get_total_requests_per_day(start_date, end_date, agent_name)
|
|
94
|
-
Console.write_stdout(
|
|
86
|
+
Console.write_stdout("Total requests per day:")
|
|
95
87
|
for item in result.requestsPerDay:
|
|
96
88
|
Console.write_stdout(f" {item.date}: {item.totalRequests} requests ({item.totalRequestsWithError} errors)")
|
|
97
89
|
|
|
@@ -100,16 +92,13 @@ total_requests_per_day_options = [START_DATE_OPTION, END_DATE_OPTION, AGENT_NAME
|
|
|
100
92
|
|
|
101
93
|
|
|
102
94
|
def get_total_cost(option_list: list):
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if option_flag.name == "start_date":
|
|
107
|
-
start_date = option_arg
|
|
108
|
-
if option_flag.name == "end_date":
|
|
109
|
-
end_date = option_arg
|
|
95
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
96
|
+
start_date = opts.get("start_date")
|
|
97
|
+
end_date = opts.get("end_date")
|
|
110
98
|
|
|
111
|
-
if not
|
|
112
|
-
|
|
99
|
+
if not start_date or not end_date:
|
|
100
|
+
start_date, end_date = get_default_date_range()
|
|
101
|
+
Console.write_stdout(f"Using default date range: {start_date} to {end_date}")
|
|
113
102
|
|
|
114
103
|
manager = AnalyticsManager()
|
|
115
104
|
result = manager.get_total_cost(start_date, end_date)
|
|
@@ -120,16 +109,13 @@ total_cost_options = [START_DATE_OPTION, END_DATE_OPTION]
|
|
|
120
109
|
|
|
121
110
|
|
|
122
111
|
def get_average_cost_per_request(option_list: list):
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if option_flag.name == "start_date":
|
|
127
|
-
start_date = option_arg
|
|
128
|
-
if option_flag.name == "end_date":
|
|
129
|
-
end_date = option_arg
|
|
112
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
113
|
+
start_date = opts.get("start_date")
|
|
114
|
+
end_date = opts.get("end_date")
|
|
130
115
|
|
|
131
|
-
if not
|
|
132
|
-
|
|
116
|
+
if not start_date or not end_date:
|
|
117
|
+
start_date, end_date = get_default_date_range()
|
|
118
|
+
Console.write_stdout(f"Using default date range: {start_date} to {end_date}")
|
|
133
119
|
|
|
134
120
|
manager = AnalyticsManager()
|
|
135
121
|
result = manager.get_average_cost_per_request(start_date, end_date)
|
|
@@ -140,16 +126,13 @@ average_cost_per_request_options = [START_DATE_OPTION, END_DATE_OPTION]
|
|
|
140
126
|
|
|
141
127
|
|
|
142
128
|
def get_total_tokens(option_list: list):
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if option_flag.name == "start_date":
|
|
147
|
-
start_date = option_arg
|
|
148
|
-
if option_flag.name == "end_date":
|
|
149
|
-
end_date = option_arg
|
|
129
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
130
|
+
start_date = opts.get("start_date")
|
|
131
|
+
end_date = opts.get("end_date")
|
|
150
132
|
|
|
151
|
-
if not
|
|
152
|
-
|
|
133
|
+
if not start_date or not end_date:
|
|
134
|
+
start_date, end_date = get_default_date_range()
|
|
135
|
+
Console.write_stdout(f"Using default date range: {start_date} to {end_date}")
|
|
153
136
|
|
|
154
137
|
manager = AnalyticsManager()
|
|
155
138
|
result = manager.get_total_tokens(start_date, end_date)
|
|
@@ -160,16 +143,13 @@ total_tokens_options = [START_DATE_OPTION, END_DATE_OPTION]
|
|
|
160
143
|
|
|
161
144
|
|
|
162
145
|
def get_overall_error_rate(option_list: list):
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if option_flag.name == "start_date":
|
|
167
|
-
start_date = option_arg
|
|
168
|
-
if option_flag.name == "end_date":
|
|
169
|
-
end_date = option_arg
|
|
146
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
147
|
+
start_date = opts.get("start_date")
|
|
148
|
+
end_date = opts.get("end_date")
|
|
170
149
|
|
|
171
|
-
if not
|
|
172
|
-
|
|
150
|
+
if not start_date or not end_date:
|
|
151
|
+
start_date, end_date = get_default_date_range()
|
|
152
|
+
Console.write_stdout(f"Using default date range: {start_date} to {end_date}")
|
|
173
153
|
|
|
174
154
|
manager = AnalyticsManager()
|
|
175
155
|
result = manager.get_overall_error_rate(start_date, end_date)
|
|
@@ -180,16 +160,13 @@ error_rate_options = [START_DATE_OPTION, END_DATE_OPTION]
|
|
|
180
160
|
|
|
181
161
|
|
|
182
162
|
def get_top_agents_by_requests(option_list: list):
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if option_flag.name == "start_date":
|
|
187
|
-
start_date = option_arg
|
|
188
|
-
if option_flag.name == "end_date":
|
|
189
|
-
end_date = option_arg
|
|
163
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
164
|
+
start_date = opts.get("start_date")
|
|
165
|
+
end_date = opts.get("end_date")
|
|
190
166
|
|
|
191
|
-
if not
|
|
192
|
-
|
|
167
|
+
if not start_date or not end_date:
|
|
168
|
+
start_date, end_date = get_default_date_range()
|
|
169
|
+
Console.write_stdout(f"Using default date range: {start_date} to {end_date}")
|
|
193
170
|
|
|
194
171
|
manager = AnalyticsManager()
|
|
195
172
|
result = manager.get_top_10_agents_by_requests(start_date, end_date)
|
|
@@ -202,16 +179,13 @@ top_agents_options = [START_DATE_OPTION, END_DATE_OPTION]
|
|
|
202
179
|
|
|
203
180
|
|
|
204
181
|
def get_total_active_users(option_list: list):
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if option_flag.name == "start_date":
|
|
209
|
-
start_date = option_arg
|
|
210
|
-
if option_flag.name == "end_date":
|
|
211
|
-
end_date = option_arg
|
|
182
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
183
|
+
start_date = opts.get("start_date")
|
|
184
|
+
end_date = opts.get("end_date")
|
|
212
185
|
|
|
213
|
-
if not
|
|
214
|
-
|
|
186
|
+
if not start_date or not end_date:
|
|
187
|
+
start_date, end_date = get_default_date_range()
|
|
188
|
+
Console.write_stdout(f"Using default date range: {start_date} to {end_date}")
|
|
215
189
|
|
|
216
190
|
manager = AnalyticsManager()
|
|
217
191
|
result = manager.get_total_active_users(start_date, end_date)
|
|
@@ -222,16 +196,10 @@ active_users_options = [START_DATE_OPTION, END_DATE_OPTION]
|
|
|
222
196
|
|
|
223
197
|
|
|
224
198
|
def get_full_report(option_list: list):
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if option_flag.name == "start_date":
|
|
230
|
-
start_date = option_arg
|
|
231
|
-
if option_flag.name == "end_date":
|
|
232
|
-
end_date = option_arg
|
|
233
|
-
if option_flag.name == "csv_file":
|
|
234
|
-
csv_file = option_arg
|
|
199
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
200
|
+
start_date = opts.get("start_date")
|
|
201
|
+
end_date = opts.get("end_date")
|
|
202
|
+
csv_file = opts.get("csv_file")
|
|
235
203
|
|
|
236
204
|
if not start_date or not end_date:
|
|
237
205
|
start_date, end_date = get_default_date_range()
|