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.
Files changed (217) 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/content/migration.rst +391 -7
  6. pygeai/_docs/source/pygeai.core.common.rst +8 -0
  7. pygeai/_docs/source/pygeai.tests.auth.rst +56 -0
  8. pygeai/_docs/source/pygeai.tests.cli.rst +8 -0
  9. pygeai/admin/clients.py +1 -3
  10. pygeai/analytics/clients.py +1 -1
  11. pygeai/assistant/clients.py +2 -7
  12. pygeai/assistant/data/clients.py +0 -8
  13. pygeai/assistant/data_analyst/clients.py +0 -2
  14. pygeai/assistant/managers.py +1 -1
  15. pygeai/assistant/rag/clients.py +0 -2
  16. pygeai/assistant/rag/mappers.py +9 -11
  17. pygeai/auth/clients.py +26 -7
  18. pygeai/auth/endpoints.py +2 -1
  19. pygeai/chat/clients.py +2 -2
  20. pygeai/chat/managers.py +1 -1
  21. pygeai/cli/commands/admin.py +13 -25
  22. pygeai/cli/commands/analytics.py +56 -88
  23. pygeai/cli/commands/assistant.py +84 -138
  24. pygeai/cli/commands/auth.py +23 -46
  25. pygeai/cli/commands/base.py +0 -1
  26. pygeai/cli/commands/chat.py +218 -209
  27. pygeai/cli/commands/common.py +5 -5
  28. pygeai/cli/commands/configuration.py +79 -29
  29. pygeai/cli/commands/docs.py +3 -4
  30. pygeai/cli/commands/embeddings.py +13 -19
  31. pygeai/cli/commands/evaluation.py +133 -344
  32. pygeai/cli/commands/feedback.py +7 -15
  33. pygeai/cli/commands/files.py +26 -53
  34. pygeai/cli/commands/gam.py +28 -69
  35. pygeai/cli/commands/lab/ai_lab.py +96 -142
  36. pygeai/cli/commands/lab/common.py +1 -1
  37. pygeai/cli/commands/lab/spec.py +12 -32
  38. pygeai/cli/commands/llm.py +9 -18
  39. pygeai/cli/commands/migrate.py +43 -99
  40. pygeai/cli/commands/organization.py +223 -196
  41. pygeai/cli/commands/rag.py +35 -58
  42. pygeai/cli/commands/rerank.py +21 -25
  43. pygeai/cli/commands/secrets.py +39 -67
  44. pygeai/cli/commands/usage_limits.py +50 -136
  45. pygeai/cli/commands/validators.py +1 -1
  46. pygeai/cli/geai.py +32 -3
  47. pygeai/cli/geai_proxy.py +6 -2
  48. pygeai/cli/install_man.py +1 -1
  49. pygeai/cli/parsers.py +1 -1
  50. pygeai/core/base/clients.py +90 -21
  51. pygeai/core/base/mappers.py +39 -55
  52. pygeai/core/base/session.py +134 -22
  53. pygeai/core/common/config.py +50 -13
  54. pygeai/core/common/constants.py +8 -0
  55. pygeai/core/common/exceptions.py +6 -0
  56. pygeai/core/embeddings/clients.py +0 -1
  57. pygeai/core/embeddings/managers.py +0 -1
  58. pygeai/core/feedback/clients.py +0 -2
  59. pygeai/core/feedback/models.py +1 -1
  60. pygeai/core/files/clients.py +0 -3
  61. pygeai/core/files/managers.py +1 -1
  62. pygeai/core/files/mappers.py +4 -5
  63. pygeai/core/llm/clients.py +0 -1
  64. pygeai/core/models.py +4 -4
  65. pygeai/core/plugins/clients.py +0 -3
  66. pygeai/core/plugins/models.py +2 -2
  67. pygeai/core/rerank/clients.py +0 -2
  68. pygeai/core/secrets/clients.py +0 -2
  69. pygeai/core/services/rest.py +80 -14
  70. pygeai/core/singleton.py +24 -0
  71. pygeai/dbg/__init__.py +2 -2
  72. pygeai/dbg/debugger.py +276 -38
  73. pygeai/evaluation/clients.py +2 -4
  74. pygeai/evaluation/dataset/clients.py +0 -1
  75. pygeai/evaluation/plan/clients.py +0 -2
  76. pygeai/evaluation/result/clients.py +0 -2
  77. pygeai/gam/clients.py +1 -3
  78. pygeai/health/clients.py +1 -3
  79. pygeai/lab/clients.py +0 -1
  80. pygeai/lab/managers.py +0 -1
  81. pygeai/lab/models.py +0 -1
  82. pygeai/lab/strategies/clients.py +1 -2
  83. pygeai/lab/tools/clients.py +2 -2
  84. pygeai/lab/tools/mappers.py +1 -1
  85. pygeai/migration/strategies.py +5 -6
  86. pygeai/migration/tools.py +1 -1
  87. pygeai/organization/clients.py +118 -12
  88. pygeai/organization/endpoints.py +1 -0
  89. pygeai/organization/limits/clients.py +4 -6
  90. pygeai/organization/limits/managers.py +1 -4
  91. pygeai/organization/managers.py +2 -2
  92. pygeai/proxy/config.py +1 -0
  93. pygeai/proxy/managers.py +6 -5
  94. pygeai/tests/admin/test_clients.py +11 -11
  95. pygeai/tests/assistants/rag/test_clients.py +1 -1
  96. pygeai/tests/assistants/rag/test_models.py +1 -2
  97. pygeai/tests/assistants/test_clients.py +1 -1
  98. pygeai/tests/assistants/test_managers.py +1 -3
  99. pygeai/tests/auth/test_cli_configuration.py +252 -0
  100. pygeai/tests/auth/test_client_initialization.py +411 -0
  101. pygeai/tests/auth/test_clients.py +29 -27
  102. pygeai/tests/auth/test_config_manager.py +305 -0
  103. pygeai/tests/auth/test_header_injection.py +294 -0
  104. pygeai/tests/auth/test_oauth.py +3 -1
  105. pygeai/tests/auth/test_session_logging.py +119 -0
  106. pygeai/tests/auth/test_session_validation.py +408 -0
  107. pygeai/tests/auth/test_singleton_reset.py +201 -0
  108. pygeai/tests/chat/test_clients.py +1 -1
  109. pygeai/tests/chat/test_iris.py +1 -1
  110. pygeai/tests/chat/test_ui.py +0 -2
  111. pygeai/tests/cli/commands/lab/test_ai_lab.py +1 -3
  112. pygeai/tests/cli/commands/lab/test_common.py +0 -1
  113. pygeai/tests/cli/commands/test_chat.py +1 -1
  114. pygeai/tests/cli/commands/test_common.py +0 -1
  115. pygeai/tests/cli/commands/test_embeddings.py +2 -2
  116. pygeai/tests/cli/commands/test_evaluation.py +1 -9
  117. pygeai/tests/cli/commands/test_llm.py +1 -1
  118. pygeai/tests/cli/commands/test_migrate.py +1 -1
  119. pygeai/tests/cli/commands/test_rerank.py +0 -1
  120. pygeai/tests/cli/commands/test_secrets.py +1 -1
  121. pygeai/tests/cli/commands/test_show_help.py +0 -1
  122. pygeai/tests/cli/commands/test_validators.py +0 -1
  123. pygeai/tests/cli/test_credentials_flag.py +312 -0
  124. pygeai/tests/cli/test_error_handler.py +0 -1
  125. pygeai/tests/core/base/test_mappers.py +2 -2
  126. pygeai/tests/core/base/test_models.py +4 -4
  127. pygeai/tests/core/common/test_config.py +2 -7
  128. pygeai/tests/core/common/test_decorators.py +0 -1
  129. pygeai/tests/core/embeddings/test_managers.py +1 -1
  130. pygeai/tests/core/feedback/test_clients.py +2 -2
  131. pygeai/tests/core/files/test_clients.py +6 -6
  132. pygeai/tests/core/files/test_models.py +0 -1
  133. pygeai/tests/core/files/test_responses.py +0 -1
  134. pygeai/tests/core/llm/test_clients.py +1 -1
  135. pygeai/tests/core/plugins/test_clients.py +4 -4
  136. pygeai/tests/core/rerank/test_mappers.py +1 -3
  137. pygeai/tests/core/secrets/test_clients.py +2 -3
  138. pygeai/tests/core/services/test_rest.py +10 -10
  139. pygeai/tests/core/utils/test_console.py +0 -1
  140. pygeai/tests/dbg/test_debugger.py +95 -8
  141. pygeai/tests/evaluation/dataset/test_clients.py +24 -27
  142. pygeai/tests/evaluation/plan/test_clients.py +16 -18
  143. pygeai/tests/evaluation/result/test_clients.py +4 -5
  144. pygeai/tests/health/test_clients.py +2 -2
  145. pygeai/tests/integration/lab/agents/test_create_agent.py +1 -3
  146. pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
  147. pygeai/tests/integration/lab/processes/test_create_process.py +2 -2
  148. pygeai/tests/integration/lab/processes/test_create_task.py +2 -3
  149. pygeai/tests/integration/lab/processes/test_delete_process.py +0 -1
  150. pygeai/tests/integration/lab/processes/test_get_process.py +2 -4
  151. pygeai/tests/integration/lab/processes/test_list_process_instances.py +1 -3
  152. pygeai/tests/integration/lab/processes/test_update_process.py +3 -9
  153. pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -2
  154. pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
  155. pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
  156. pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
  157. pygeai/tests/lab/agents/test_clients.py +17 -17
  158. pygeai/tests/lab/processes/test_clients.py +67 -67
  159. pygeai/tests/lab/processes/test_mappers.py +23 -23
  160. pygeai/tests/lab/spec/test_loader.py +0 -2
  161. pygeai/tests/lab/spec/test_parsers.py +1 -2
  162. pygeai/tests/lab/strategies/test_clients.py +10 -10
  163. pygeai/tests/lab/test_managers.py +3 -5
  164. pygeai/tests/lab/test_mappers.py +1 -4
  165. pygeai/tests/lab/tools/test_clients.py +21 -21
  166. pygeai/tests/lab/tools/test_mappers.py +0 -1
  167. pygeai/tests/organization/limits/test_clients.py +33 -33
  168. pygeai/tests/organization/limits/test_managers.py +7 -7
  169. pygeai/tests/organization/test_clients.py +78 -60
  170. pygeai/tests/proxy/test_clients.py +1 -1
  171. pygeai/tests/proxy/test_integration.py +1 -4
  172. pygeai/tests/proxy/test_managers.py +1 -2
  173. pygeai/tests/proxy/test_servers.py +1 -2
  174. pygeai/tests/snippets/assistants/rag/delete_rag_assistant.py +0 -1
  175. pygeai/tests/snippets/assistants/rag/get_documents.py +0 -1
  176. pygeai/tests/snippets/assistants/rag/get_rag_assistant_data.py +0 -1
  177. pygeai/tests/snippets/chat/get_request_status.py +0 -1
  178. pygeai/tests/snippets/dbg/file_debugging.py +72 -0
  179. pygeai/tests/snippets/dbg/module_debugging.py +60 -0
  180. pygeai/tests/snippets/embeddings/cohere_example.py +2 -2
  181. pygeai/tests/snippets/embeddings/openai_base64_example.py +1 -1
  182. pygeai/tests/snippets/evaluation/dataset/complete_workflow_example.py +8 -8
  183. pygeai/tests/snippets/evaluation/plan/complete_workflow_example.py +5 -5
  184. pygeai/tests/snippets/evaluation/result/complete_workflow_example.py +3 -3
  185. pygeai/tests/snippets/lab/agentic_flow_example_1.py +1 -1
  186. pygeai/tests/snippets/lab/agentic_flow_example_2.py +3 -4
  187. pygeai/tests/snippets/lab/agents/create_agent_with_permissions.py +2 -2
  188. pygeai/tests/snippets/lab/agents/delete_agent.py +1 -2
  189. pygeai/tests/snippets/lab/agents/get_agent.py +1 -1
  190. pygeai/tests/snippets/lab/agents/get_agent_with_new_fields.py +10 -10
  191. pygeai/tests/snippets/lab/agents/get_sharing_link.py +0 -1
  192. pygeai/tests/snippets/lab/agents/list_agents.py +1 -1
  193. pygeai/tests/snippets/lab/agents/publish_agent_revision.py +0 -1
  194. pygeai/tests/snippets/lab/agents/update_agent_properties.py +1 -1
  195. pygeai/tests/snippets/lab/crud_ui.py +3 -5
  196. pygeai/tests/snippets/lab/processes/kbs/get_kb.py +0 -1
  197. pygeai/tests/snippets/lab/processes/kbs/list_kbs.py +0 -1
  198. pygeai/tests/snippets/lab/processes/list_processes.py +1 -1
  199. pygeai/tests/snippets/lab/samples/summarize_files.py +0 -3
  200. pygeai/tests/snippets/lab/strategies/get_reasoning_strategy.py +0 -1
  201. pygeai/tests/snippets/lab/strategies/list_reasoning_strategies.py +1 -1
  202. pygeai/tests/snippets/lab/tools/get_tool.py +1 -1
  203. pygeai/tests/snippets/lab/tools/publish_tool_revision.py +0 -1
  204. pygeai/tests/snippets/lab/tools/set_parameters.py +1 -2
  205. pygeai/tests/snippets/lab/use_cases/c_code_fixer_agent_flow.py +2 -3
  206. pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +1 -1
  207. pygeai/tests/snippets/lab/use_cases/update_cli_expert.py +0 -1
  208. pygeai/tests/snippets/lab/use_cases/update_lab_expert.py +0 -1
  209. pygeai/tests/snippets/lab/use_cases/update_web_designer.py +0 -1
  210. pygeai/tests/snippets/lab/use_cases/update_web_reader.py +0 -1
  211. pygeai/tests/snippets/migrate/orchestrator_examples.py +1 -1
  212. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/METADATA +32 -7
  213. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/RECORD +217 -206
  214. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/WHEEL +0 -0
  215. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/entry_points.txt +0 -0
  216. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/licenses/LICENSE +0 -0
  217. {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/top_level.txt +0 -0
@@ -19,13 +19,9 @@ def show_help():
19
19
 
20
20
 
21
21
  def get_assistant_detail(option_list: list):
22
- detail = "summary"
23
- assistant_id = None
24
- for option_flag, option_arg in option_list:
25
- if option_flag.name == "detail":
26
- detail = option_arg
27
- if option_flag.name == "assistant_id":
28
- assistant_id = option_arg
22
+ opts = {opt.name: arg for opt, arg in option_list}
23
+ detail = opts.get("detail", "summary")
24
+ assistant_id = opts.get("assistant_id")
29
25
 
30
26
  if not assistant_id:
31
27
  raise MissingRequirementException("Cannot retrieve assistant detail without assistant_id")
@@ -52,58 +48,43 @@ assistant_detail_options = [
52
48
 
53
49
 
54
50
  def create_assistant(option_list: list):
55
- assistant_type = "text"
56
- name = None
57
- description = None
58
- prompt = None
59
- provider_name = None
60
- model_name = None
51
+ opts = {opt.name: arg for opt, arg in option_list}
52
+ assistant_type = opts.get("type", "text")
53
+ name = opts.get("name")
54
+ description = opts.get("description")
55
+ prompt = opts.get("prompt")
56
+ provider_name = opts.get("provider_name")
57
+ model_name = opts.get("model_name")
58
+ max_tokens = opts.get("max_tokens")
59
+ welcome_data_title = opts.get("welcome_data_title")
60
+ welcome_data_description = opts.get("welcome_data_description")
61
+
61
62
  temperature = None
62
- max_tokens = None
63
- llm_settings = {}
64
- welcome_data = {}
65
- welcome_data_title = None
66
- welcome_data_description = None
63
+ temp_arg = opts.get("temperature")
64
+ if temp_arg:
65
+ try:
66
+ temperature = float(temp_arg)
67
+ except Exception:
68
+ raise WrongArgumentError("When defined, temperature must be a decimal numer. Example: 0.5")
69
+
67
70
  feature_list = []
71
+ feature_arg = opts.get("welcome_data_feature")
72
+ if feature_arg:
73
+ feature_list = get_welcome_data_feature_list([], feature_arg)
74
+
68
75
  examples_prompt_list = []
69
-
70
- for option_flag, option_arg in option_list:
71
- if option_flag.name == "type":
72
- assistant_type = option_arg
73
- if option_flag.name == "name":
74
- name = option_arg
75
- if option_flag.name == "description":
76
- description = option_arg
77
- if option_flag.name == "prompt":
78
- prompt = option_arg
79
- if option_flag.name == "provider_name":
80
- provider_name = option_arg
81
- if option_flag.name == "model_name":
82
- model_name = option_arg
83
- if option_flag.name == "temperature":
84
- if option_arg:
85
- try:
86
- temperature = float(option_arg)
87
- except Exception as e:
88
- raise WrongArgumentError("When defined, temperature must be a decimal numer. Example: 0.5")
89
-
90
- if option_flag.name == "max_tokens":
91
- max_tokens = option_arg
92
- if option_flag.name == "welcome_data_title":
93
- welcome_data_title = option_arg
94
- if option_flag.name == "welcome_data_description":
95
- welcome_data_description = option_arg
96
- if option_flag.name == "welcome_data_feature":
97
- feature_list = get_welcome_data_feature_list(feature_list, option_arg)
98
- if option_flag.name == "welcome_data_example_prompt":
99
- examples_prompt_list = get_welcome_data_example_prompt(examples_prompt_list, option_arg)
76
+ examples_arg = opts.get("welcome_data_example_prompt")
77
+ if examples_arg:
78
+ examples_prompt_list = get_welcome_data_example_prompt([], examples_arg)
100
79
 
101
80
  if not (assistant_type and name and prompt):
102
81
  raise MissingRequirementException("Cannot create new assistant without 'type', 'name' and 'prompt'")
103
82
 
83
+ llm_settings = {}
104
84
  if provider_name or model_name or temperature or max_tokens:
105
85
  llm_settings = get_llm_settings(provider_name, model_name, temperature, max_tokens)
106
86
 
87
+ welcome_data = {}
107
88
  if welcome_data_title or welcome_data_description:
108
89
  welcome_data = get_welcome_data(
109
90
  welcome_data_title,
@@ -205,60 +186,37 @@ create_assistant_options = [
205
186
 
206
187
 
207
188
  def update_assistant(option_list: list):
208
- assistant_id = None
209
- name = None
210
- description = None
211
- status = 1
212
- action = "saveNewRevision"
213
- revision_id = None
214
- prompt = None
215
- provider_name = None
216
- model_name = None
189
+ opts = {opt.name: arg for opt, arg in option_list}
190
+ assistant_id = opts.get("assistant_id")
191
+ name = opts.get("name")
192
+ description = opts.get("description")
193
+ status = opts.get("status", 1)
194
+ action = opts.get("action", "saveNewRevision")
195
+ revision_id = opts.get("revision_id")
196
+ prompt = opts.get("prompt")
197
+ provider_name = opts.get("provider_name")
198
+ model_name = opts.get("model_name")
199
+ max_tokens = opts.get("max_tokens")
200
+ welcome_data_title = opts.get("welcome_data_title")
201
+ welcome_data_description = opts.get("welcome_data_description")
202
+
217
203
  temperature = None
218
- max_tokens = None
219
- llm_settings = {}
220
- welcome_data = {}
221
- welcome_data_title = None
222
- welcome_data_description = None
204
+ temp_arg = opts.get("temperature")
205
+ if temp_arg:
206
+ try:
207
+ temperature = float(temp_arg)
208
+ except Exception:
209
+ raise WrongArgumentError("When defined, temperature must be a decimal numer. Example: 0.5")
210
+
223
211
  feature_list = []
212
+ feature_arg = opts.get("welcome_data_feature")
213
+ if feature_arg:
214
+ feature_list = get_welcome_data_feature_list([], feature_arg)
215
+
224
216
  examples_prompt_list = []
225
-
226
- for option_flag, option_arg in option_list:
227
- if option_flag.name == "assistant_id":
228
- assistant_id = option_arg
229
- if option_flag.name == "name":
230
- name = option_arg
231
- if option_flag.name == "description":
232
- description = option_arg
233
- if option_flag.name == "status":
234
- status = option_arg
235
- if option_flag.name == "action":
236
- action = option_arg
237
- if option_flag.name == "revision_id":
238
- revision_id = option_arg
239
- if option_flag.name == "prompt":
240
- prompt = option_arg
241
- if option_flag.name == "provider_name":
242
- provider_name = option_arg
243
- if option_flag.name == "model_name":
244
- model_name = option_arg
245
- if option_flag.name == "temperature":
246
- if option_arg:
247
- try:
248
- temperature = float(option_arg)
249
- except Exception as e:
250
- raise WrongArgumentError("When defined, temperature must be a decimal numer. Example: 0.5")
251
-
252
- if option_flag.name == "max_tokens":
253
- max_tokens = option_arg
254
- if option_flag.name == "welcome_data_title":
255
- welcome_data_title = option_arg
256
- if option_flag.name == "welcome_data_description":
257
- welcome_data_description = option_arg
258
- if option_flag.name == "welcome_data_feature":
259
- feature_list = get_welcome_data_feature_list(feature_list, option_arg)
260
- if option_flag.name == "welcome_data_example_prompt":
261
- examples_prompt_list = get_welcome_data_example_prompt(examples_prompt_list, option_arg)
217
+ examples_arg = opts.get("welcome_data_example_prompt")
218
+ if examples_arg:
219
+ examples_prompt_list = get_welcome_data_example_prompt([], examples_arg)
262
220
 
263
221
  if not assistant_id:
264
222
  raise MissingRequirementException("Cannot update existing assistant without 'assistant_id'")
@@ -269,9 +227,11 @@ def update_assistant(option_list: list):
269
227
  if ((action == "saveNewRevision" or action == "savePublishNewRevision") or revision_id) and not prompt:
270
228
  raise MissingRequirementException("Prompt must be defined if revisionId is specified or in case of actions saveNewRevision and savePublishNewRevision.")
271
229
 
230
+ llm_settings = {}
272
231
  if provider_name or model_name or temperature or max_tokens:
273
232
  llm_settings = get_llm_settings(provider_name, model_name, temperature, max_tokens)
274
233
 
234
+ welcome_data = {}
275
235
  if welcome_data_title or welcome_data_description:
276
236
  welcome_data = get_welcome_data(welcome_data_title, welcome_data_description, feature_list, examples_prompt_list)
277
237
 
@@ -389,10 +349,8 @@ update_assistant_options = [
389
349
 
390
350
 
391
351
  def delete_assistant(option_list: list):
392
- assistant_id = None
393
- for option_flag, option_arg in option_list:
394
- if option_flag.name == "assistant_id":
395
- assistant_id = option_arg
352
+ opts = {opt.name: arg for opt, arg in option_list}
353
+ assistant_id = opts.get("assistant_id")
396
354
 
397
355
  if not assistant_id:
398
356
  raise MissingRequirementException("Cannot delete assistant without 'assistant_id'")
@@ -415,38 +373,30 @@ delete_assistant_options = [
415
373
 
416
374
 
417
375
  def send_chat_request(option_list: list):
418
- assistant_name = None
376
+ opts = {opt.name: arg for opt, arg in option_list}
377
+ assistant_name = opts.get("assistant_name")
378
+ revision = opts.get("revision")
379
+ revision_name = opts.get("revision_name")
380
+
419
381
  message_list = []
420
- revision = None
421
- revision_name = None
422
-
423
- for option_flag, option_arg in option_list:
424
- if option_flag.name == "assistant_name":
425
- assistant_name = option_arg
426
- if option_flag.name == "messages":
427
- try:
428
- message_json = json.loads(option_arg)
429
- if isinstance(message_json, list):
430
- message_list = message_json
431
- elif isinstance(message_json, dict):
432
- message_list.append(message_json)
433
- except Exception as e:
434
- raise WrongArgumentError(
435
- "Each message must be in json format: '{\"role\": \"user\", \"content\": \"message content\"}' "
436
- "It can be a dictionary or a list of dictionaries. Each dictionary must contain role and content")
437
-
438
- if option_flag.name == "revision":
439
- revision = option_arg
440
- if option_flag.name == "revision_name":
441
- revision_name = option_arg
382
+ messages_arg = opts.get("messages")
383
+ if messages_arg:
384
+ try:
385
+ message_json = json.loads(messages_arg)
386
+ if isinstance(message_json, list):
387
+ message_list = message_json
388
+ elif isinstance(message_json, dict):
389
+ message_list.append(message_json)
390
+ except Exception:
391
+ raise WrongArgumentError(
392
+ "Each message must be in json format: '{\"role\": \"user\", \"content\": \"message content\"}' "
393
+ "It can be a dictionary or a list of dictionaries. Each dictionary must contain role and content")
442
394
 
443
395
  if not assistant_name:
444
396
  raise MissingRequirementException("Cannot send chat request without specifying assistant name")
445
397
 
446
398
  messages = get_messages(message_list)
447
399
 
448
- # TODO -> Add variables handling
449
-
450
400
  client = AssistantClient()
451
401
  result = client.send_chat_request(
452
402
  assistant_name=assistant_name,
@@ -480,7 +430,7 @@ send_chat_request_options = [
480
430
  Option(
481
431
  "revision_name",
482
432
  ["--revision-name"],
483
- "string: Name of the revision.",
433
+ "string:\tName of the revision.",
484
434
  True
485
435
  ),
486
436
  Option(
@@ -493,10 +443,8 @@ send_chat_request_options = [
493
443
 
494
444
 
495
445
  def get_request_status(option_list: list):
496
- request_id = None
497
- for option_flag, option_arg in option_list:
498
- if option_flag.name == "request_id":
499
- request_id = option_arg
446
+ opts = {opt.name: arg for opt, arg in option_list}
447
+ request_id = opts.get("request_id")
500
448
 
501
449
  if not request_id:
502
450
  raise MissingRequirementException("Cannot retrieve status of request without request_id.")
@@ -517,10 +465,8 @@ request_status_options = [
517
465
 
518
466
 
519
467
  def cancel_request(option_list: list):
520
- request_id = None
521
- for option_flag, option_arg in option_list:
522
- if option_flag.name == "request_id":
523
- request_id = option_arg
468
+ opts = {opt.name: arg for opt, arg in option_list}
469
+ request_id = opts.get("request_id")
524
470
 
525
471
  if not request_id:
526
472
  raise MissingRequirementException("Cannot cancel request without request_id.")
@@ -2,7 +2,7 @@ from pygeai.auth.clients import AuthClient
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 AUTH_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
 
@@ -15,19 +15,12 @@ def show_help():
15
15
 
16
16
 
17
17
  def get_oauth2_access_token(option_list: list):
18
- client_id = None
19
- username = None
20
- password = None
21
- scope = "gam_user_data gam_user_roles"
22
- for option_flag, option_arg in option_list:
23
- if option_flag.name == "client_id":
24
- client_id = option_arg
25
- if option_flag.name == "username":
26
- username = option_arg
27
- if option_flag.name == "password":
28
- password = option_arg
29
- if option_flag.name == "scope":
30
- scope = option_arg
18
+ opts = {opt.name: arg for opt, arg in option_list}
19
+
20
+ client_id = opts.get('client_id')
21
+ username = opts.get('username')
22
+ password = opts.get('password')
23
+ scope = opts.get('scope', "gam_user_data gam_user_roles")
31
24
 
32
25
  if not (client_id and username and password):
33
26
  raise MissingRequirementException("Cannot obtain Oauth2 access token without client_id, username and password")
@@ -72,10 +65,8 @@ get_oauth2_access_token_options = [
72
65
 
73
66
 
74
67
  def get_user_profile_information(option_list: list):
75
- access_token = None
76
- for option_flag, option_arg in option_list:
77
- if option_flag.name == "access_token":
78
- access_token = option_arg
68
+ opts = {opt.name: arg for opt, arg in option_list}
69
+ access_token = opts.get('access_token')
79
70
 
80
71
  client = AuthClient()
81
72
  result = client.get_user_profile_information(access_token=access_token)
@@ -93,16 +84,11 @@ get_user_profile_information_options = [
93
84
 
94
85
 
95
86
  def create_project_api_token(option_list: list):
96
- project_id = None
97
- name = None
98
- description = None
99
- for option_flag, option_arg in option_list:
100
- if option_flag.name == "project_id":
101
- project_id = option_arg
102
- if option_flag.name == "name":
103
- name = option_arg
104
- if option_flag.name == "description":
105
- description = option_arg
87
+ opts = {opt.name: arg for opt, arg in option_list}
88
+
89
+ project_id = opts.get('project_id')
90
+ name = opts.get('name')
91
+ description = opts.get('description')
106
92
 
107
93
  if not (project_id and name):
108
94
  raise MissingRequirementException("Cannot create project API token without project-id and name")
@@ -139,10 +125,8 @@ create_project_api_token_options = [
139
125
 
140
126
 
141
127
  def delete_project_api_token(option_list: list):
142
- api_token_id = None
143
- for option_flag, option_arg in option_list:
144
- if option_flag.name == "api_token_id":
145
- api_token_id = option_arg
128
+ opts = {opt.name: arg for opt, arg in option_list}
129
+ api_token_id = opts.get('api_token_id')
146
130
 
147
131
  if not api_token_id:
148
132
  raise MissingRequirementException("Cannot delete project API token without api-token-id")
@@ -163,16 +147,11 @@ delete_project_api_token_options = [
163
147
 
164
148
 
165
149
  def update_project_api_token(option_list: list):
166
- api_token_id = None
167
- description = None
168
- status = None
169
- for option_flag, option_arg in option_list:
170
- if option_flag.name == "api_token_id":
171
- api_token_id = option_arg
172
- if option_flag.name == "description":
173
- description = option_arg
174
- if option_flag.name == "status":
175
- status = option_arg
150
+ opts = {opt.name: arg for opt, arg in option_list}
151
+
152
+ api_token_id = opts.get('api_token_id')
153
+ description = opts.get('description')
154
+ status = opts.get('status')
176
155
 
177
156
  if not api_token_id:
178
157
  raise MissingRequirementException("Cannot update project API token without api-token-id")
@@ -209,10 +188,8 @@ update_project_api_token_options = [
209
188
 
210
189
 
211
190
  def get_project_api_token(option_list: list):
212
- api_token_id = None
213
- for option_flag, option_arg in option_list:
214
- if option_flag.name == "api_token_id":
215
- api_token_id = option_arg
191
+ opts = {opt.name: arg for opt, arg in option_list}
192
+ api_token_id = opts.get('api_token_id')
216
193
 
217
194
  if not api_token_id:
218
195
  raise MissingRequirementException("Cannot get project API token without api-token-id")
@@ -6,7 +6,6 @@ from pygeai.cli.commands.auth import auth_commands
6
6
  from pygeai.cli.commands.builders import build_help_text
7
7
  from pygeai.cli.commands.chat import chat_commands
8
8
  from pygeai.cli.commands.configuration import configure, configuration_options
9
- from pygeai.cli.commands.docs import docs_commands
10
9
  from pygeai.cli.commands.embeddings import embeddings_commands
11
10
  from pygeai.cli.commands.evaluation import evaluation_commands
12
11
  from pygeai.cli.commands.feedback import feedback_commands