pygeai 0.6.0b14__py3-none-any.whl → 0.7.0b1__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/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 +31 -71
- 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 +129 -18
- 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.0b14.dist-info → pygeai-0.7.0b1.dist-info}/METADATA +32 -7
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/RECORD +216 -205
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/WHEEL +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/entry_points.txt +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/top_level.txt +0 -0
|
@@ -18,7 +18,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
18
18
|
def setUp(self):
|
|
19
19
|
self.client = OrganizationClient()
|
|
20
20
|
|
|
21
|
-
@patch("pygeai.core.services.rest.
|
|
21
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
22
22
|
def test_get_assistant_list_success(self, mock_get):
|
|
23
23
|
mock_response = mock_get.return_value
|
|
24
24
|
mock_response.json.return_value = {"assistants": [{"name": "assistant1"}, {"name": "assistant2"}]}
|
|
@@ -32,7 +32,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
32
32
|
self.assertEqual(result['assistants'][0]['name'], "assistant1")
|
|
33
33
|
self.assertEqual(result['assistants'][1]['name'], "assistant2")
|
|
34
34
|
|
|
35
|
-
@patch("pygeai.core.services.rest.
|
|
35
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
36
36
|
def test_get_assistant_list_json_decode_error(self, mock_get):
|
|
37
37
|
mock_response = mock_get.return_value
|
|
38
38
|
mock_response.status_code = 200
|
|
@@ -45,7 +45,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
45
45
|
mock_get.assert_called_once_with(endpoint=GET_ASSISTANT_LIST_V1, params={"detail": "full"})
|
|
46
46
|
self.assertEqual(str(context.exception), "Unable to get assistant list: Invalid JSON response")
|
|
47
47
|
|
|
48
|
-
@patch("pygeai.core.services.rest.
|
|
48
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
49
49
|
def test_get_project_list_success(self, mock_get):
|
|
50
50
|
mock_response = mock_get.return_value
|
|
51
51
|
mock_response.json.return_value = {"projects": [{"name": "project1"}, {"name": "project2"}]}
|
|
@@ -59,7 +59,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
59
59
|
self.assertEqual(result['projects'][0]['name'], "project1")
|
|
60
60
|
self.assertEqual(result['projects'][1]['name'], "project2")
|
|
61
61
|
|
|
62
|
-
@patch("pygeai.core.services.rest.
|
|
62
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
63
63
|
def test_get_project_list_with_name(self, mock_get):
|
|
64
64
|
mock_response = mock_get.return_value
|
|
65
65
|
mock_response.json.return_value = {"projects": [{"name": "specific_project"}]}
|
|
@@ -75,7 +75,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
75
75
|
self.assertEqual(len(result['projects']), 1)
|
|
76
76
|
self.assertEqual(result['projects'][0]['name'], "specific_project")
|
|
77
77
|
|
|
78
|
-
@patch("pygeai.core.services.rest.
|
|
78
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
79
79
|
def test_get_project_list_json_decode_error(self, mock_get):
|
|
80
80
|
mock_response = mock_get.return_value
|
|
81
81
|
mock_response.status_code = 200
|
|
@@ -88,7 +88,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
88
88
|
mock_get.assert_called_once_with(endpoint=GET_PROJECT_LIST_V1, params={"detail": "full"})
|
|
89
89
|
self.assertEqual(str(context.exception), "Unable to get project list: Invalid JSON response")
|
|
90
90
|
|
|
91
|
-
@patch("pygeai.core.services.rest.
|
|
91
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
92
92
|
def test_get_project_data_success(self, mock_get):
|
|
93
93
|
mock_response = mock_get.return_value
|
|
94
94
|
mock_response.json.return_value = {"project": {"id": "123", "name": "project1"}}
|
|
@@ -100,7 +100,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
100
100
|
self.assertIsNotNone(result)
|
|
101
101
|
self.assertEqual(result['project']['name'], "project1")
|
|
102
102
|
|
|
103
|
-
@patch("pygeai.core.services.rest.
|
|
103
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
104
104
|
def test_get_project_data_json_decode_error(self, mock_get):
|
|
105
105
|
mock_response = mock_get.return_value
|
|
106
106
|
mock_response.status_code = 200
|
|
@@ -113,7 +113,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
113
113
|
mock_get.assert_called_once_with(endpoint=GET_PROJECT_V1.format(id="123"))
|
|
114
114
|
self.assertEqual(str(context.exception), "Unable to get project data for ID '123': Invalid JSON response")
|
|
115
115
|
|
|
116
|
-
@patch("pygeai.core.services.rest.
|
|
116
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
117
117
|
def test_create_project_success(self, mock_post):
|
|
118
118
|
mock_response = mock_post.return_value
|
|
119
119
|
mock_response.json.return_value = {"project": {"id": "123", "name": "project1"}}
|
|
@@ -132,7 +132,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
132
132
|
self.assertIsNotNone(result)
|
|
133
133
|
self.assertEqual(result['project']['name'], "project1")
|
|
134
134
|
|
|
135
|
-
@patch("pygeai.core.services.rest.
|
|
135
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
136
136
|
def test_create_project_with_usage_limit(self, mock_post):
|
|
137
137
|
mock_response = mock_post.return_value
|
|
138
138
|
mock_response.json.return_value = {"project": {"id": "123", "name": "project1"}}
|
|
@@ -155,7 +155,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
155
155
|
self.assertIsNotNone(result)
|
|
156
156
|
self.assertEqual(result['project']['name'], "project1")
|
|
157
157
|
|
|
158
|
-
@patch("pygeai.core.services.rest.
|
|
158
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
159
159
|
def test_create_project_json_decode_error(self, mock_post):
|
|
160
160
|
mock_response = mock_post.return_value
|
|
161
161
|
mock_response.status_code = 200
|
|
@@ -175,7 +175,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
175
175
|
)
|
|
176
176
|
self.assertEqual(str(context.exception), "Unable to create project with name 'project1': Invalid JSON response")
|
|
177
177
|
|
|
178
|
-
@patch("pygeai.core.services.rest.
|
|
178
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
179
179
|
def test_update_project_success(self, mock_put):
|
|
180
180
|
mock_response = mock_put.return_value
|
|
181
181
|
mock_response.json.return_value = {"project": {"id": "123", "name": "updated_project"}}
|
|
@@ -190,7 +190,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
190
190
|
self.assertIsNotNone(result)
|
|
191
191
|
self.assertEqual(result['project']['name'], "updated_project")
|
|
192
192
|
|
|
193
|
-
@patch("pygeai.core.services.rest.
|
|
193
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
194
194
|
def test_update_project_json_decode_error(self, mock_put):
|
|
195
195
|
mock_response = mock_put.return_value
|
|
196
196
|
mock_response.status_code = 200
|
|
@@ -206,7 +206,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
206
206
|
)
|
|
207
207
|
self.assertEqual(str(context.exception), "Unable to update project with ID '123': Invalid JSON response")
|
|
208
208
|
|
|
209
|
-
@patch("pygeai.core.services.rest.
|
|
209
|
+
@patch("pygeai.core.services.rest.GEAIApiService.delete")
|
|
210
210
|
def test_delete_project_success(self, mock_delete):
|
|
211
211
|
mock_response = mock_delete.return_value
|
|
212
212
|
mock_response.json.return_value = {"status": "deleted"}
|
|
@@ -218,7 +218,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
218
218
|
self.assertIsNotNone(result)
|
|
219
219
|
self.assertEqual(result['status'], "deleted")
|
|
220
220
|
|
|
221
|
-
@patch("pygeai.core.services.rest.
|
|
221
|
+
@patch("pygeai.core.services.rest.GEAIApiService.delete")
|
|
222
222
|
def test_delete_project_json_decode_error(self, mock_delete):
|
|
223
223
|
mock_response = mock_delete.return_value
|
|
224
224
|
mock_response.status_code = 200
|
|
@@ -231,7 +231,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
231
231
|
mock_delete.assert_called_once_with(endpoint=DELETE_PROJECT_V1.format(id="123"))
|
|
232
232
|
self.assertEqual(str(context.exception), "Unable to delete project with ID '123': Invalid JSON response")
|
|
233
233
|
|
|
234
|
-
@patch("pygeai.core.services.rest.
|
|
234
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
235
235
|
def test_get_project_tokens_success(self, mock_get):
|
|
236
236
|
mock_response = mock_get.return_value
|
|
237
237
|
mock_response.json.return_value = {"tokens": ["token1", "token2"]}
|
|
@@ -245,7 +245,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
245
245
|
self.assertEqual(result['tokens'][0], "token1")
|
|
246
246
|
self.assertEqual(result['tokens'][1], "token2")
|
|
247
247
|
|
|
248
|
-
@patch("pygeai.core.services.rest.
|
|
248
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
249
249
|
def test_get_project_tokens_json_decode_error(self, mock_get):
|
|
250
250
|
mock_response = mock_get.return_value
|
|
251
251
|
mock_response.status_code = 200
|
|
@@ -258,7 +258,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
258
258
|
mock_get.assert_called_once_with(endpoint=GET_PROJECT_TOKENS_V1.format(id="123"))
|
|
259
259
|
self.assertEqual(str(context.exception), "Unable to get tokens for project with ID '123': Invalid JSON response")
|
|
260
260
|
|
|
261
|
-
@patch("pygeai.core.services.rest.
|
|
261
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
262
262
|
def test_export_request_data_success(self, mock_get):
|
|
263
263
|
mock_response = mock_get.return_value
|
|
264
264
|
mock_response.json.return_value = {"requests": [{"id": "1", "status": "pending"}]}
|
|
@@ -274,7 +274,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
274
274
|
self.assertEqual(len(result['requests']), 1)
|
|
275
275
|
self.assertEqual(result['requests'][0]['status'], "pending")
|
|
276
276
|
|
|
277
|
-
@patch("pygeai.core.services.rest.
|
|
277
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
278
278
|
def test_export_request_data_with_params(self, mock_get):
|
|
279
279
|
mock_response = mock_get.return_value
|
|
280
280
|
mock_response.json.return_value = {"requests": [{"id": "1", "status": "completed"}]}
|
|
@@ -290,7 +290,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
290
290
|
self.assertEqual(len(result['requests']), 1)
|
|
291
291
|
self.assertEqual(result['requests'][0]['status'], "completed")
|
|
292
292
|
|
|
293
|
-
@patch("pygeai.core.services.rest.
|
|
293
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
294
294
|
def test_export_request_data_json_decode_error(self, mock_get):
|
|
295
295
|
mock_response = mock_get.return_value
|
|
296
296
|
mock_response.status_code = 200
|
|
@@ -306,7 +306,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
306
306
|
)
|
|
307
307
|
self.assertEqual(str(context.exception), "Unable to export request data: Invalid JSON response")
|
|
308
308
|
|
|
309
|
-
@patch("pygeai.core.services.rest.
|
|
309
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
310
310
|
def test_get_memberships_success(self, mock_get):
|
|
311
311
|
mock_response = mock_get.return_value
|
|
312
312
|
mock_response.json.return_value = {
|
|
@@ -332,7 +332,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
332
332
|
self.assertIsNotNone(result)
|
|
333
333
|
self.assertEqual(result['count'], 1)
|
|
334
334
|
|
|
335
|
-
@patch("pygeai.core.services.rest.
|
|
335
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
336
336
|
def test_get_memberships_with_params(self, mock_get):
|
|
337
337
|
mock_response = mock_get.return_value
|
|
338
338
|
mock_response.json.return_value = {"count": 0, "pages": 0, "organizationsMemberships": []}
|
|
@@ -360,7 +360,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
360
360
|
)
|
|
361
361
|
self.assertIsNotNone(result)
|
|
362
362
|
|
|
363
|
-
@patch("pygeai.core.services.rest.
|
|
363
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
364
364
|
def test_get_memberships_json_decode_error(self, mock_get):
|
|
365
365
|
mock_response = mock_get.return_value
|
|
366
366
|
mock_response.status_code = 200
|
|
@@ -372,39 +372,46 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
372
372
|
|
|
373
373
|
self.assertEqual(str(context.exception), "Unable to get memberships: Invalid JSON response")
|
|
374
374
|
|
|
375
|
-
@patch("pygeai.core.services.rest.
|
|
375
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
376
376
|
def test_get_project_memberships_success(self, mock_get):
|
|
377
377
|
mock_response = mock_get.return_value
|
|
378
|
-
mock_response.json.
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
378
|
+
mock_response.json.side_effect = [
|
|
379
|
+
{"organizationId": "org-123"},
|
|
380
|
+
{
|
|
381
|
+
"count": 1,
|
|
382
|
+
"pages": 1,
|
|
383
|
+
"projectsMemberships": [
|
|
384
|
+
{
|
|
385
|
+
"organizationId": "org-123",
|
|
386
|
+
"organizationName": "Test Org",
|
|
387
|
+
"projectId": "proj-456",
|
|
388
|
+
"projectName": "Test Project",
|
|
389
|
+
"roles": []
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
}
|
|
393
|
+
]
|
|
392
394
|
mock_response.status_code = 200
|
|
393
395
|
|
|
394
396
|
result = self.client.get_project_memberships()
|
|
395
397
|
|
|
396
|
-
mock_get.
|
|
398
|
+
self.assertEqual(mock_get.call_count, 2)
|
|
399
|
+
mock_get.assert_called_with(
|
|
397
400
|
endpoint=GET_PROJECT_MEMBERSHIPS_V2,
|
|
398
|
-
params={"startPage": 1, "pageSize": 20, "orderDirection": "desc"}
|
|
401
|
+
params={"startPage": 1, "pageSize": 20, "orderDirection": "desc"},
|
|
402
|
+
headers={"organization-id": "org-123"}
|
|
399
403
|
)
|
|
400
404
|
self.assertIsNotNone(result)
|
|
401
405
|
self.assertEqual(result['count'], 1)
|
|
402
406
|
|
|
403
|
-
@patch("pygeai.core.services.rest.
|
|
407
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
404
408
|
def test_get_project_memberships_json_decode_error(self, mock_get):
|
|
405
409
|
mock_response = mock_get.return_value
|
|
406
410
|
mock_response.status_code = 200
|
|
407
|
-
mock_response.json.side_effect =
|
|
411
|
+
mock_response.json.side_effect = [
|
|
412
|
+
{"organizationId": "org-123"},
|
|
413
|
+
JSONDecodeError("Invalid JSON", "", 0)
|
|
414
|
+
]
|
|
408
415
|
mock_response.text = "Invalid JSON response"
|
|
409
416
|
|
|
410
417
|
with self.assertRaises(InvalidAPIResponseException) as context:
|
|
@@ -412,7 +419,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
412
419
|
|
|
413
420
|
self.assertEqual(str(context.exception), "Unable to get project memberships: Invalid JSON response")
|
|
414
421
|
|
|
415
|
-
@patch("pygeai.core.services.rest.
|
|
422
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
416
423
|
def test_get_project_roles_success(self, mock_get):
|
|
417
424
|
mock_response = mock_get.return_value
|
|
418
425
|
mock_response.json.return_value = {
|
|
@@ -425,11 +432,15 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
425
432
|
|
|
426
433
|
result = self.client.get_project_roles(project_id="proj-123")
|
|
427
434
|
|
|
428
|
-
mock_get.assert_called_once_with(
|
|
435
|
+
mock_get.assert_called_once_with(
|
|
436
|
+
endpoint=GET_PROJECT_ROLES_V2,
|
|
437
|
+
params={"startPage": 1, "pageSize": 20, "orderDirection": "desc"},
|
|
438
|
+
headers={"project-id": "proj-123"}
|
|
439
|
+
)
|
|
429
440
|
self.assertIsNotNone(result)
|
|
430
441
|
self.assertEqual(len(result['roles']), 1)
|
|
431
442
|
|
|
432
|
-
@patch("pygeai.core.services.rest.
|
|
443
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
433
444
|
def test_get_project_roles_json_decode_error(self, mock_get):
|
|
434
445
|
mock_response = mock_get.return_value
|
|
435
446
|
mock_response.status_code = 200
|
|
@@ -441,7 +452,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
441
452
|
|
|
442
453
|
self.assertEqual(str(context.exception), "Unable to get project roles for project 'proj-123': Invalid JSON response")
|
|
443
454
|
|
|
444
|
-
@patch("pygeai.core.services.rest.
|
|
455
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
445
456
|
def test_get_project_members_success(self, mock_get):
|
|
446
457
|
mock_response = mock_get.return_value
|
|
447
458
|
mock_response.json.return_value = {
|
|
@@ -454,11 +465,15 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
454
465
|
|
|
455
466
|
result = self.client.get_project_members(project_id="proj-123")
|
|
456
467
|
|
|
457
|
-
mock_get.assert_called_once_with(
|
|
468
|
+
mock_get.assert_called_once_with(
|
|
469
|
+
endpoint=GET_PROJECT_MEMBERS_V2,
|
|
470
|
+
params={"startPage": 1, "pageSize": 20, "orderDirection": "desc"},
|
|
471
|
+
headers={"project-id": "proj-123"}
|
|
472
|
+
)
|
|
458
473
|
self.assertIsNotNone(result)
|
|
459
474
|
self.assertEqual(len(result['members']), 1)
|
|
460
475
|
|
|
461
|
-
@patch("pygeai.core.services.rest.
|
|
476
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
462
477
|
def test_get_project_members_json_decode_error(self, mock_get):
|
|
463
478
|
mock_response = mock_get.return_value
|
|
464
479
|
mock_response.status_code = 200
|
|
@@ -470,7 +485,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
470
485
|
|
|
471
486
|
self.assertEqual(str(context.exception), "Unable to get project members for project 'proj-123': Invalid JSON response")
|
|
472
487
|
|
|
473
|
-
@patch("pygeai.core.services.rest.
|
|
488
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
474
489
|
def test_get_organization_members_success(self, mock_get):
|
|
475
490
|
mock_response = mock_get.return_value
|
|
476
491
|
mock_response.json.return_value = {
|
|
@@ -483,11 +498,14 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
483
498
|
|
|
484
499
|
result = self.client.get_organization_members(organization_id="org-123")
|
|
485
500
|
|
|
486
|
-
mock_get.assert_called_once_with(
|
|
501
|
+
mock_get.assert_called_once_with(
|
|
502
|
+
endpoint=GET_ORGANIZATION_MEMBERS_V2,
|
|
503
|
+
params={"organizationId": "org-123", "startPage": 1, "pageSize": 20, "orderDirection": "desc"}
|
|
504
|
+
)
|
|
487
505
|
self.assertIsNotNone(result)
|
|
488
506
|
self.assertEqual(len(result['members']), 1)
|
|
489
507
|
|
|
490
|
-
@patch("pygeai.core.services.rest.
|
|
508
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
491
509
|
def test_get_organization_members_json_decode_error(self, mock_get):
|
|
492
510
|
mock_response = mock_get.return_value
|
|
493
511
|
mock_response.status_code = 200
|
|
@@ -499,7 +517,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
499
517
|
|
|
500
518
|
self.assertEqual(str(context.exception), "Unable to get organization members for organization 'org-123': Invalid JSON response")
|
|
501
519
|
|
|
502
|
-
@patch("pygeai.core.services.rest.
|
|
520
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
503
521
|
def test_add_project_member_success(self, mock_post):
|
|
504
522
|
mock_response = mock_post.return_value
|
|
505
523
|
mock_response.json.return_value = {"status": "invitation sent"}
|
|
@@ -522,7 +540,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
522
540
|
self.assertIsNotNone(result)
|
|
523
541
|
self.assertEqual(result['status'], "invitation sent")
|
|
524
542
|
|
|
525
|
-
@patch("pygeai.core.services.rest.
|
|
543
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
526
544
|
def test_add_project_member_with_role_guids(self, mock_post):
|
|
527
545
|
mock_response = mock_post.return_value
|
|
528
546
|
mock_response.json.return_value = {"status": "invitation sent"}
|
|
@@ -544,7 +562,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
544
562
|
)
|
|
545
563
|
self.assertIsNotNone(result)
|
|
546
564
|
|
|
547
|
-
@patch("pygeai.core.services.rest.
|
|
565
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
548
566
|
def test_add_project_member_json_decode_error(self, mock_post):
|
|
549
567
|
mock_response = mock_post.return_value
|
|
550
568
|
mock_response.status_code = 201
|
|
@@ -560,7 +578,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
560
578
|
|
|
561
579
|
self.assertEqual(str(context.exception), "Unable to add project member 'newuser@example.com': Invalid JSON response")
|
|
562
580
|
|
|
563
|
-
@patch("pygeai.core.services.rest.
|
|
581
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
564
582
|
def test_create_organization_success(self, mock_post):
|
|
565
583
|
mock_response = mock_post.return_value
|
|
566
584
|
mock_response.json.return_value = {"organizationId": "org-123", "organizationName": "Test Org"}
|
|
@@ -578,7 +596,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
578
596
|
self.assertIsNotNone(result)
|
|
579
597
|
self.assertEqual(result['organizationName'], "Test Org")
|
|
580
598
|
|
|
581
|
-
@patch("pygeai.core.services.rest.
|
|
599
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
582
600
|
def test_create_organization_json_decode_error(self, mock_post):
|
|
583
601
|
mock_response = mock_post.return_value
|
|
584
602
|
mock_response.status_code = 201
|
|
@@ -590,7 +608,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
590
608
|
|
|
591
609
|
self.assertEqual(str(context.exception), "Unable to create organization with name 'Test Org': Invalid JSON response")
|
|
592
610
|
|
|
593
|
-
@patch("pygeai.core.services.rest.
|
|
611
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
594
612
|
def test_get_organization_list_success(self, mock_get):
|
|
595
613
|
mock_response = mock_get.return_value
|
|
596
614
|
mock_response.json.return_value = {
|
|
@@ -613,7 +631,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
613
631
|
self.assertEqual(result['count'], 2)
|
|
614
632
|
self.assertEqual(len(result['organizations']), 2)
|
|
615
633
|
|
|
616
|
-
@patch("pygeai.core.services.rest.
|
|
634
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
617
635
|
def test_get_organization_list_with_filters(self, mock_get):
|
|
618
636
|
mock_response = mock_get.return_value
|
|
619
637
|
mock_response.json.return_value = {"count": 1, "pages": 1, "organizations": [{"organizationId": "org-1", "organizationName": "Test"}]}
|
|
@@ -641,7 +659,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
641
659
|
)
|
|
642
660
|
self.assertIsNotNone(result)
|
|
643
661
|
|
|
644
|
-
@patch("pygeai.core.services.rest.
|
|
662
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
645
663
|
def test_get_organization_list_json_decode_error(self, mock_get):
|
|
646
664
|
mock_response = mock_get.return_value
|
|
647
665
|
mock_response.status_code = 200
|
|
@@ -653,7 +671,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
653
671
|
|
|
654
672
|
self.assertEqual(str(context.exception), "Unable to get organization list: Invalid JSON response")
|
|
655
673
|
|
|
656
|
-
@patch("pygeai.core.services.rest.
|
|
674
|
+
@patch("pygeai.core.services.rest.GEAIApiService.delete")
|
|
657
675
|
def test_delete_organization_success(self, mock_delete):
|
|
658
676
|
mock_response = mock_delete.return_value
|
|
659
677
|
mock_response.json.return_value = {"status": "deleted"}
|
|
@@ -665,7 +683,7 @@ class TestOrganizationClient(unittest.TestCase):
|
|
|
665
683
|
self.assertIsNotNone(result)
|
|
666
684
|
self.assertEqual(result['status'], "deleted")
|
|
667
685
|
|
|
668
|
-
@patch("pygeai.core.services.rest.
|
|
686
|
+
@patch("pygeai.core.services.rest.GEAIApiService.delete")
|
|
669
687
|
def test_delete_organization_json_decode_error(self, mock_delete):
|
|
670
688
|
mock_response = mock_delete.return_value
|
|
671
689
|
mock_response.status_code = 200
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import unittest
|
|
2
|
-
from unittest.mock import Mock, patch,
|
|
3
|
-
import asyncio
|
|
2
|
+
from unittest.mock import Mock, patch, AsyncMock
|
|
4
3
|
import uuid
|
|
5
4
|
import json
|
|
6
5
|
import sys
|
|
@@ -10,8 +9,6 @@ from pygeai.proxy.config import ProxySettingsManager
|
|
|
10
9
|
from pygeai.proxy.tool import ProxiedTool
|
|
11
10
|
from pygeai.proxy.clients import ProxyClient, ToolProxyData, ToolProxyJob, ToolProxyJobResult
|
|
12
11
|
from pygeai.proxy.managers import ServerManager
|
|
13
|
-
from pygeai.proxy.servers import A2AServer, MCPServer
|
|
14
|
-
from types import SimpleNamespace
|
|
15
12
|
|
|
16
13
|
|
|
17
14
|
class TestProxyIntegration(unittest.IsolatedAsyncioTestCase):
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import unittest
|
|
2
|
-
from unittest.mock import Mock, patch,
|
|
2
|
+
from unittest.mock import Mock, patch, AsyncMock
|
|
3
3
|
import asyncio
|
|
4
4
|
import json
|
|
5
5
|
import uuid
|
|
6
6
|
from pygeai.proxy.managers import ServerManager
|
|
7
7
|
from pygeai.proxy.config import ProxySettingsManager
|
|
8
|
-
from pygeai.proxy.clients import ProxyClient, ToolProxyData, ToolProxyJobResult
|
|
9
8
|
from pygeai.proxy.tool import ProxiedTool
|
|
10
9
|
|
|
11
10
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import unittest
|
|
2
|
-
from unittest.mock import Mock, patch,
|
|
3
|
-
import asyncio
|
|
2
|
+
from unittest.mock import Mock, patch, AsyncMock
|
|
4
3
|
import httpx
|
|
5
4
|
from pygeai.proxy.servers import ToolServer, MCPServer, A2AServer
|
|
6
5
|
from pygeai.proxy.config import ProxySettingsManager
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Example of debugging a standalone Python file using geai-dbg.
|
|
3
|
+
|
|
4
|
+
This demonstrates how to use debug_file() to debug any Python script.
|
|
5
|
+
"""
|
|
6
|
+
from pygeai.dbg import debug_file
|
|
7
|
+
import tempfile
|
|
8
|
+
import os
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def create_sample_script():
|
|
12
|
+
"""Create a sample script to debug."""
|
|
13
|
+
code = '''
|
|
14
|
+
def process_data(items):
|
|
15
|
+
"""Process a list of items."""
|
|
16
|
+
result = []
|
|
17
|
+
for item in items:
|
|
18
|
+
result.append(item * 2)
|
|
19
|
+
return result
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def main():
|
|
23
|
+
"""Main entry point."""
|
|
24
|
+
data = [1, 2, 3, 4, 5]
|
|
25
|
+
processed = process_data(data)
|
|
26
|
+
print(f"Processed: {processed}")
|
|
27
|
+
return processed
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if __name__ == "__main__":
|
|
31
|
+
main()
|
|
32
|
+
'''
|
|
33
|
+
|
|
34
|
+
fd, filepath = tempfile.mkstemp(suffix='.py', text=True)
|
|
35
|
+
try:
|
|
36
|
+
os.write(fd, code.encode())
|
|
37
|
+
finally:
|
|
38
|
+
os.close(fd)
|
|
39
|
+
|
|
40
|
+
return filepath
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def main():
|
|
44
|
+
"""Demonstrate file debugging."""
|
|
45
|
+
print("Creating sample script...")
|
|
46
|
+
script_path = create_sample_script()
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
print(f"Script created at: {script_path}")
|
|
50
|
+
print("\nSetting up debugger...")
|
|
51
|
+
|
|
52
|
+
dbg = debug_file(script_path)
|
|
53
|
+
dbg.add_breakpoint(function_name='process_data')
|
|
54
|
+
|
|
55
|
+
print("Debugger configured with breakpoint on 'process_data'")
|
|
56
|
+
print("\nTo run interactively, uncomment the line below:")
|
|
57
|
+
print("# dbg.run()")
|
|
58
|
+
print("\nCommands you can use:")
|
|
59
|
+
print(" c - continue")
|
|
60
|
+
print(" s - step into")
|
|
61
|
+
print(" n - next line")
|
|
62
|
+
print(" p - print variable (e.g., 'p items')")
|
|
63
|
+
print(" l - list source")
|
|
64
|
+
print(" h - help")
|
|
65
|
+
|
|
66
|
+
finally:
|
|
67
|
+
os.unlink(script_path)
|
|
68
|
+
print(f"\nCleaned up {script_path}")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
main()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Example of debugging a specific module and function using geai-dbg.
|
|
3
|
+
|
|
4
|
+
This demonstrates how to use debug_module() to debug imported modules.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def example_simple_module():
|
|
9
|
+
"""Debug a simple built-in module."""
|
|
10
|
+
print("Example: Debugging os.path.exists function")
|
|
11
|
+
print("\nThis would set up a debugger for the os.path.exists function:")
|
|
12
|
+
print(" dbg = debug_module('os.path', 'exists')")
|
|
13
|
+
print(" dbg.run()")
|
|
14
|
+
print("\nNote: This is for demonstration. Built-in functions may not be traceable.")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def example_pygeai_module():
|
|
18
|
+
"""Debug a PyGEAI module."""
|
|
19
|
+
print("\nExample: Debugging PyGEAI modules")
|
|
20
|
+
print("\nYou can debug any PyGEAI module function:")
|
|
21
|
+
print(" from pygeai.dbg import debug_module")
|
|
22
|
+
print(" ")
|
|
23
|
+
print(" # Debug the chat module")
|
|
24
|
+
print(" dbg = debug_module('pygeai.chat', 'send_message')")
|
|
25
|
+
print(" dbg.add_breakpoint(module='pygeai.core.llm', function_name='get_completion')")
|
|
26
|
+
print(" dbg.run()")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def example_cli_debugging():
|
|
30
|
+
"""Debug the geai CLI programmatically."""
|
|
31
|
+
print("\nExample: Debugging geai CLI programmatically")
|
|
32
|
+
print("\nInstead of using 'geai-dbg', you can set it up in code:")
|
|
33
|
+
print(" from pygeai.dbg import debug_module")
|
|
34
|
+
print(" ")
|
|
35
|
+
print(" # Set up debugging with custom breakpoints")
|
|
36
|
+
print(" dbg = debug_module('pygeai.cli.geai', 'main')")
|
|
37
|
+
print(" dbg.add_breakpoint(module='pygeai.cli.commands', function_name='execute')")
|
|
38
|
+
print(" dbg.run()")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def main():
|
|
42
|
+
"""Run all examples."""
|
|
43
|
+
print("=" * 70)
|
|
44
|
+
print("Module Debugging Examples")
|
|
45
|
+
print("=" * 70)
|
|
46
|
+
|
|
47
|
+
example_simple_module()
|
|
48
|
+
example_pygeai_module()
|
|
49
|
+
example_cli_debugging()
|
|
50
|
+
|
|
51
|
+
print("\n" + "=" * 70)
|
|
52
|
+
print("To use module debugging from the command line:")
|
|
53
|
+
print("=" * 70)
|
|
54
|
+
print(" geai-dbg -m pygeai.cli.geai:main")
|
|
55
|
+
print(" geai-dbg -m pygeai.chat:send_message -b process_response")
|
|
56
|
+
print("=" * 70)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
main()
|
|
@@ -21,7 +21,7 @@ configuration = EmbeddingConfiguration(
|
|
|
21
21
|
embeddings = manager.generate_embeddings(configuration)
|
|
22
22
|
|
|
23
23
|
print(f"Model: {embeddings.model}")
|
|
24
|
-
print(
|
|
24
|
+
print("Input type: search_document")
|
|
25
25
|
print(f"Documents embedded: {len(embeddings.data)}")
|
|
26
26
|
print(f"Usage - Prompt tokens: {embeddings.usage.prompt_tokens}")
|
|
27
27
|
print(f"Usage - Total cost: ${embeddings.usage.total_cost} {embeddings.usage.currency}")
|
|
@@ -37,5 +37,5 @@ query_configuration = EmbeddingConfiguration(
|
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
query_embeddings = manager.generate_embeddings(query_configuration)
|
|
40
|
-
print(
|
|
40
|
+
print("\nQuery embedded with input_type: search_query")
|
|
41
41
|
print(f"Usage - Total cost: ${query_embeddings.usage.total_cost} {query_embeddings.usage.currency}")
|
|
@@ -21,7 +21,7 @@ configuration = EmbeddingConfiguration(
|
|
|
21
21
|
embeddings = manager.generate_embeddings(configuration)
|
|
22
22
|
|
|
23
23
|
print(f"Model: {embeddings.model}")
|
|
24
|
-
print(
|
|
24
|
+
print("Encoding format: base64")
|
|
25
25
|
print(f"Embedding (base64 encoded, first 100 chars): {embeddings.data[0].embedding[:100]}")
|
|
26
26
|
print(f"Type of embedding: {type(embeddings.data[0].embedding)}")
|
|
27
27
|
print(f"Usage - Total cost: ${embeddings.usage.total_cost} {embeddings.usage.currency}")
|