pygeai 0.6.0b14__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.
Files changed (216) hide show
  1. pygeai/__init__.py +1 -2
  2. pygeai/_docs/source/content/api_reference/project.rst +392 -0
  3. pygeai/_docs/source/content/authentication.rst +130 -1
  4. pygeai/_docs/source/content/debugger.rst +327 -157
  5. pygeai/_docs/source/pygeai.core.common.rst +8 -0
  6. pygeai/_docs/source/pygeai.tests.auth.rst +56 -0
  7. pygeai/_docs/source/pygeai.tests.cli.rst +8 -0
  8. pygeai/admin/clients.py +1 -3
  9. pygeai/analytics/clients.py +1 -1
  10. pygeai/assistant/clients.py +2 -7
  11. pygeai/assistant/data/clients.py +0 -8
  12. pygeai/assistant/data_analyst/clients.py +0 -2
  13. pygeai/assistant/managers.py +1 -1
  14. pygeai/assistant/rag/clients.py +0 -2
  15. pygeai/assistant/rag/mappers.py +9 -11
  16. pygeai/auth/clients.py +26 -7
  17. pygeai/auth/endpoints.py +2 -1
  18. pygeai/chat/clients.py +2 -2
  19. pygeai/chat/managers.py +1 -1
  20. pygeai/cli/commands/admin.py +13 -25
  21. pygeai/cli/commands/analytics.py +31 -71
  22. pygeai/cli/commands/assistant.py +84 -138
  23. pygeai/cli/commands/auth.py +23 -46
  24. pygeai/cli/commands/base.py +0 -1
  25. pygeai/cli/commands/chat.py +218 -209
  26. pygeai/cli/commands/common.py +5 -5
  27. pygeai/cli/commands/configuration.py +79 -29
  28. pygeai/cli/commands/docs.py +3 -4
  29. pygeai/cli/commands/embeddings.py +13 -19
  30. pygeai/cli/commands/evaluation.py +133 -344
  31. pygeai/cli/commands/feedback.py +7 -15
  32. pygeai/cli/commands/files.py +26 -53
  33. pygeai/cli/commands/gam.py +28 -69
  34. pygeai/cli/commands/lab/ai_lab.py +96 -142
  35. pygeai/cli/commands/lab/common.py +1 -1
  36. pygeai/cli/commands/lab/spec.py +12 -32
  37. pygeai/cli/commands/llm.py +9 -18
  38. pygeai/cli/commands/migrate.py +43 -99
  39. pygeai/cli/commands/organization.py +223 -196
  40. pygeai/cli/commands/rag.py +35 -58
  41. pygeai/cli/commands/rerank.py +21 -25
  42. pygeai/cli/commands/secrets.py +39 -67
  43. pygeai/cli/commands/usage_limits.py +50 -136
  44. pygeai/cli/commands/validators.py +1 -1
  45. pygeai/cli/geai.py +32 -3
  46. pygeai/cli/geai_proxy.py +6 -2
  47. pygeai/cli/install_man.py +1 -1
  48. pygeai/cli/parsers.py +1 -1
  49. pygeai/core/base/clients.py +90 -21
  50. pygeai/core/base/mappers.py +39 -55
  51. pygeai/core/base/session.py +129 -18
  52. pygeai/core/common/config.py +50 -13
  53. pygeai/core/common/constants.py +8 -0
  54. pygeai/core/common/exceptions.py +6 -0
  55. pygeai/core/embeddings/clients.py +0 -1
  56. pygeai/core/embeddings/managers.py +0 -1
  57. pygeai/core/feedback/clients.py +0 -2
  58. pygeai/core/feedback/models.py +1 -1
  59. pygeai/core/files/clients.py +0 -3
  60. pygeai/core/files/managers.py +1 -1
  61. pygeai/core/files/mappers.py +4 -5
  62. pygeai/core/llm/clients.py +0 -1
  63. pygeai/core/models.py +4 -4
  64. pygeai/core/plugins/clients.py +0 -3
  65. pygeai/core/plugins/models.py +2 -2
  66. pygeai/core/rerank/clients.py +0 -2
  67. pygeai/core/secrets/clients.py +0 -2
  68. pygeai/core/services/rest.py +80 -14
  69. pygeai/core/singleton.py +24 -0
  70. pygeai/dbg/__init__.py +2 -2
  71. pygeai/dbg/debugger.py +276 -38
  72. pygeai/evaluation/clients.py +2 -4
  73. pygeai/evaluation/dataset/clients.py +0 -1
  74. pygeai/evaluation/plan/clients.py +0 -2
  75. pygeai/evaluation/result/clients.py +0 -2
  76. pygeai/gam/clients.py +1 -3
  77. pygeai/health/clients.py +1 -3
  78. pygeai/lab/clients.py +0 -1
  79. pygeai/lab/managers.py +0 -1
  80. pygeai/lab/models.py +0 -1
  81. pygeai/lab/strategies/clients.py +1 -2
  82. pygeai/lab/tools/clients.py +2 -2
  83. pygeai/lab/tools/mappers.py +1 -1
  84. pygeai/migration/strategies.py +5 -6
  85. pygeai/migration/tools.py +1 -1
  86. pygeai/organization/clients.py +118 -12
  87. pygeai/organization/endpoints.py +1 -0
  88. pygeai/organization/limits/clients.py +4 -6
  89. pygeai/organization/limits/managers.py +1 -4
  90. pygeai/organization/managers.py +2 -2
  91. pygeai/proxy/config.py +1 -0
  92. pygeai/proxy/managers.py +6 -5
  93. pygeai/tests/admin/test_clients.py +11 -11
  94. pygeai/tests/assistants/rag/test_clients.py +1 -1
  95. pygeai/tests/assistants/rag/test_models.py +1 -2
  96. pygeai/tests/assistants/test_clients.py +1 -1
  97. pygeai/tests/assistants/test_managers.py +1 -3
  98. pygeai/tests/auth/test_cli_configuration.py +252 -0
  99. pygeai/tests/auth/test_client_initialization.py +411 -0
  100. pygeai/tests/auth/test_clients.py +29 -27
  101. pygeai/tests/auth/test_config_manager.py +305 -0
  102. pygeai/tests/auth/test_header_injection.py +294 -0
  103. pygeai/tests/auth/test_oauth.py +3 -1
  104. pygeai/tests/auth/test_session_logging.py +119 -0
  105. pygeai/tests/auth/test_session_validation.py +408 -0
  106. pygeai/tests/auth/test_singleton_reset.py +201 -0
  107. pygeai/tests/chat/test_clients.py +1 -1
  108. pygeai/tests/chat/test_iris.py +1 -1
  109. pygeai/tests/chat/test_ui.py +0 -2
  110. pygeai/tests/cli/commands/lab/test_ai_lab.py +1 -3
  111. pygeai/tests/cli/commands/lab/test_common.py +0 -1
  112. pygeai/tests/cli/commands/test_chat.py +1 -1
  113. pygeai/tests/cli/commands/test_common.py +0 -1
  114. pygeai/tests/cli/commands/test_embeddings.py +2 -2
  115. pygeai/tests/cli/commands/test_evaluation.py +1 -9
  116. pygeai/tests/cli/commands/test_llm.py +1 -1
  117. pygeai/tests/cli/commands/test_migrate.py +1 -1
  118. pygeai/tests/cli/commands/test_rerank.py +0 -1
  119. pygeai/tests/cli/commands/test_secrets.py +1 -1
  120. pygeai/tests/cli/commands/test_show_help.py +0 -1
  121. pygeai/tests/cli/commands/test_validators.py +0 -1
  122. pygeai/tests/cli/test_credentials_flag.py +312 -0
  123. pygeai/tests/cli/test_error_handler.py +0 -1
  124. pygeai/tests/core/base/test_mappers.py +2 -2
  125. pygeai/tests/core/base/test_models.py +4 -4
  126. pygeai/tests/core/common/test_config.py +2 -7
  127. pygeai/tests/core/common/test_decorators.py +0 -1
  128. pygeai/tests/core/embeddings/test_managers.py +1 -1
  129. pygeai/tests/core/feedback/test_clients.py +2 -2
  130. pygeai/tests/core/files/test_clients.py +6 -6
  131. pygeai/tests/core/files/test_models.py +0 -1
  132. pygeai/tests/core/files/test_responses.py +0 -1
  133. pygeai/tests/core/llm/test_clients.py +1 -1
  134. pygeai/tests/core/plugins/test_clients.py +4 -4
  135. pygeai/tests/core/rerank/test_mappers.py +1 -3
  136. pygeai/tests/core/secrets/test_clients.py +2 -3
  137. pygeai/tests/core/services/test_rest.py +10 -10
  138. pygeai/tests/core/utils/test_console.py +0 -1
  139. pygeai/tests/dbg/test_debugger.py +95 -8
  140. pygeai/tests/evaluation/dataset/test_clients.py +24 -27
  141. pygeai/tests/evaluation/plan/test_clients.py +16 -18
  142. pygeai/tests/evaluation/result/test_clients.py +4 -5
  143. pygeai/tests/health/test_clients.py +2 -2
  144. pygeai/tests/integration/lab/agents/test_create_agent.py +1 -3
  145. pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
  146. pygeai/tests/integration/lab/processes/test_create_process.py +2 -2
  147. pygeai/tests/integration/lab/processes/test_create_task.py +2 -3
  148. pygeai/tests/integration/lab/processes/test_delete_process.py +0 -1
  149. pygeai/tests/integration/lab/processes/test_get_process.py +2 -4
  150. pygeai/tests/integration/lab/processes/test_list_process_instances.py +1 -3
  151. pygeai/tests/integration/lab/processes/test_update_process.py +3 -9
  152. pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -2
  153. pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
  154. pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
  155. pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
  156. pygeai/tests/lab/agents/test_clients.py +17 -17
  157. pygeai/tests/lab/processes/test_clients.py +67 -67
  158. pygeai/tests/lab/processes/test_mappers.py +23 -23
  159. pygeai/tests/lab/spec/test_loader.py +0 -2
  160. pygeai/tests/lab/spec/test_parsers.py +1 -2
  161. pygeai/tests/lab/strategies/test_clients.py +10 -10
  162. pygeai/tests/lab/test_managers.py +3 -5
  163. pygeai/tests/lab/test_mappers.py +1 -4
  164. pygeai/tests/lab/tools/test_clients.py +21 -21
  165. pygeai/tests/lab/tools/test_mappers.py +0 -1
  166. pygeai/tests/organization/limits/test_clients.py +33 -33
  167. pygeai/tests/organization/limits/test_managers.py +7 -7
  168. pygeai/tests/organization/test_clients.py +78 -60
  169. pygeai/tests/proxy/test_clients.py +1 -1
  170. pygeai/tests/proxy/test_integration.py +1 -4
  171. pygeai/tests/proxy/test_managers.py +1 -2
  172. pygeai/tests/proxy/test_servers.py +1 -2
  173. pygeai/tests/snippets/assistants/rag/delete_rag_assistant.py +0 -1
  174. pygeai/tests/snippets/assistants/rag/get_documents.py +0 -1
  175. pygeai/tests/snippets/assistants/rag/get_rag_assistant_data.py +0 -1
  176. pygeai/tests/snippets/chat/get_request_status.py +0 -1
  177. pygeai/tests/snippets/dbg/file_debugging.py +72 -0
  178. pygeai/tests/snippets/dbg/module_debugging.py +60 -0
  179. pygeai/tests/snippets/embeddings/cohere_example.py +2 -2
  180. pygeai/tests/snippets/embeddings/openai_base64_example.py +1 -1
  181. pygeai/tests/snippets/evaluation/dataset/complete_workflow_example.py +8 -8
  182. pygeai/tests/snippets/evaluation/plan/complete_workflow_example.py +5 -5
  183. pygeai/tests/snippets/evaluation/result/complete_workflow_example.py +3 -3
  184. pygeai/tests/snippets/lab/agentic_flow_example_1.py +1 -1
  185. pygeai/tests/snippets/lab/agentic_flow_example_2.py +3 -4
  186. pygeai/tests/snippets/lab/agents/create_agent_with_permissions.py +2 -2
  187. pygeai/tests/snippets/lab/agents/delete_agent.py +1 -2
  188. pygeai/tests/snippets/lab/agents/get_agent.py +1 -1
  189. pygeai/tests/snippets/lab/agents/get_agent_with_new_fields.py +10 -10
  190. pygeai/tests/snippets/lab/agents/get_sharing_link.py +0 -1
  191. pygeai/tests/snippets/lab/agents/list_agents.py +1 -1
  192. pygeai/tests/snippets/lab/agents/publish_agent_revision.py +0 -1
  193. pygeai/tests/snippets/lab/agents/update_agent_properties.py +1 -1
  194. pygeai/tests/snippets/lab/crud_ui.py +3 -5
  195. pygeai/tests/snippets/lab/processes/kbs/get_kb.py +0 -1
  196. pygeai/tests/snippets/lab/processes/kbs/list_kbs.py +0 -1
  197. pygeai/tests/snippets/lab/processes/list_processes.py +1 -1
  198. pygeai/tests/snippets/lab/samples/summarize_files.py +0 -3
  199. pygeai/tests/snippets/lab/strategies/get_reasoning_strategy.py +0 -1
  200. pygeai/tests/snippets/lab/strategies/list_reasoning_strategies.py +1 -1
  201. pygeai/tests/snippets/lab/tools/get_tool.py +1 -1
  202. pygeai/tests/snippets/lab/tools/publish_tool_revision.py +0 -1
  203. pygeai/tests/snippets/lab/tools/set_parameters.py +1 -2
  204. pygeai/tests/snippets/lab/use_cases/c_code_fixer_agent_flow.py +2 -3
  205. pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +1 -1
  206. pygeai/tests/snippets/lab/use_cases/update_cli_expert.py +0 -1
  207. pygeai/tests/snippets/lab/use_cases/update_lab_expert.py +0 -1
  208. pygeai/tests/snippets/lab/use_cases/update_web_designer.py +0 -1
  209. pygeai/tests/snippets/lab/use_cases/update_web_reader.py +0 -1
  210. pygeai/tests/snippets/migrate/orchestrator_examples.py +1 -1
  211. {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/METADATA +32 -7
  212. {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/RECORD +216 -205
  213. {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/WHEEL +0 -0
  214. {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/entry_points.txt +0 -0
  215. {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/licenses/LICENSE +0 -0
  216. {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/top_level.txt +0 -0
@@ -4,6 +4,22 @@ pygeai.tests.auth package
4
4
  Submodules
5
5
  ----------
6
6
 
7
+ pygeai.tests.auth.test\_cli\_configuration module
8
+ -------------------------------------------------
9
+
10
+ .. automodule:: pygeai.tests.auth.test_cli_configuration
11
+ :members:
12
+ :show-inheritance:
13
+ :undoc-members:
14
+
15
+ pygeai.tests.auth.test\_client\_initialization module
16
+ -----------------------------------------------------
17
+
18
+ .. automodule:: pygeai.tests.auth.test_client_initialization
19
+ :members:
20
+ :show-inheritance:
21
+ :undoc-members:
22
+
7
23
  pygeai.tests.auth.test\_clients module
8
24
  --------------------------------------
9
25
 
@@ -12,6 +28,22 @@ pygeai.tests.auth.test\_clients module
12
28
  :show-inheritance:
13
29
  :undoc-members:
14
30
 
31
+ pygeai.tests.auth.test\_config\_manager module
32
+ ----------------------------------------------
33
+
34
+ .. automodule:: pygeai.tests.auth.test_config_manager
35
+ :members:
36
+ :show-inheritance:
37
+ :undoc-members:
38
+
39
+ pygeai.tests.auth.test\_header\_injection module
40
+ ------------------------------------------------
41
+
42
+ .. automodule:: pygeai.tests.auth.test_header_injection
43
+ :members:
44
+ :show-inheritance:
45
+ :undoc-members:
46
+
15
47
  pygeai.tests.auth.test\_oauth module
16
48
  ------------------------------------
17
49
 
@@ -20,6 +52,30 @@ pygeai.tests.auth.test\_oauth module
20
52
  :show-inheritance:
21
53
  :undoc-members:
22
54
 
55
+ pygeai.tests.auth.test\_session\_logging module
56
+ -----------------------------------------------
57
+
58
+ .. automodule:: pygeai.tests.auth.test_session_logging
59
+ :members:
60
+ :show-inheritance:
61
+ :undoc-members:
62
+
63
+ pygeai.tests.auth.test\_session\_validation module
64
+ --------------------------------------------------
65
+
66
+ .. automodule:: pygeai.tests.auth.test_session_validation
67
+ :members:
68
+ :show-inheritance:
69
+ :undoc-members:
70
+
71
+ pygeai.tests.auth.test\_singleton\_reset module
72
+ -----------------------------------------------
73
+
74
+ .. automodule:: pygeai.tests.auth.test_singleton_reset
75
+ :members:
76
+ :show-inheritance:
77
+ :undoc-members:
78
+
23
79
  Module contents
24
80
  ---------------
25
81
 
@@ -13,6 +13,14 @@ Subpackages
13
13
  Submodules
14
14
  ----------
15
15
 
16
+ pygeai.tests.cli.test\_credentials\_flag module
17
+ -----------------------------------------------
18
+
19
+ .. automodule:: pygeai.tests.cli.test_credentials_flag
20
+ :members:
21
+ :show-inheritance:
22
+ :undoc-members:
23
+
16
24
  pygeai.tests.cli.test\_error\_handler module
17
25
  --------------------------------------------
18
26
 
pygeai/admin/clients.py CHANGED
@@ -1,9 +1,7 @@
1
-
2
- from pygeai import logger
3
1
  from pygeai.admin.endpoints import GET_API_TOKEN_VALIDATION_V1, GET_AUTHORIZED_ORGANIZATIONS_V1, \
4
2
  GET_AUTHORIZED_PROJECTS_V1, GET_PROJECT_VISIBILITY_V1, GET_PROJECT_API_TOKEN_V1
5
3
  from pygeai.core.base.clients import BaseClient
6
- from pygeai.core.common.exceptions import InvalidAPIResponseException
4
+
7
5
  from pygeai.core.utils.validators import validate_status_code
8
6
  from pygeai.core.utils.parsers import parse_json_response
9
7
 
@@ -53,7 +53,7 @@ class AnalyticsClient(BaseClient):
53
53
 
54
54
  def __build_headers(self):
55
55
  return {
56
- "Authorization": self.api_service.token,
56
+ "Authorization": f"Bearer {self.api_service.token}",
57
57
  "OrganizationId": self.organization_id,
58
58
  "ProjectId": self.project_id
59
59
  }
@@ -1,11 +1,6 @@
1
-
2
- from pygeai import logger
3
- from pygeai.assistant.endpoints import GET_ASSISTANT_DATA_V1, CREATE_ASSISTANT_V1, UPDATE_ASSISTANT_V1, BEGIN_CONVERSATION_V1, \
4
- SEND_TEXT_PROMPT_V1, SEND_CHAT_REQUEST_V1, GET_REQUEST_STATUS_V1, CANCEL_REQUEST_V1
5
- from pygeai.assistant.data_analyst.endpoints import GET_DATA_ANALYST_STATUS_V1, EXTEND_DATA_ANALYST_DATASET_V1
1
+ from pygeai.assistant.endpoints import GET_ASSISTANT_DATA_V1, CREATE_ASSISTANT_V1, UPDATE_ASSISTANT_V1, \
2
+ SEND_CHAT_REQUEST_V1, GET_REQUEST_STATUS_V1, CANCEL_REQUEST_V1
6
3
  from pygeai.core.base.clients import BaseClient
7
- from pygeai.core.common.decorators import handler_server_error
8
- from pygeai.core.common.exceptions import InvalidAPIResponseException
9
4
  from pygeai.core.utils.validators import validate_status_code
10
5
  from pygeai.core.utils.parsers import parse_json_response
11
6
 
@@ -1,12 +1,4 @@
1
- import json
2
-
3
1
  from pygeai.assistant.clients import AssistantClient
4
- from pygeai.assistant.endpoints import GET_ASSISTANT_DATA_V1, CREATE_ASSISTANT_V1, UPDATE_ASSISTANT_V1, BEGIN_CONVERSATION_V1, \
5
- SEND_TEXT_PROMPT_V1, SEND_CHAT_REQUEST_V1, GET_REQUEST_STATUS_V1, CANCEL_REQUEST_V1
6
- from pygeai.assistant.data_analyst.endpoints import GET_DATA_ANALYST_STATUS_V1, EXTEND_DATA_ANALYST_DATASET_V1
7
- from pygeai.core.base.clients import BaseClient
8
- from pygeai.core.common.decorators import handler_server_error
9
- from pygeai.core.utils.validators import validate_status_code
10
2
 
11
3
 
12
4
  class ChatWithDataAssistantClient(AssistantClient):
@@ -1,9 +1,7 @@
1
1
  from pathlib import Path
2
2
 
3
- from pygeai import logger
4
3
  from pygeai.assistant.clients import AssistantClient
5
4
  from pygeai.assistant.data_analyst.endpoints import GET_DATA_ANALYST_STATUS_V1, EXTEND_DATA_ANALYST_DATASET_V1
6
- from pygeai.core.common.exceptions import InvalidAPIResponseException
7
5
  from pygeai.core.utils.validators import validate_status_code
8
6
  from pygeai.core.utils.parsers import parse_json_response
9
7
 
@@ -4,7 +4,7 @@ from pygeai.assistant.clients import AssistantClient
4
4
  from pygeai.assistant.rag.clients import RAGAssistantClient
5
5
  from pygeai.assistant.rag.mappers import RAGAssistantMapper
6
6
  from pygeai.assistant.rag.responses import DocumentListResponse
7
- from pygeai.core.base.mappers import ErrorMapper, ResponseMapper
7
+ from pygeai.core.base.mappers import ResponseMapper
8
8
  from pygeai.core.handlers import ErrorHandler
9
9
  from pygeai.core.models import Assistant, TextAssistant, ChatAssistant, ChatMessageList, AssistantRevision, \
10
10
  ChatVariableList, LlmSettings, ChatWithDataAssistant, ChatToolList, ToolChoice
@@ -3,14 +3,12 @@ import logging
3
3
  from pathlib import Path
4
4
  from typing import Any
5
5
 
6
- from pygeai import logger
7
6
  from pygeai.assistant.rag.endpoints import GET_ASSISTANTS_FROM_PROJECT_V1, GET_ASSISTANT_V1, CREATE_ASSISTANT_V1, \
8
7
  UPDATE_ASSISTANT_V1, DELETE_ASSISTANT_V1, GET_DOCUMENTS_V1, DELETE_ALL_DOCUMENTS_V1, RETRIEVE_DOCUMENT_V1, \
9
8
  UPLOAD_DOCUMENT_V1, DELETE_DOCUMENT_V1, EXECUTE_QUERY_V1
10
9
  from pygeai.core.base.clients import BaseClient
11
10
  import urllib.parse
12
11
 
13
- from pygeai.core.common.exceptions import InvalidAPIResponseException
14
12
  from pygeai.core.utils.validators import validate_status_code
15
13
  from pygeai.core.utils.parsers import parse_json_response
16
14
 
@@ -186,14 +186,13 @@ class RAGAssistantMapper(ModelMapper):
186
186
 
187
187
  @classmethod
188
188
  def map_to_document_list(cls, data: dict) -> list[Document]:
189
- document_list = list()
190
- documents = data.get("documents")
189
+ documents = data.get('documents')
190
+
191
191
  if documents is not None and any(documents):
192
- for document_data in documents:
193
- document = cls.map_to_document(document_data)
194
- document_list.append(document)
195
192
 
196
- return document_list
193
+ return [cls.map_to_document(document_data) for document_data in documents]
194
+
195
+ return []
197
196
 
198
197
  @classmethod
199
198
  def map_to_document(cls, data: dict) -> Document:
@@ -211,14 +210,13 @@ class RAGAssistantMapper(ModelMapper):
211
210
 
212
211
  @classmethod
213
212
  def map_to_document_metadata_list(cls, data: dict) -> List[DocumentMetadata]:
214
- metadata_list = list()
215
213
  metadata = data.get('metadata')
214
+
216
215
  if metadata is not None and any(metadata):
217
- for metadata_data in metadata:
218
- new_metadata = cls.map_to_document_metadata(metadata_data)
219
- metadata_list.append(new_metadata)
220
216
 
221
- return metadata_list
217
+ return [cls.map_to_metadata(metadata_data) for metadata_data in metadata]
218
+
219
+ return []
222
220
 
223
221
  @classmethod
224
222
  def map_to_document_metadata(cls, data: dict) -> DocumentMetadata:
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
- :param access_token: str - Token obtained in the POST to /oauth/access_token
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
- self.api_service.token = access_token
48
- response = self.api_service.get(endpoint=GET_USER_PROFILE_INFO)
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 as e:
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 as e:
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 ChatResponse, ProviderResponse
8
+ from pygeai.core.responses import ProviderResponse
9
9
 
10
10
 
11
11
  class ChatManager:
@@ -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, WrongArgumentError
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
- organization = None
31
- for option_flag, option_arg in option_list:
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
- organization = None
57
- project = None
58
- access_token = None
59
- for option_flag, option_arg in option_list:
60
- if option_flag.name == "organization":
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
- organization = None
104
- project = None
105
- access_token = None
106
- for option_flag, option_arg in option_list:
107
- if option_flag.name == "organization":
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 "
@@ -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
- from pygeai.core.common.exceptions import MissingRequirementException
4
+
5
5
  from pygeai.core.utils.console import Console
6
6
  from pygeai.analytics.managers import AnalyticsManager
7
7
  import csv
@@ -55,13 +55,9 @@ CSV_EXPORT_OPTION = Option(
55
55
 
56
56
 
57
57
  def get_agents_created_and_modified(option_list: list):
58
- start_date = None
59
- end_date = None
60
- for option_flag, option_arg in option_list:
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
62
  if not start_date or not end_date:
67
63
  start_date, end_date = get_default_date_range()
@@ -76,16 +72,10 @@ agents_created_options = [START_DATE_OPTION, END_DATE_OPTION]
76
72
 
77
73
 
78
74
  def get_total_requests_per_day(option_list: list):
79
- start_date = None
80
- end_date = None
81
- agent_name = None
82
- for option_flag, option_arg in option_list:
83
- if option_flag.name == "start_date":
84
- start_date = option_arg
85
- if option_flag.name == "end_date":
86
- end_date = option_arg
87
- if option_flag.name == "agent_name":
88
- agent_name = option_arg
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")
89
79
 
90
80
  if not start_date or not end_date:
91
81
  start_date, end_date = get_default_date_range()
@@ -93,7 +83,7 @@ def get_total_requests_per_day(option_list: list):
93
83
 
94
84
  manager = AnalyticsManager()
95
85
  result = manager.get_total_requests_per_day(start_date, end_date, agent_name)
96
- Console.write_stdout(f"Total requests per day:")
86
+ Console.write_stdout("Total requests per day:")
97
87
  for item in result.requestsPerDay:
98
88
  Console.write_stdout(f" {item.date}: {item.totalRequests} requests ({item.totalRequestsWithError} errors)")
99
89
 
@@ -102,13 +92,9 @@ total_requests_per_day_options = [START_DATE_OPTION, END_DATE_OPTION, AGENT_NAME
102
92
 
103
93
 
104
94
  def get_total_cost(option_list: list):
105
- start_date = None
106
- end_date = None
107
- for option_flag, option_arg in option_list:
108
- if option_flag.name == "start_date":
109
- start_date = option_arg
110
- if option_flag.name == "end_date":
111
- 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")
112
98
 
113
99
  if not start_date or not end_date:
114
100
  start_date, end_date = get_default_date_range()
@@ -123,13 +109,9 @@ total_cost_options = [START_DATE_OPTION, END_DATE_OPTION]
123
109
 
124
110
 
125
111
  def get_average_cost_per_request(option_list: list):
126
- start_date = None
127
- end_date = None
128
- for option_flag, option_arg in option_list:
129
- if option_flag.name == "start_date":
130
- start_date = option_arg
131
- if option_flag.name == "end_date":
132
- 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")
133
115
 
134
116
  if not start_date or not end_date:
135
117
  start_date, end_date = get_default_date_range()
@@ -144,13 +126,9 @@ average_cost_per_request_options = [START_DATE_OPTION, END_DATE_OPTION]
144
126
 
145
127
 
146
128
  def get_total_tokens(option_list: list):
147
- start_date = None
148
- end_date = None
149
- for option_flag, option_arg in option_list:
150
- if option_flag.name == "start_date":
151
- start_date = option_arg
152
- if option_flag.name == "end_date":
153
- 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")
154
132
 
155
133
  if not start_date or not end_date:
156
134
  start_date, end_date = get_default_date_range()
@@ -165,13 +143,9 @@ total_tokens_options = [START_DATE_OPTION, END_DATE_OPTION]
165
143
 
166
144
 
167
145
  def get_overall_error_rate(option_list: list):
168
- start_date = None
169
- end_date = None
170
- for option_flag, option_arg in option_list:
171
- if option_flag.name == "start_date":
172
- start_date = option_arg
173
- if option_flag.name == "end_date":
174
- 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")
175
149
 
176
150
  if not start_date or not end_date:
177
151
  start_date, end_date = get_default_date_range()
@@ -186,13 +160,9 @@ error_rate_options = [START_DATE_OPTION, END_DATE_OPTION]
186
160
 
187
161
 
188
162
  def get_top_agents_by_requests(option_list: list):
189
- start_date = None
190
- end_date = None
191
- for option_flag, option_arg in option_list:
192
- if option_flag.name == "start_date":
193
- start_date = option_arg
194
- if option_flag.name == "end_date":
195
- 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")
196
166
 
197
167
  if not start_date or not end_date:
198
168
  start_date, end_date = get_default_date_range()
@@ -209,13 +179,9 @@ top_agents_options = [START_DATE_OPTION, END_DATE_OPTION]
209
179
 
210
180
 
211
181
  def get_total_active_users(option_list: list):
212
- start_date = None
213
- end_date = None
214
- for option_flag, option_arg in option_list:
215
- if option_flag.name == "start_date":
216
- start_date = option_arg
217
- if option_flag.name == "end_date":
218
- 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")
219
185
 
220
186
  if not start_date or not end_date:
221
187
  start_date, end_date = get_default_date_range()
@@ -230,16 +196,10 @@ active_users_options = [START_DATE_OPTION, END_DATE_OPTION]
230
196
 
231
197
 
232
198
  def get_full_report(option_list: list):
233
- start_date = None
234
- end_date = None
235
- csv_file = None
236
- for option_flag, option_arg in option_list:
237
- if option_flag.name == "start_date":
238
- start_date = option_arg
239
- if option_flag.name == "end_date":
240
- end_date = option_arg
241
- if option_flag.name == "csv_file":
242
- 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")
243
203
 
244
204
  if not start_date or not end_date:
245
205
  start_date, end_date = get_default_date_range()