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.
- 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.6.1.dist-info}/METADATA +32 -7
- {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/RECORD +216 -205
- {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/WHEEL +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/entry_points.txt +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.6.1.dist-info}/top_level.txt +0 -0
|
@@ -4,16 +4,17 @@ PyGEAI Debugger
|
|
|
4
4
|
Overview
|
|
5
5
|
--------
|
|
6
6
|
|
|
7
|
-
``geai-dbg`` is
|
|
7
|
+
``geai-dbg`` is an interactive command-line debugger for PyGEAI applications. It enables developers to debug the ``geai`` CLI, custom Python scripts that use PyGEAI, or specific PyGEAI modules. The debugger pauses execution at specified breakpoints, allowing inspection of variables, stack navigation, code stepping, and interactive control of program flow.
|
|
8
8
|
|
|
9
9
|
The debugger provides features similar to Python's built-in ``pdb`` debugger, including:
|
|
10
10
|
|
|
11
|
-
- **
|
|
11
|
+
- **Multiple debugging modes**: Debug geai CLI, Python files, or specific modules
|
|
12
|
+
- **Breakpoint management**: Set, list, enable/disable, and remove breakpoints with optional conditions
|
|
12
13
|
- **Stepping**: Step into, over, and out of function calls
|
|
13
14
|
- **Stack navigation**: Move up and down the call stack to inspect different frames
|
|
14
15
|
- **Variable inspection**: Print, pretty-print, and examine local/global variables
|
|
15
16
|
- **Source code display**: View source code around the current execution point
|
|
16
|
-
- **Performance optimization**:
|
|
17
|
+
- **Performance optimization**: Module filtering to minimize overhead
|
|
17
18
|
- **Command history**: Uses readline for command history and editing
|
|
18
19
|
|
|
19
20
|
Installation and Setup
|
|
@@ -25,52 +26,130 @@ Installation and Setup
|
|
|
25
26
|
|
|
26
27
|
pip install pygeai
|
|
27
28
|
|
|
28
|
-
No additional setup is required. The debugger
|
|
29
|
+
No additional setup is required. The debugger is located in the ``pygeai.dbg`` module and can be invoked via the ``geai-dbg`` command.
|
|
29
30
|
|
|
30
|
-
Usage
|
|
31
|
-
|
|
31
|
+
Usage Modes
|
|
32
|
+
-----------
|
|
33
|
+
|
|
34
|
+
The debugger supports three distinct usage modes:
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
Mode 1: Debug geai CLI (Default)
|
|
37
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
Debug the ``geai`` CLI tool with your command arguments:
|
|
37
40
|
|
|
38
41
|
.. code-block:: bash
|
|
39
42
|
|
|
43
|
+
geai-dbg
|
|
40
44
|
geai-dbg ail lrs
|
|
45
|
+
geai-dbg chat "Hello, AI"
|
|
41
46
|
|
|
42
|
-
This
|
|
47
|
+
This runs the ``geai`` CLI under the debugger with an automatic breakpoint at ``pygeai.cli.geai:main``.
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
Mode 2: Debug Python Files
|
|
50
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
- Source code context around the current line
|
|
48
|
-
- An interactive prompt ``(geai-dbg)`` for entering commands
|
|
52
|
+
Debug any Python script that uses PyGEAI:
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
.. code-block:: bash
|
|
55
|
+
|
|
56
|
+
geai-dbg my_script.py
|
|
57
|
+
geai-dbg my_script.py --input data.csv --output results.json
|
|
58
|
+
geai-dbg -b process_data my_script.py
|
|
59
|
+
|
|
60
|
+
The debugger automatically detects whether your script imports PyGEAI and adjusts module filtering accordingly.
|
|
61
|
+
|
|
62
|
+
Mode 3: Debug Specific Modules
|
|
63
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
64
|
+
|
|
65
|
+
Debug a specific module and function directly:
|
|
66
|
+
|
|
67
|
+
.. code-block:: bash
|
|
68
|
+
|
|
69
|
+
geai-dbg -m pygeai.cli.geai:main
|
|
70
|
+
geai-dbg -m pygeai.chat:send_message -b process_response
|
|
71
|
+
|
|
72
|
+
This imports the module, sets up debugging, and runs the specified function.
|
|
73
|
+
|
|
74
|
+
Command-Line Options
|
|
75
|
+
--------------------
|
|
76
|
+
|
|
77
|
+
.. code-block:: text
|
|
78
|
+
|
|
79
|
+
geai-dbg [OPTIONS] [target] [args...]
|
|
80
|
+
|
|
81
|
+
Options:
|
|
82
|
+
-h, --help Show help message
|
|
83
|
+
-m MODULE:FUNC Debug a module function (e.g., pygeai.cli.geai:main)
|
|
84
|
+
-b BREAKPOINT Set initial breakpoint ([module:]function)
|
|
85
|
+
--filter PREFIX Only trace modules with this prefix
|
|
86
|
+
--trace-all Trace all modules (warning: slow)
|
|
87
|
+
-v, --verbose Enable verbose logging for pygeai modules
|
|
88
|
+
--log-level LEVEL Log level for verbose mode: DEBUG, INFO, WARNING, ERROR (default: DEBUG)
|
|
89
|
+
|
|
90
|
+
Examples:
|
|
91
|
+
geai-dbg Debug the geai CLI
|
|
92
|
+
geai-dbg script.py arg1 arg2 Debug a Python file with arguments
|
|
93
|
+
geai-dbg -v script.py Debug with verbose logging (DEBUG level)
|
|
94
|
+
geai-dbg -v --log-level INFO script.py Debug with INFO level logging
|
|
95
|
+
geai-dbg -m pygeai.cli.geai:main Debug a specific module function
|
|
96
|
+
geai-dbg -b main script.py Break on 'main' function
|
|
97
|
+
geai-dbg --filter pygeai script.py Only trace pygeai modules
|
|
98
|
+
|
|
99
|
+
Programmatic Usage
|
|
100
|
+
------------------
|
|
101
|
+
|
|
102
|
+
Debug a Python File
|
|
103
|
+
~~~~~~~~~~~~~~~~~~~
|
|
104
|
+
|
|
105
|
+
.. code-block:: python
|
|
106
|
+
|
|
107
|
+
from pygeai.dbg import debug_file
|
|
108
|
+
|
|
109
|
+
# Set up debugger for a file
|
|
110
|
+
dbg = debug_file('my_script.py', args=['--verbose'])
|
|
111
|
+
dbg.add_breakpoint(function_name='process_data')
|
|
112
|
+
dbg.add_breakpoint(module='pygeai.chat', function_name='send_message')
|
|
113
|
+
|
|
114
|
+
# Run with debugging
|
|
115
|
+
dbg.run()
|
|
116
|
+
|
|
117
|
+
# Enable verbose logging with custom log level
|
|
118
|
+
dbg = debug_file('my_script.py', verbose=True, log_level='INFO')
|
|
119
|
+
dbg.run()
|
|
120
|
+
|
|
121
|
+
Debug a Module
|
|
122
|
+
~~~~~~~~~~~~~~
|
|
123
|
+
|
|
124
|
+
.. code-block:: python
|
|
52
125
|
|
|
53
|
-
|
|
126
|
+
from pygeai.dbg import debug_module
|
|
127
|
+
|
|
128
|
+
# Debug a specific module function
|
|
129
|
+
dbg = debug_module('pygeai.cli.geai', 'main')
|
|
130
|
+
dbg.add_breakpoint(module='pygeai.core.llm', function_name='get_completion')
|
|
131
|
+
dbg.run()
|
|
132
|
+
|
|
133
|
+
Advanced Configuration
|
|
134
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
|
54
135
|
|
|
55
136
|
.. code-block:: python
|
|
56
137
|
|
|
57
|
-
from pygeai.dbg
|
|
138
|
+
from pygeai.dbg import Debugger
|
|
58
139
|
|
|
59
140
|
def my_function():
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
dbg = Debugger(target=my_function, module_filter="__main__")
|
|
67
|
-
dbg.add_breakpoint(module="__main__", function_name="my_function")
|
|
141
|
+
# Your code here
|
|
142
|
+
pass
|
|
143
|
+
|
|
144
|
+
# Create custom debugger
|
|
145
|
+
dbg = Debugger(target=my_function, module_filter='') # Trace all modules
|
|
146
|
+
dbg.add_breakpoint(function_name='helper_func', condition='x > 100')
|
|
68
147
|
dbg.run()
|
|
69
148
|
|
|
70
|
-
Commands
|
|
71
|
-
|
|
149
|
+
Interactive Commands
|
|
150
|
+
--------------------
|
|
72
151
|
|
|
73
|
-
|
|
152
|
+
Once paused at a breakpoint, the following commands are available at the ``(geai-dbg)`` prompt:
|
|
74
153
|
|
|
75
154
|
Flow Control
|
|
76
155
|
~~~~~~~~~~~~
|
|
@@ -90,13 +169,13 @@ Flow Control
|
|
|
90
169
|
**run, r**
|
|
91
170
|
Run the program to completion, disabling all breakpoints and skipping further pauses.
|
|
92
171
|
|
|
93
|
-
**quit, q
|
|
172
|
+
**quit, q**
|
|
94
173
|
Exit the debugger, terminating the program with a clean exit status (0).
|
|
95
174
|
|
|
96
175
|
Stack Navigation
|
|
97
176
|
~~~~~~~~~~~~~~~~
|
|
98
177
|
|
|
99
|
-
**where, w, bt
|
|
178
|
+
**where, w, bt**
|
|
100
179
|
Display the stack trace, showing all frames from the current execution point to the top of the call stack.
|
|
101
180
|
|
|
102
181
|
**up, u**
|
|
@@ -167,20 +246,6 @@ Breakpoint Management
|
|
|
167
246
|
|
|
168
247
|
Example: ``dis main``
|
|
169
248
|
|
|
170
|
-
Legacy Commands
|
|
171
|
-
~~~~~~~~~~~~~~~
|
|
172
|
-
|
|
173
|
-
These commands are maintained for backward compatibility:
|
|
174
|
-
|
|
175
|
-
**breakpoint-module, bm**
|
|
176
|
-
Add a breakpoint for a specific module (interactive prompt).
|
|
177
|
-
|
|
178
|
-
**breakpoint-function, bf**
|
|
179
|
-
Add a breakpoint for a specific function (interactive prompt).
|
|
180
|
-
|
|
181
|
-
**list-modules, lm**
|
|
182
|
-
List all loaded modules starting with the module filter (default: ``pygeai``).
|
|
183
|
-
|
|
184
249
|
Other Commands
|
|
185
250
|
~~~~~~~~~~~~~~
|
|
186
251
|
|
|
@@ -188,18 +253,59 @@ Other Commands
|
|
|
188
253
|
Display a list of available commands and their descriptions.
|
|
189
254
|
|
|
190
255
|
**<Python code>**
|
|
191
|
-
Execute arbitrary Python code in the current frame's context. For example, ``x = 42`` or ``print(sys.argv)``.
|
|
192
|
-
|
|
193
|
-
**Ctrl+C**
|
|
194
|
-
Interrupt the current command input and resume execution, equivalent to ``continue``.
|
|
256
|
+
Execute arbitrary Python code in the current frame's context. For example, ``x = 42`` or ``print(sys.argv)``.
|
|
195
257
|
|
|
196
258
|
Examples
|
|
197
259
|
--------
|
|
198
260
|
|
|
199
|
-
Example 1:
|
|
261
|
+
Example 1: Debug a Chat Application
|
|
262
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
263
|
+
|
|
264
|
+
Create a chat application script:
|
|
265
|
+
|
|
266
|
+
.. code-block:: python
|
|
267
|
+
|
|
268
|
+
# chat_app.py
|
|
269
|
+
from pygeai.chat import ChatClient
|
|
270
|
+
|
|
271
|
+
def process_message(message):
|
|
272
|
+
client = ChatClient()
|
|
273
|
+
response = client.send_message(message)
|
|
274
|
+
return response.content
|
|
275
|
+
|
|
276
|
+
def main():
|
|
277
|
+
msg = "Hello, AI!"
|
|
278
|
+
result = process_message(msg)
|
|
279
|
+
print(result)
|
|
280
|
+
|
|
281
|
+
if __name__ == "__main__":
|
|
282
|
+
main()
|
|
283
|
+
|
|
284
|
+
Debug it:
|
|
285
|
+
|
|
286
|
+
.. code-block:: bash
|
|
287
|
+
|
|
288
|
+
# Break on process_message
|
|
289
|
+
geai-dbg -b process_message chat_app.py
|
|
290
|
+
|
|
291
|
+
# Or with module-specific breakpoint
|
|
292
|
+
geai-dbg -b pygeai.chat:send_message chat_app.py
|
|
293
|
+
|
|
294
|
+
Interactive session:
|
|
295
|
+
|
|
296
|
+
.. code-block:: text
|
|
297
|
+
|
|
298
|
+
(geai-dbg) p message
|
|
299
|
+
'Hello, AI!'
|
|
300
|
+
(geai-dbg) s # Step into send_message
|
|
301
|
+
(geai-dbg) l # List source code
|
|
302
|
+
(geai-dbg) p self.config # Inspect client configuration
|
|
303
|
+
(geai-dbg) c # Continue
|
|
304
|
+
|
|
305
|
+
Example 2: Debug geai CLI
|
|
200
306
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
201
307
|
|
|
202
|
-
Debug the ``geai
|
|
308
|
+
Debug the ``geai`` CLI with specific arguments:
|
|
203
309
|
|
|
204
310
|
.. code-block:: bash
|
|
205
311
|
|
|
@@ -209,10 +315,10 @@ Output:
|
|
|
209
315
|
|
|
210
316
|
.. code-block:: text
|
|
211
317
|
|
|
212
|
-
2026-01-
|
|
213
|
-
2026-01-
|
|
214
|
-
2026-01-
|
|
215
|
-
2026-01-
|
|
318
|
+
2026-01-14 15:04:57,263 - geai.dbg - INFO - GEAI debugger started.
|
|
319
|
+
2026-01-14 15:04:57,264 - geai.dbg - INFO - Breakpoint added: pygeai.cli.geai:main (enabled, hits: 0)
|
|
320
|
+
2026-01-14 15:04:57,264 - geai.dbg - INFO - Setting trace and running target
|
|
321
|
+
2026-01-14 15:04:57,264 - geai.dbg - INFO - Breakpoint hit at pygeai.cli.geai.main (hit #1)
|
|
216
322
|
|
|
217
323
|
============================================================
|
|
218
324
|
Paused at pygeai.cli.geai.main (line 42)
|
|
@@ -227,45 +333,44 @@ Output:
|
|
|
227
333
|
45
|
|
228
334
|
============================================================
|
|
229
335
|
Type 'h' for help, 'c' to continue
|
|
230
|
-
(geai-dbg)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
336
|
+
(geai-dbg) p sys.argv
|
|
337
|
+
['geai', 'ail', 'lrs']
|
|
338
|
+
(geai-dbg) c
|
|
234
339
|
|
|
235
|
-
|
|
340
|
+
Example 3: Debug with Conditional Breakpoints
|
|
341
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
236
342
|
|
|
237
|
-
.. code-block::
|
|
343
|
+
.. code-block:: python
|
|
238
344
|
|
|
239
|
-
|
|
240
|
-
# Steps into the next function call
|
|
345
|
+
from pygeai.dbg import debug_file
|
|
241
346
|
|
|
242
|
-
(
|
|
243
|
-
# Steps over function calls, staying in the current function
|
|
347
|
+
dbg = debug_file('process_data.py')
|
|
244
348
|
|
|
245
|
-
|
|
246
|
-
|
|
349
|
+
# Only break when count exceeds 1000
|
|
350
|
+
dbg.add_breakpoint(
|
|
351
|
+
function_name='process_batch',
|
|
352
|
+
condition='len(batch) > 1000'
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
dbg.run()
|
|
247
356
|
|
|
248
|
-
Example
|
|
249
|
-
|
|
357
|
+
Example 4: Debug SDK Internals
|
|
358
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
250
359
|
|
|
251
|
-
|
|
360
|
+
.. code-block:: bash
|
|
361
|
+
|
|
362
|
+
# Debug the CLI and inspect how commands are processed
|
|
363
|
+
geai-dbg -m pygeai.cli.geai:main -b parse_command
|
|
364
|
+
|
|
365
|
+
Interactive session:
|
|
252
366
|
|
|
253
367
|
.. code-block:: text
|
|
254
368
|
|
|
255
|
-
(geai-dbg) p
|
|
256
|
-
42
|
|
257
|
-
|
|
369
|
+
(geai-dbg) p command
|
|
258
370
|
(geai-dbg) pp locals()
|
|
259
|
-
|
|
260
|
-
'y': 20,
|
|
261
|
-
'result': 62}
|
|
262
|
-
|
|
263
|
-
(geai-dbg) args
|
|
264
|
-
Function arguments:
|
|
265
|
-
self = <pygeai.cli.geai.CLIDriver object at 0x...>
|
|
266
|
-
args = None
|
|
371
|
+
(geai-dbg) where # See the full call stack
|
|
267
372
|
|
|
268
|
-
Example
|
|
373
|
+
Example 5: Stack Navigation
|
|
269
374
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
270
375
|
|
|
271
376
|
Navigate the call stack:
|
|
@@ -288,7 +393,7 @@ Navigate the call stack:
|
|
|
288
393
|
(geai-dbg) down
|
|
289
394
|
Frame #1: __main__.level_3
|
|
290
395
|
|
|
291
|
-
Example
|
|
396
|
+
Example 6: Breakpoint Management
|
|
292
397
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
293
398
|
|
|
294
399
|
Manage breakpoints during debugging:
|
|
@@ -311,21 +416,35 @@ Manage breakpoints during debugging:
|
|
|
311
416
|
(geai-dbg) cl pygeai.core:helper_function
|
|
312
417
|
Breakpoint removed: pygeai.core:helper_function
|
|
313
418
|
|
|
314
|
-
Example
|
|
315
|
-
|
|
419
|
+
Example 7: Verbose Logging
|
|
420
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
316
421
|
|
|
317
|
-
|
|
422
|
+
Debug with verbose logging to see PyGEAI internal logs:
|
|
318
423
|
|
|
319
|
-
.. code-block::
|
|
424
|
+
.. code-block:: bash
|
|
425
|
+
|
|
426
|
+
# Enable verbose logging with DEBUG level (default)
|
|
427
|
+
geai-dbg -v my_script.py
|
|
428
|
+
|
|
429
|
+
# Enable verbose logging with INFO level
|
|
430
|
+
geai-dbg -v --log-level INFO my_script.py
|
|
431
|
+
|
|
432
|
+
# Enable verbose logging with ERROR level only
|
|
433
|
+
geai-dbg -v --log-level ERROR my_script.py
|
|
434
|
+
|
|
435
|
+
Programmatically:
|
|
436
|
+
|
|
437
|
+
.. code-block:: python
|
|
320
438
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
439
|
+
from pygeai.dbg import debug_file
|
|
440
|
+
|
|
441
|
+
# Enable verbose logging with DEBUG level
|
|
442
|
+
dbg = debug_file('my_script.py', verbose=True)
|
|
443
|
+
dbg.run()
|
|
444
|
+
|
|
445
|
+
# Enable verbose logging with INFO level
|
|
446
|
+
dbg = debug_file('my_script.py', verbose=True, log_level='INFO')
|
|
447
|
+
dbg.run()
|
|
329
448
|
|
|
330
449
|
Advanced Features
|
|
331
450
|
-----------------
|
|
@@ -333,15 +452,35 @@ Advanced Features
|
|
|
333
452
|
Module Filtering
|
|
334
453
|
~~~~~~~~~~~~~~~~
|
|
335
454
|
|
|
336
|
-
The debugger includes a performance optimization that only traces modules matching a specified prefix
|
|
455
|
+
The debugger includes a performance optimization that only traces modules matching a specified prefix. This significantly reduces overhead compared to tracing all Python code.
|
|
337
456
|
|
|
338
|
-
|
|
457
|
+
**Automatic detection** (for file debugging):
|
|
339
458
|
|
|
340
|
-
|
|
459
|
+
- Scripts without PyGEAI imports: filters to ``__main__`` only
|
|
460
|
+
- Scripts with PyGEAI imports: traces all modules (empty filter)
|
|
461
|
+
|
|
462
|
+
**Manual control**:
|
|
463
|
+
|
|
464
|
+
.. code-block:: bash
|
|
465
|
+
|
|
466
|
+
# Only trace pygeai modules (default for geai CLI)
|
|
467
|
+
geai-dbg --filter pygeai my_script.py
|
|
468
|
+
|
|
469
|
+
# Only trace your script
|
|
470
|
+
geai-dbg --filter __main__ my_script.py
|
|
471
|
+
|
|
472
|
+
# Trace everything (slow!)
|
|
473
|
+
geai-dbg --trace-all my_script.py
|
|
341
474
|
|
|
342
|
-
|
|
475
|
+
Programmatically:
|
|
343
476
|
|
|
344
|
-
|
|
477
|
+
.. code-block:: python
|
|
478
|
+
|
|
479
|
+
# Fast: only trace __main__
|
|
480
|
+
dbg = debug_file('script.py', module_filter='__main__')
|
|
481
|
+
|
|
482
|
+
# Slower: trace pygeai and __main__
|
|
483
|
+
dbg = debug_file('script.py', module_filter='')
|
|
345
484
|
|
|
346
485
|
Conditional Breakpoints
|
|
347
486
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
@@ -350,6 +489,8 @@ Breakpoints can include conditions that must be met for the breakpoint to trigge
|
|
|
350
489
|
|
|
351
490
|
.. code-block:: python
|
|
352
491
|
|
|
492
|
+
from pygeai.dbg import Debugger
|
|
493
|
+
|
|
353
494
|
dbg = Debugger(target=my_function)
|
|
354
495
|
dbg.add_breakpoint(
|
|
355
496
|
module="my_module",
|
|
@@ -366,39 +507,35 @@ The debugger uses Python's ``readline`` module to provide command history and li
|
|
|
366
507
|
|
|
367
508
|
- **Up/Down arrows**: Navigate through command history
|
|
368
509
|
- **Ctrl+R**: Search command history
|
|
369
|
-
- **Tab**: (if configured) Auto-completion
|
|
370
510
|
|
|
371
511
|
Command history is saved to ``~/.geai_dbg_history`` and persists across debugging sessions.
|
|
372
512
|
|
|
373
|
-
|
|
374
|
-
|
|
513
|
+
Helper Functions
|
|
514
|
+
~~~~~~~~~~~~~~~~
|
|
375
515
|
|
|
376
|
-
|
|
516
|
+
The ``pygeai.dbg`` module provides convenient helper functions:
|
|
377
517
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
from pygeai.dbg.debugger import Debugger, Breakpoint
|
|
381
|
-
|
|
382
|
-
def my_target():
|
|
383
|
-
# Your code here
|
|
384
|
-
pass
|
|
385
|
-
|
|
386
|
-
# Create debugger
|
|
387
|
-
dbg = Debugger(target=my_target, module_filter="my_package")
|
|
388
|
-
|
|
389
|
-
# Add breakpoints
|
|
390
|
-
dbg.add_breakpoint(module="my_package.module", function_name="my_function")
|
|
391
|
-
dbg.add_breakpoint(function_name="helper", condition="x > 10")
|
|
392
|
-
|
|
393
|
-
# List breakpoints
|
|
394
|
-
for bp in dbg.list_breakpoints():
|
|
395
|
-
print(f"Breakpoint: {bp}")
|
|
518
|
+
**debug_file(filepath, args, module_filter, breakpoint_specs, verbose, log_level)**
|
|
519
|
+
Debug a Python file by executing it under the debugger.
|
|
396
520
|
|
|
397
|
-
|
|
398
|
-
|
|
521
|
+
:param filepath: Path to the Python file to debug (required)
|
|
522
|
+
:param args: Command-line arguments to pass to the script (optional)
|
|
523
|
+
:param module_filter: Module prefix to trace, None auto-detects (optional)
|
|
524
|
+
:param breakpoint_specs: List of (module, function) tuples for initial breakpoints (optional)
|
|
525
|
+
:param verbose: Enable verbose logging for pygeai modules (default: False)
|
|
526
|
+
:param log_level: Log level for verbose mode: 'DEBUG', 'INFO', 'WARNING', 'ERROR' (default: 'DEBUG')
|
|
527
|
+
:return: Configured Debugger instance
|
|
528
|
+
:raises: FileNotFoundError if the file doesn't exist
|
|
529
|
+
|
|
530
|
+
**debug_module(module_name, function_name, args, module_filter)**
|
|
531
|
+
Debug a specific module and function.
|
|
399
532
|
|
|
400
|
-
|
|
401
|
-
|
|
533
|
+
:param module_name: Fully qualified module name, e.g., 'pygeai.cli.geai' (required)
|
|
534
|
+
:param function_name: Function to call (default: 'main')
|
|
535
|
+
:param args: Command-line arguments (optional)
|
|
536
|
+
:param module_filter: Module prefix to trace (optional)
|
|
537
|
+
:return: Configured Debugger instance with automatic breakpoint
|
|
538
|
+
:raises: ImportError if module or function cannot be imported
|
|
402
539
|
|
|
403
540
|
Tips and Best Practices
|
|
404
541
|
-----------------------
|
|
@@ -417,27 +554,53 @@ Tips and Best Practices
|
|
|
417
554
|
|
|
418
555
|
7. **Conditional breakpoints**: Use conditions to break only when specific criteria are met, reducing manual stepping.
|
|
419
556
|
|
|
420
|
-
|
|
421
|
-
-----
|
|
557
|
+
8. **Strategic breakpoints**: Set breakpoints only where needed. Specific module:function breakpoints are faster than wildcards.
|
|
422
558
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
- Pressing ``Ctrl+C`` resumes execution, equivalent to the ``continue`` command.
|
|
559
|
+
Performance Considerations
|
|
560
|
+
--------------------------
|
|
426
561
|
|
|
427
|
-
|
|
428
|
-
- Arbitrary Python code executed at the prompt runs in the context of the current frame, with access to local and global variables. Use with caution, as it can modify program state.
|
|
562
|
+
**Module Filtering**
|
|
429
563
|
|
|
430
|
-
|
|
431
|
-
- The debugger uses ``sys.settrace`` which has performance overhead. The module filter helps minimize this, but expect slower execution than running without the debugger.
|
|
564
|
+
Module filtering defaults to sensible values:
|
|
432
565
|
|
|
433
|
-
-
|
|
434
|
-
|
|
566
|
+
- ``__main__`` for scripts without PyGEAI imports
|
|
567
|
+
- Empty string (all modules) for scripts with PyGEAI imports
|
|
568
|
+
- Inherited from module name for module debugging
|
|
435
569
|
|
|
436
|
-
-
|
|
437
|
-
- The debugger logs to stdout with timestamps, including breakpoint hits, state changes, and errors. The log level is set to DEBUG by default.
|
|
570
|
+
Users can override with ``--filter`` or ``--trace-all``.
|
|
438
571
|
|
|
439
|
-
|
|
440
|
-
|
|
572
|
+
**Overhead**
|
|
573
|
+
|
|
574
|
+
The debugger uses ``sys.settrace`` which has performance overhead. The module filter helps minimize this, but expect slower execution than running without the debugger.
|
|
575
|
+
|
|
576
|
+
Troubleshooting
|
|
577
|
+
---------------
|
|
578
|
+
|
|
579
|
+
**Debugger Not Stopping**
|
|
580
|
+
|
|
581
|
+
1. Check module filter matches your code
|
|
582
|
+
2. Verify breakpoint module/function names are correct
|
|
583
|
+
3. Use ``--trace-all`` to debug filtering issues
|
|
584
|
+
|
|
585
|
+
**Source Code Not Available**
|
|
586
|
+
|
|
587
|
+
Some modules (built-ins, compiled extensions) don't have accessible source. The debugger will notify you when source is unavailable.
|
|
588
|
+
|
|
589
|
+
**Performance Issues**
|
|
590
|
+
|
|
591
|
+
1. Reduce module filter scope
|
|
592
|
+
2. Use specific breakpoints instead of wildcards
|
|
593
|
+
3. Disable conditional breakpoints if not needed
|
|
594
|
+
|
|
595
|
+
**Breakpoint not hitting**
|
|
596
|
+
|
|
597
|
+
- Check that the module and function names match exactly (use ``lm`` to list loaded modules)
|
|
598
|
+
- Verify the breakpoint is enabled (use ``b`` to list breakpoints)
|
|
599
|
+
- Check if a condition is preventing the breakpoint from triggering
|
|
600
|
+
|
|
601
|
+
**Can't see local variables**
|
|
602
|
+
|
|
603
|
+
Make sure you're in the correct frame. Use ``where`` to see the stack and ``up``/``down`` to navigate.
|
|
441
604
|
|
|
442
605
|
Code Examples
|
|
443
606
|
-------------
|
|
@@ -445,34 +608,41 @@ Code Examples
|
|
|
445
608
|
See the ``pygeai/tests/snippets/dbg/`` directory for complete working examples:
|
|
446
609
|
|
|
447
610
|
- ``basic_debugging.py`` - Simple debugging with variable inspection
|
|
448
|
-
- ``
|
|
449
|
-
- ``
|
|
611
|
+
- ``file_debugging.py`` - Demonstrates debugging Python files
|
|
612
|
+
- ``module_debugging.py`` - Shows module debugging capabilities
|
|
450
613
|
- ``breakpoint_management.py`` - Examples of managing breakpoints
|
|
614
|
+
- ``stack_navigation.py`` - Shows stack traversal with up/down
|
|
451
615
|
|
|
452
616
|
Run these examples with:
|
|
453
617
|
|
|
454
618
|
.. code-block:: bash
|
|
455
619
|
|
|
456
|
-
python
|
|
620
|
+
python pygeai/tests/snippets/dbg/basic_debugging.py
|
|
621
|
+
python pygeai/tests/snippets/dbg/file_debugging.py
|
|
622
|
+
python pygeai/tests/snippets/dbg/module_debugging.py
|
|
457
623
|
|
|
458
|
-
|
|
459
|
-
|
|
624
|
+
Notes
|
|
625
|
+
-----
|
|
460
626
|
|
|
461
|
-
**
|
|
462
|
-
|
|
627
|
+
- **Ctrl+D and Ctrl+C**:
|
|
628
|
+
- Pressing ``Ctrl+D`` at the ``(geai-dbg)`` prompt terminates the debugger gracefully.
|
|
629
|
+
- Pressing ``Ctrl+C`` resumes execution, equivalent to the ``continue`` command.
|
|
463
630
|
|
|
464
|
-
**
|
|
465
|
-
|
|
466
|
-
- Verify the breakpoint is enabled (use ``b`` to list breakpoints)
|
|
467
|
-
- Check if a condition is preventing the breakpoint from triggering
|
|
631
|
+
- **Python Code Execution**:
|
|
632
|
+
- Arbitrary Python code executed at the prompt runs in the context of the current frame, with access to local and global variables.
|
|
468
633
|
|
|
469
|
-
**
|
|
470
|
-
|
|
634
|
+
- **Breakpoint Persistence**:
|
|
635
|
+
- Breakpoints persist across ``continue`` commands but are cleared when the program exits. They are not saved to disk.
|
|
471
636
|
|
|
472
|
-
|
|
473
|
-
|
|
637
|
+
- **Logging**:
|
|
638
|
+
- The debugger logs to stdout with timestamps, including breakpoint hits, state changes, and errors.
|
|
639
|
+
- PyGEAI module logging is disabled by default. Enable it with ``-v/--verbose`` flag.
|
|
640
|
+
- When verbose mode is enabled, the log level can be controlled with ``--log-level`` (default: DEBUG).
|
|
641
|
+
|
|
642
|
+
- **Frame Context**:
|
|
643
|
+
- When you move up/down the stack with ``up``/``down``, the current frame changes, affecting what ``locals``, ``globals``, and expression evaluation see.
|
|
474
644
|
|
|
475
|
-
For issues or feature requests, contact the
|
|
645
|
+
For issues or feature requests, contact the PyGEAI development team or file an issue on the project's GitHub repository.
|
|
476
646
|
|
|
477
647
|
.. seealso::
|
|
478
648
|
|
|
@@ -12,6 +12,14 @@ pygeai.core.common.config module
|
|
|
12
12
|
:show-inheritance:
|
|
13
13
|
:undoc-members:
|
|
14
14
|
|
|
15
|
+
pygeai.core.common.constants module
|
|
16
|
+
-----------------------------------
|
|
17
|
+
|
|
18
|
+
.. automodule:: pygeai.core.common.constants
|
|
19
|
+
:members:
|
|
20
|
+
:show-inheritance:
|
|
21
|
+
:undoc-members:
|
|
22
|
+
|
|
15
23
|
pygeai.core.common.decorators module
|
|
16
24
|
------------------------------------
|
|
17
25
|
|