pygeai-orchestration 0.1.0b2__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 (61) hide show
  1. pygeai_orchestration/__init__.py +99 -0
  2. pygeai_orchestration/cli/__init__.py +7 -0
  3. pygeai_orchestration/cli/__main__.py +11 -0
  4. pygeai_orchestration/cli/commands/__init__.py +13 -0
  5. pygeai_orchestration/cli/commands/base.py +192 -0
  6. pygeai_orchestration/cli/error_handler.py +123 -0
  7. pygeai_orchestration/cli/formatters.py +419 -0
  8. pygeai_orchestration/cli/geai_orch.py +270 -0
  9. pygeai_orchestration/cli/interactive.py +265 -0
  10. pygeai_orchestration/cli/texts/help.py +169 -0
  11. pygeai_orchestration/core/__init__.py +130 -0
  12. pygeai_orchestration/core/base/__init__.py +23 -0
  13. pygeai_orchestration/core/base/agent.py +121 -0
  14. pygeai_orchestration/core/base/geai_agent.py +144 -0
  15. pygeai_orchestration/core/base/geai_orchestrator.py +77 -0
  16. pygeai_orchestration/core/base/orchestrator.py +142 -0
  17. pygeai_orchestration/core/base/pattern.py +161 -0
  18. pygeai_orchestration/core/base/tool.py +149 -0
  19. pygeai_orchestration/core/common/__init__.py +18 -0
  20. pygeai_orchestration/core/common/context.py +140 -0
  21. pygeai_orchestration/core/common/memory.py +176 -0
  22. pygeai_orchestration/core/common/message.py +50 -0
  23. pygeai_orchestration/core/common/state.py +181 -0
  24. pygeai_orchestration/core/composition.py +190 -0
  25. pygeai_orchestration/core/config.py +356 -0
  26. pygeai_orchestration/core/exceptions.py +400 -0
  27. pygeai_orchestration/core/handlers.py +380 -0
  28. pygeai_orchestration/core/utils/__init__.py +37 -0
  29. pygeai_orchestration/core/utils/cache.py +138 -0
  30. pygeai_orchestration/core/utils/config.py +94 -0
  31. pygeai_orchestration/core/utils/logging.py +57 -0
  32. pygeai_orchestration/core/utils/metrics.py +184 -0
  33. pygeai_orchestration/core/utils/validators.py +140 -0
  34. pygeai_orchestration/dev/__init__.py +15 -0
  35. pygeai_orchestration/dev/debug.py +288 -0
  36. pygeai_orchestration/dev/templates.py +321 -0
  37. pygeai_orchestration/dev/testing.py +301 -0
  38. pygeai_orchestration/patterns/__init__.py +15 -0
  39. pygeai_orchestration/patterns/multi_agent.py +237 -0
  40. pygeai_orchestration/patterns/planning.py +219 -0
  41. pygeai_orchestration/patterns/react.py +221 -0
  42. pygeai_orchestration/patterns/reflection.py +134 -0
  43. pygeai_orchestration/patterns/tool_use.py +170 -0
  44. pygeai_orchestration/tests/__init__.py +1 -0
  45. pygeai_orchestration/tests/test_base_classes.py +187 -0
  46. pygeai_orchestration/tests/test_cache.py +184 -0
  47. pygeai_orchestration/tests/test_cli_formatters.py +232 -0
  48. pygeai_orchestration/tests/test_common.py +214 -0
  49. pygeai_orchestration/tests/test_composition.py +265 -0
  50. pygeai_orchestration/tests/test_config.py +301 -0
  51. pygeai_orchestration/tests/test_dev_utils.py +337 -0
  52. pygeai_orchestration/tests/test_exceptions.py +327 -0
  53. pygeai_orchestration/tests/test_handlers.py +307 -0
  54. pygeai_orchestration/tests/test_metrics.py +171 -0
  55. pygeai_orchestration/tests/test_patterns.py +165 -0
  56. pygeai_orchestration-0.1.0b2.dist-info/METADATA +290 -0
  57. pygeai_orchestration-0.1.0b2.dist-info/RECORD +61 -0
  58. pygeai_orchestration-0.1.0b2.dist-info/WHEEL +5 -0
  59. pygeai_orchestration-0.1.0b2.dist-info/entry_points.txt +2 -0
  60. pygeai_orchestration-0.1.0b2.dist-info/licenses/LICENSE +8 -0
  61. pygeai_orchestration-0.1.0b2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,99 @@
1
+ import logging
2
+
3
+ __author__ = "Globant"
4
+ __version__ = "0.1.0b1"
5
+
6
+ logger = logging.getLogger("pygeai-orchestration")
7
+ logger.addHandler(logging.NullHandler())
8
+
9
+ from .core import (
10
+ BaseAgent,
11
+ AgentConfig,
12
+ BaseOrchestrator,
13
+ OrchestratorConfig,
14
+ BasePattern,
15
+ PatternConfig,
16
+ PatternResult,
17
+ PatternType,
18
+ BaseTool,
19
+ ToolConfig,
20
+ ToolResult,
21
+ ToolCategory,
22
+ GEAIAgent,
23
+ GEAIOrchestrator,
24
+ Message,
25
+ MessageRole,
26
+ Conversation,
27
+ Context,
28
+ ContextManager,
29
+ State,
30
+ StateStatus,
31
+ StateManager,
32
+ Memory,
33
+ MemoryEntry,
34
+ MemoryStore,
35
+ get_logger,
36
+ get_config,
37
+ OrchestrationError,
38
+ PatternExecutionError,
39
+ PatternConfigurationError,
40
+ AgentError,
41
+ ToolExecutionError,
42
+ StateError,
43
+ ValidationError,
44
+ )
45
+
46
+ from .patterns import (
47
+ ReflectionPattern,
48
+ ToolUsePattern,
49
+ ReActPattern,
50
+ PlanningPattern,
51
+ PlanStep,
52
+ MultiAgentPattern,
53
+ AgentRole,
54
+ )
55
+
56
+ __all__ = [
57
+ "__version__",
58
+ "BaseAgent",
59
+ "AgentConfig",
60
+ "BaseOrchestrator",
61
+ "OrchestratorConfig",
62
+ "BasePattern",
63
+ "PatternConfig",
64
+ "PatternResult",
65
+ "PatternType",
66
+ "BaseTool",
67
+ "ToolConfig",
68
+ "ToolResult",
69
+ "ToolCategory",
70
+ "GEAIAgent",
71
+ "GEAIOrchestrator",
72
+ "Message",
73
+ "MessageRole",
74
+ "Conversation",
75
+ "Context",
76
+ "ContextManager",
77
+ "State",
78
+ "StateStatus",
79
+ "StateManager",
80
+ "Memory",
81
+ "MemoryEntry",
82
+ "MemoryStore",
83
+ "get_logger",
84
+ "get_config",
85
+ "OrchestrationError",
86
+ "PatternExecutionError",
87
+ "PatternConfigurationError",
88
+ "AgentError",
89
+ "ToolExecutionError",
90
+ "StateError",
91
+ "ValidationError",
92
+ "ReflectionPattern",
93
+ "ToolUsePattern",
94
+ "ReActPattern",
95
+ "PlanningPattern",
96
+ "PlanStep",
97
+ "MultiAgentPattern",
98
+ "AgentRole",
99
+ ]
@@ -0,0 +1,7 @@
1
+ """
2
+ CLI module for PyGEAI-Orchestration.
3
+
4
+ Provides the geai-orch command-line interface for orchestration patterns.
5
+ """
6
+
7
+ __all__ = []
@@ -0,0 +1,11 @@
1
+ import sys
2
+
3
+ from pygeai_orchestration.cli.geai_orch import main as geai_orch
4
+
5
+
6
+ def main():
7
+ sys.exit(geai_orch())
8
+
9
+
10
+ if __name__ == "__main__":
11
+ main()
@@ -0,0 +1,13 @@
1
+ """
2
+ CLI commands module.
3
+
4
+ Re-exports command infrastructure from PyGEAI to avoid code duplication.
5
+ """
6
+
7
+ from pygeai.cli.commands import Command, Option, ArgumentsEnum
8
+
9
+ __all__ = [
10
+ "Command",
11
+ "Option",
12
+ "ArgumentsEnum",
13
+ ]
@@ -0,0 +1,192 @@
1
+ """
2
+ Base commands for the geai-orch CLI.
3
+ """
4
+
5
+ from typing import List, Tuple
6
+
7
+ from pygeai_orchestration import __version__
8
+ from pygeai_orchestration.cli.commands import Command, Option, ArgumentsEnum
9
+ from pygeai_orchestration.cli.texts.help import (
10
+ CLI_USAGE,
11
+ VERSION_TEXT,
12
+ HELP_REFLECTION,
13
+ HELP_TOOL_USE,
14
+ HELP_REACT,
15
+ HELP_PLANNING,
16
+ HELP_MULTI_AGENT,
17
+ )
18
+
19
+
20
+ def show_help(option_list: List[Tuple[Option, str]] = None):
21
+ """
22
+ Display help information for geai-orch CLI.
23
+
24
+ :param option_list: Optional list of options (unused, for compatibility)
25
+ """
26
+ print(CLI_USAGE)
27
+
28
+
29
+ def show_version(option_list: List[Tuple[Option, str]] = None):
30
+ """
31
+ Display version information.
32
+
33
+ :param option_list: Optional list of options (unused, for compatibility)
34
+ """
35
+ print(VERSION_TEXT.format(version=__version__))
36
+
37
+
38
+ def show_reflection_help(option_list: List[Tuple[Option, str]] = None):
39
+ """Display help for reflection command."""
40
+ print(HELP_REFLECTION)
41
+
42
+
43
+ def show_tool_use_help(option_list: List[Tuple[Option, str]] = None):
44
+ """Display help for tool-use command."""
45
+ print(HELP_TOOL_USE)
46
+
47
+
48
+ def show_react_help(option_list: List[Tuple[Option, str]] = None):
49
+ """Display help for react command."""
50
+ print(HELP_REACT)
51
+
52
+
53
+ def show_planning_help(option_list: List[Tuple[Option, str]] = None):
54
+ """Display help for planning command."""
55
+ print(HELP_PLANNING)
56
+
57
+
58
+ def show_multi_agent_help(option_list: List[Tuple[Option, str]] = None):
59
+ """Display help for multi-agent command."""
60
+ print(HELP_MULTI_AGENT)
61
+
62
+
63
+ def placeholder_handler(option_list: List[Tuple[Option, str]] = None):
64
+ """
65
+ Placeholder handler for commands not yet implemented.
66
+
67
+ :param option_list: List of parsed options
68
+ """
69
+ print("⚠️ This command is not yet implemented.")
70
+ print("This feature is under development and will be available soon.")
71
+
72
+
73
+ help_command = Command(
74
+ name="help",
75
+ identifiers=["help", "-h", "--help"],
76
+ description="Show help information",
77
+ action=show_help,
78
+ additional_args=ArgumentsEnum.NOT_AVAILABLE,
79
+ subcommands=[],
80
+ options=[],
81
+ )
82
+
83
+ version_command = Command(
84
+ name="version",
85
+ identifiers=["version", "-V", "--version"],
86
+ description="Show version information",
87
+ action=show_version,
88
+ additional_args=ArgumentsEnum.NOT_AVAILABLE,
89
+ subcommands=[],
90
+ options=[],
91
+ )
92
+
93
+ reflection_command = Command(
94
+ name="reflection",
95
+ identifiers=["reflection", "reflect"],
96
+ description="Run reflection pattern for iterative improvement",
97
+ action=placeholder_handler,
98
+ additional_args=ArgumentsEnum.OPTIONAL,
99
+ subcommands=[],
100
+ options=[
101
+ Option("agent", ["-a", "--agent"], "Agent ID to use for reflection", True),
102
+ Option("iterations", ["-i", "--iterations"], "Number of reflection iterations", True),
103
+ Option("task", ["-t", "--task"], "Task or text to improve", True),
104
+ Option("output", ["-o", "--output"], "Output file for results", True),
105
+ Option("verbose", ["-v", "--verbose"], "Show detailed output", False),
106
+ Option("help", ["-h", "--help"], "Show help for this command", False),
107
+ ],
108
+ )
109
+
110
+ tool_use_command = Command(
111
+ name="tool-use",
112
+ identifiers=["tool-use", "tools"],
113
+ description="Execute tool use pattern with function calling",
114
+ action=placeholder_handler,
115
+ additional_args=ArgumentsEnum.OPTIONAL,
116
+ subcommands=[],
117
+ options=[
118
+ Option("agent", ["-a", "--agent"], "Agent ID to use", True),
119
+ Option("tools", ["-t", "--tools"], "Tools configuration file", True),
120
+ Option("task", ["--task"], "Task description", True),
121
+ Option("output", ["-o", "--output"], "Output file for results", True),
122
+ Option("verbose", ["-v", "--verbose"], "Show detailed output", False),
123
+ Option("help", ["-h", "--help"], "Show help for this command", False),
124
+ ],
125
+ )
126
+
127
+ react_command = Command(
128
+ name="react",
129
+ identifiers=["react"],
130
+ description="Run ReAct (Reasoning + Acting) pattern",
131
+ action=placeholder_handler,
132
+ additional_args=ArgumentsEnum.OPTIONAL,
133
+ subcommands=[],
134
+ options=[
135
+ Option("agent", ["-a", "--agent"], "Agent ID to use", True),
136
+ Option("task", ["-t", "--task"], "Task to solve", True),
137
+ Option("max_steps", ["--max-steps"], "Maximum reasoning-acting steps", True),
138
+ Option("output", ["-o", "--output"], "Output file for results", True),
139
+ Option("verbose", ["-v", "--verbose"], "Show detailed reasoning trace", False),
140
+ Option("help", ["-h", "--help"], "Show help for this command", False),
141
+ ],
142
+ )
143
+
144
+ planning_command = Command(
145
+ name="planning",
146
+ identifiers=["planning", "plan"],
147
+ description="Execute planning pattern for multi-step tasks",
148
+ action=placeholder_handler,
149
+ additional_args=ArgumentsEnum.OPTIONAL,
150
+ subcommands=[],
151
+ options=[
152
+ Option("agent", ["-a", "--agent"], "Planner agent ID", True),
153
+ Option("task", ["-t", "--task"], "Task to plan and execute", True),
154
+ Option("plan_only", ["--plan-only"], "Only create plan, don't execute", False),
155
+ Option("output", ["-o", "--output"], "Output file for results", True),
156
+ Option("verbose", ["-v", "--verbose"], "Show detailed execution trace", False),
157
+ Option("help", ["-h", "--help"], "Show help for this command", False),
158
+ ],
159
+ )
160
+
161
+ multi_agent_command = Command(
162
+ name="multi-agent",
163
+ identifiers=["multi-agent", "multi"],
164
+ description="Run multi-agent coordination pattern",
165
+ action=placeholder_handler,
166
+ additional_args=ArgumentsEnum.OPTIONAL,
167
+ subcommands=[],
168
+ options=[
169
+ Option("config", ["-c", "--config"], "Agent configuration file", True),
170
+ Option("task", ["-t", "--task"], "Task for agents to collaborate on", True),
171
+ Option("strategy", ["--strategy"], "Coordination strategy", True),
172
+ Option("output", ["-o", "--output"], "Output file for results", True),
173
+ Option("verbose", ["-v", "--verbose"], "Show agent communication details", False),
174
+ Option("help", ["-h", "--help"], "Show help for this command", False),
175
+ ],
176
+ )
177
+
178
+ base_commands = [
179
+ help_command,
180
+ version_command,
181
+ reflection_command,
182
+ tool_use_command,
183
+ react_command,
184
+ planning_command,
185
+ multi_agent_command,
186
+ ]
187
+
188
+ base_options = [
189
+ Option("alias", ["-a", "--alias"], "Use a specific credentials profile", True),
190
+ Option("credentials", ["--credentials", "--creds"], "Path to custom credentials file", True),
191
+ Option("verbose", ["-v", "--verbose"], "Enable verbose logging", False),
192
+ ]
@@ -0,0 +1,123 @@
1
+ """
2
+ Error handling for the geai-orch CLI.
3
+ """
4
+
5
+ from typing import List
6
+ from enum import IntEnum
7
+
8
+
9
+ class ExitCode(IntEnum):
10
+ """Exit codes for the CLI."""
11
+
12
+ SUCCESS = 0
13
+ USER_INPUT_ERROR = 1
14
+ MISSING_REQUIREMENT = 2
15
+ SERVICE_ERROR = 3
16
+ ORCHESTRATION_ERROR = 4
17
+ KEYBOARD_INTERRUPT = 130
18
+ UNEXPECTED_ERROR = 255
19
+
20
+
21
+ class ErrorHandler:
22
+ """Handles error formatting and display for the CLI."""
23
+
24
+ @staticmethod
25
+ def format_error(title: str, message: str) -> str:
26
+ """
27
+ Format an error message with a title.
28
+
29
+ :param title: str - Error title
30
+ :param message: str - Error message
31
+ :return: str - Formatted error message
32
+ """
33
+ return f"\n❌ {title}\n{message}\n"
34
+
35
+ @staticmethod
36
+ def handle_unknown_command(arg: str, available_commands: List) -> str:
37
+ """
38
+ Handle unknown command error.
39
+
40
+ :param arg: str - The unknown argument
41
+ :param available_commands: List - List of available commands
42
+ :return: str - Formatted error message
43
+ """
44
+ commands_str = ", ".join([cmd.name for cmd in available_commands])
45
+ message = (
46
+ f"'{arg}' is not a recognized command.\n\n"
47
+ f"Available commands: {commands_str}\n\n"
48
+ f"Use 'geai-orch help' for more information."
49
+ )
50
+ return ErrorHandler.format_error("Unknown Command", message)
51
+
52
+ @staticmethod
53
+ def handle_unknown_option(arg: str, available_options: List) -> str:
54
+ """
55
+ Handle unknown option error.
56
+
57
+ :param arg: str - The unknown argument
58
+ :param available_options: List - List of available options
59
+ :return: str - Formatted error message
60
+ """
61
+ options_str = ", ".join(["/".join(opt.identifiers) for opt in available_options])
62
+ message = (
63
+ f"'{arg}' is not a recognized option.\n\n"
64
+ f"Available options: {options_str}\n\n"
65
+ f"Use 'geai-orch help' for more information."
66
+ )
67
+ return ErrorHandler.format_error("Unknown Option", message)
68
+
69
+ @staticmethod
70
+ def handle_wrong_argument(message: str, usage: str) -> str:
71
+ """
72
+ Handle wrong argument error.
73
+
74
+ :param message: str - Error message
75
+ :param usage: str - Usage information
76
+ :return: str - Formatted error message
77
+ """
78
+ full_message = f"{message}\n\n{usage}"
79
+ return ErrorHandler.format_error("Invalid Argument", full_message)
80
+
81
+ @staticmethod
82
+ def handle_missing_requirement(message: str) -> str:
83
+ """
84
+ Handle missing requirement error.
85
+
86
+ :param message: str - Error message
87
+ :return: str - Formatted error message
88
+ """
89
+ return ErrorHandler.format_error("Missing Requirement", message)
90
+
91
+ @staticmethod
92
+ def handle_orchestration_error(message: str) -> str:
93
+ """
94
+ Handle orchestration-specific errors.
95
+
96
+ :param message: str - Error message
97
+ :return: str - Formatted error message
98
+ """
99
+ return ErrorHandler.format_error("Orchestration Error", message)
100
+
101
+ @staticmethod
102
+ def handle_keyboard_interrupt() -> str:
103
+ """
104
+ Handle keyboard interrupt (Ctrl+C).
105
+
106
+ :return: str - Formatted message
107
+ """
108
+ return "\n\n⚠️ Operation cancelled by user.\n"
109
+
110
+ @staticmethod
111
+ def handle_unexpected_error(exception: Exception) -> str:
112
+ """
113
+ Handle unexpected errors.
114
+
115
+ :param exception: Exception - The exception that occurred
116
+ :return: str - Formatted error message
117
+ """
118
+ message = (
119
+ f"An unexpected error occurred: {str(exception)}\n\n"
120
+ f"Please report this issue at:\n"
121
+ f"https://github.com/genexus-books/pygeai-orchestration/issues"
122
+ )
123
+ return ErrorHandler.format_error("Unexpected Error", message)