pygeai-orchestration 0.1.0b5__py3-none-any.whl → 0.1.0b7__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.
@@ -3,10 +3,10 @@ import logging
3
3
  __author__ = "Globant"
4
4
  __version__ = "0.1.0b1"
5
5
 
6
- logger = logging.getLogger("pygeai-orchestration")
6
+ logger = logging.getLogger("pygeai_orchestration")
7
7
  logger.addHandler(logging.NullHandler())
8
8
 
9
- from .core import (
9
+ from pygeai_orchestration.core import (
10
10
  BaseAgent,
11
11
  AgentConfig,
12
12
  BaseOrchestrator,
@@ -32,7 +32,6 @@ from .core import (
32
32
  Memory,
33
33
  MemoryEntry,
34
34
  MemoryStore,
35
- get_logger,
36
35
  get_config,
37
36
  OrchestrationError,
38
37
  PatternExecutionError,
@@ -43,7 +42,7 @@ from .core import (
43
42
  ValidationError,
44
43
  )
45
44
 
46
- from .patterns import (
45
+ from pygeai_orchestration.patterns import (
47
46
  ReflectionPattern,
48
47
  ToolUsePattern,
49
48
  ReActPattern,
@@ -55,6 +54,7 @@ from .patterns import (
55
54
 
56
55
  __all__ = [
57
56
  "__version__",
57
+ "logger",
58
58
  "BaseAgent",
59
59
  "AgentConfig",
60
60
  "BaseOrchestrator",
@@ -80,7 +80,6 @@ __all__ = [
80
80
  "Memory",
81
81
  "MemoryEntry",
82
82
  "MemoryStore",
83
- "get_logger",
84
83
  "get_config",
85
84
  "OrchestrationError",
86
85
  "PatternExecutionError",
@@ -30,8 +30,6 @@ from .common import (
30
30
  )
31
31
 
32
32
  from .utils import (
33
- OrchestrationLogger,
34
- get_logger,
35
33
  ConfigManager,
36
34
  get_config,
37
35
  ValidationResult,
@@ -97,8 +95,6 @@ __all__ = [
97
95
  "Memory",
98
96
  "MemoryEntry",
99
97
  "MemoryStore",
100
- "OrchestrationLogger",
101
- "get_logger",
102
98
  "ConfigManager",
103
99
  "get_config",
104
100
  "ValidationResult",
@@ -1,9 +1,9 @@
1
- from .agent import BaseAgent, AgentConfig
2
- from .orchestrator import BaseOrchestrator, OrchestratorConfig
3
- from .pattern import BasePattern, PatternConfig, PatternResult, PatternType
4
- from .tool import BaseTool, ToolConfig, ToolResult, ToolCategory
5
- from .geai_agent import GEAIAgent
6
- from .geai_orchestrator import GEAIOrchestrator
1
+ from pygeai_orchestration.core.base.agent import BaseAgent, AgentConfig
2
+ from pygeai_orchestration.core.base.orchestrator import BaseOrchestrator, OrchestratorConfig
3
+ from pygeai_orchestration.core.base.pattern import BasePattern, PatternConfig, PatternResult, PatternType
4
+ from pygeai_orchestration.core.base.tool import BaseTool, ToolConfig, ToolResult, ToolCategory
5
+ from pygeai_orchestration.core.base.geai_agent import GEAIAgent
6
+ from pygeai_orchestration.core.base.geai_orchestrator import GEAIOrchestrator
7
7
 
8
8
  __all__ = [
9
9
  "BaseAgent",
@@ -5,19 +5,16 @@ This module provides a concrete agent implementation using the PyGEAI SDK,
5
5
  enabling AI-powered task execution with GeneXus Enterprise AI.
6
6
  """
7
7
 
8
+ import logging
8
9
  from typing import Any, Dict, Optional
9
- from .agent import BaseAgent, AgentConfig
10
- from ..utils import get_logger
11
10
 
12
- logger = get_logger()
11
+ from pygeai_orchestration.core.base.agent import BaseAgent, AgentConfig
12
+ from pygeai.core.base.session import Session
13
+ from pygeai.chat.managers import ChatManager
14
+ from pygeai.core.models import LlmSettings, ChatMessageList, ChatMessage
15
+ from pygeai.core.common.config import get_settings
13
16
 
14
- try:
15
- from pygeai import Session
16
-
17
- PYGEAI_AVAILABLE = True
18
- except ImportError:
19
- PYGEAI_AVAILABLE = False
20
- logger.warning("PyGEAI not available. GEAIAgent will have limited functionality.")
17
+ logger = logging.getLogger("pygeai_orchestration")
21
18
 
22
19
 
23
20
  class GEAIAgent(BaseAgent):
@@ -28,10 +25,10 @@ class GEAIAgent(BaseAgent):
28
25
  Enterprise AI models, providing AI-powered reasoning and generation.
29
26
 
30
27
  The agent:
31
- - Integrates with PyGEAI Session and Agent resources
28
+ - Integrates with PyGEAI Session and ChatManager
32
29
  - Supports custom system prompts and model configuration
33
- - Automatically manages agent resource creation
34
30
  - Maintains execution history
31
+ - Automatically loads credentials from ~/.geai/credentials
35
32
  """
36
33
 
37
34
  def __init__(self, config: AgentConfig, session=None, alias: Optional[str] = None):
@@ -40,14 +37,20 @@ class GEAIAgent(BaseAgent):
40
37
 
41
38
  :param config: AgentConfig - Agent configuration.
42
39
  :param session: Optional PyGEAI Session - Existing session to use.
43
- :param alias: Optional[str] - Session alias if creating new session.
44
- :raises ImportError: If PyGEAI is not installed.
40
+ :param alias: Optional[str] - Credentials alias (default: 'default').
45
41
  """
46
42
  super().__init__(config)
47
- if not PYGEAI_AVAILABLE:
48
- raise ImportError("PyGEAI is required for GEAIAgent but is not installed")
49
- self._session = session or Session(alias=alias)
50
- self._agent_resource = None
43
+
44
+ if session:
45
+ self._session = session
46
+ else:
47
+ alias = alias or 'default'
48
+ settings = get_settings()
49
+ api_key = settings.get_api_key(alias)
50
+ base_url = settings.get_base_url(alias)
51
+ self._session = Session(api_key=api_key, base_url=base_url)
52
+
53
+ self._chat_manager = ChatManager(self._session)
51
54
 
52
55
  async def execute(self, task: str, context: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
53
56
  """
@@ -88,8 +91,6 @@ class GEAIAgent(BaseAgent):
88
91
  :raises Exception: If generation fails.
89
92
  """
90
93
  try:
91
- self._get_or_create_agent()
92
-
93
94
  messages = kwargs.get("messages", [])
94
95
  if not messages:
95
96
  messages = [{"role": "user", "content": prompt}]
@@ -97,48 +98,24 @@ class GEAIAgent(BaseAgent):
97
98
  if self.config.system_prompt:
98
99
  messages.insert(0, {"role": "system", "content": self.config.system_prompt})
99
100
 
100
- chat = self._session.chats.create(
101
- messages=messages,
102
- model=self.config.model,
103
- temperature=self.config.temperature,
104
- max_tokens=self.config.max_tokens,
101
+ chat_messages = ChatMessageList(
102
+ messages=[ChatMessage(role=msg["role"], content=msg["content"]) for msg in messages]
103
+ )
104
+
105
+ llm_settings = LlmSettings(
106
+ temperature=self.config.temperature, max_tokens=self.config.max_tokens
107
+ )
108
+
109
+ response = self._chat_manager.chat_completion(
110
+ model=self.config.model, messages=chat_messages, llm_settings=llm_settings
105
111
  )
106
112
 
107
- response = chat.choices[0].message.content
113
+ response_text = response.choices[0].message.content
108
114
 
109
- self.add_to_history({"type": "generation", "prompt": prompt, "response": response})
115
+ self.add_to_history({"type": "generation", "prompt": prompt, "response": response_text})
110
116
 
111
- return response
117
+ return response_text
112
118
 
113
119
  except Exception as e:
114
120
  logger.error(f"Generation failed: {str(e)}")
115
121
  raise
116
-
117
- def _get_or_create_agent(self):
118
- """
119
- Get or create PyGEAI agent resource.
120
-
121
- Lazily creates an agent resource in PyGEAI if not already created,
122
- or reuses existing agent with matching name.
123
-
124
- :return: PyGEAI Agent resource.
125
- """
126
- if self._agent_resource is None:
127
- try:
128
- agents = self._session.agents.list()
129
- for agent in agents.data:
130
- if agent.name == self.name:
131
- self._agent_resource = agent
132
- break
133
-
134
- if self._agent_resource is None:
135
- logger.debug(f"Creating new agent resource: {self.name}")
136
- self._agent_resource = self._session.agents.create(
137
- name=self.name,
138
- model=self.config.model,
139
- description=self.config.description or f"Orchestration agent: {self.name}",
140
- )
141
- except Exception as e:
142
- logger.warning(f"Could not create agent resource: {str(e)}")
143
-
144
- return self._agent_resource
@@ -1,9 +1,10 @@
1
+ import logging
1
2
  from typing import Any, Dict, List, Optional
2
- from .orchestrator import BaseOrchestrator, OrchestratorConfig
3
- from .pattern import PatternResult
4
- from ..utils import get_logger
5
3
 
6
- logger = get_logger()
4
+ from pygeai_orchestration.core.base.orchestrator import BaseOrchestrator, OrchestratorConfig
5
+ from pygeai_orchestration.core.base.pattern import PatternResult
6
+
7
+ logger = logging.getLogger("pygeai_orchestration")
7
8
 
8
9
 
9
10
  class GEAIOrchestrator(BaseOrchestrator):
@@ -48,30 +49,7 @@ class GEAIOrchestrator(BaseOrchestrator):
48
49
 
49
50
  async def coordinate_agents(self, agents: List[str], task: str) -> Dict[str, Any]:
50
51
  logger.info(f"Coordinating {len(agents)} agents for task: {task[:50]}...")
51
-
52
- results = {}
53
-
54
- for agent_name in agents:
55
- agent = self.get_agent(agent_name)
56
- if agent is None:
57
- logger.warning(f"Agent '{agent_name}' not found, skipping")
58
- continue
59
-
60
- try:
61
- result = await agent.execute(task)
62
- results[agent_name] = result
63
- except Exception as e:
64
- logger.error(f"Agent '{agent_name}' failed: {str(e)}")
65
- results[agent_name] = {"success": False, "error": str(e)}
66
-
67
- return {
68
- "success": len(results) > 0,
69
- "results": results,
70
- "agents_executed": list(results.keys()),
71
- }
52
+ return {"status": "not_implemented", "agents": agents, "task": task}
72
53
 
73
54
  def get_execution_history(self) -> List[Dict[str, Any]]:
74
55
  return self._execution_history.copy()
75
-
76
- def clear_history(self) -> None:
77
- self._execution_history.clear()
@@ -9,8 +9,8 @@ from abc import ABC, abstractmethod
9
9
  from typing import Any, Dict, List, Optional
10
10
  from pydantic import BaseModel, Field
11
11
 
12
- from .agent import BaseAgent
13
- from .pattern import BasePattern, PatternResult
12
+ from pygeai_orchestration.core.base.agent import BaseAgent
13
+ from pygeai_orchestration.core.base.pattern import BasePattern, PatternResult
14
14
 
15
15
 
16
16
  class OrchestratorConfig(BaseModel):
@@ -1,14 +1,13 @@
1
- from .logging import OrchestrationLogger, get_logger
2
- from .config import ConfigManager, get_config
3
- from .validators import (
1
+ from pygeai_orchestration.core.utils.config import ConfigManager, get_config
2
+ from pygeai_orchestration.core.utils.validators import (
4
3
  ValidationResult,
5
4
  validate_agent_config,
6
5
  validate_pattern_config,
7
6
  validate_tool_config,
8
7
  validate_pydantic_model,
9
8
  )
10
- from .cache import CacheEntry, LRUCache, PatternCache
11
- from .metrics import (
9
+ from pygeai_orchestration.core.utils.cache import CacheEntry, LRUCache, PatternCache
10
+ from pygeai_orchestration.core.utils.metrics import (
12
11
  Metric,
13
12
  MetricType,
14
13
  MetricsCollector,
@@ -17,8 +16,6 @@ from .metrics import (
17
16
  )
18
17
 
19
18
  __all__ = [
20
- "OrchestrationLogger",
21
- "get_logger",
22
19
  "ConfigManager",
23
20
  "get_config",
24
21
  "ValidationResult",
@@ -1,9 +1,9 @@
1
1
  from typing import Any, Dict, List, Optional
2
- from ..core.base import BasePattern, PatternConfig, PatternResult, PatternType
3
- from ..core.common import Message, MessageRole, Conversation, State, StateStatus
4
- from ..core.utils import get_logger
2
+ from pygeai_orchestration.core.base import BasePattern, PatternConfig, PatternResult, PatternType
3
+ from pygeai_orchestration.core.common import Message, MessageRole, Conversation, State, StateStatus
4
+ import logging
5
5
 
6
- logger = get_logger()
6
+ logger = logging.getLogger("pygeai_orchestration")
7
7
 
8
8
 
9
9
  class AgentRole:
@@ -1,9 +1,9 @@
1
1
  from typing import Any, Dict, List, Optional
2
- from ..core.base import BasePattern, PatternConfig, PatternResult, PatternType
3
- from ..core.common import Message, MessageRole, Conversation, State, StateStatus
4
- from ..core.utils import get_logger
2
+ from pygeai_orchestration.core.base import BasePattern, PatternConfig, PatternResult, PatternType
3
+ from pygeai_orchestration.core.common import Message, MessageRole, Conversation, State, StateStatus
4
+ import logging
5
5
 
6
- logger = get_logger()
6
+ logger = logging.getLogger("pygeai_orchestration")
7
7
 
8
8
 
9
9
  class PlanStep:
@@ -1,9 +1,9 @@
1
1
  from typing import Any, Dict, List, Optional
2
- from ..core.base import BasePattern, BaseTool, PatternConfig, PatternResult, PatternType
3
- from ..core.common import Message, MessageRole, Conversation, State, StateStatus
4
- from ..core.utils import get_logger
2
+ from pygeai_orchestration.core.base import BasePattern, BaseTool, PatternConfig, PatternResult, PatternType
3
+ from pygeai_orchestration.core.common import Message, MessageRole, Conversation, State, StateStatus
4
+ import logging
5
5
 
6
- logger = get_logger()
6
+ logger = logging.getLogger("pygeai_orchestration")
7
7
 
8
8
 
9
9
  class ReActPattern(BasePattern):
@@ -1,9 +1,9 @@
1
1
  from typing import Any, Dict, Optional
2
- from ..core.base import BasePattern, PatternConfig, PatternResult, PatternType
3
- from ..core.common import Message, MessageRole, Conversation, State, StateStatus
4
- from ..core.utils import get_logger
2
+ from pygeai_orchestration.core.base import BasePattern, PatternConfig, PatternResult, PatternType
3
+ from pygeai_orchestration.core.common import Message, MessageRole, Conversation, State, StateStatus
4
+ import logging
5
5
 
6
- logger = get_logger()
6
+ logger = logging.getLogger("pygeai_orchestration")
7
7
 
8
8
 
9
9
  class ReflectionPattern(BasePattern):
@@ -1,9 +1,9 @@
1
1
  from typing import Any, Dict, List, Optional
2
- from ..core.base import BasePattern, BaseTool, PatternConfig, PatternResult, PatternType
3
- from ..core.common import Message, MessageRole, Conversation, State, StateStatus
4
- from ..core.utils import get_logger
2
+ from pygeai_orchestration.core.base import BasePattern, BaseTool, PatternConfig, PatternResult, PatternType
3
+ from pygeai_orchestration.core.common import Message, MessageRole, Conversation, State, StateStatus
4
+ import logging
5
5
 
6
- logger = get_logger()
6
+ logger = logging.getLogger("pygeai_orchestration")
7
7
 
8
8
 
9
9
  class ToolUsePattern(BasePattern):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygeai-orchestration
3
- Version: 0.1.0b5
3
+ Version: 0.1.0b7
4
4
  Summary: Agentic AI orchestration patterns built on Globant Enterprise AI
5
5
  Author-email: Globant <geai-sdk@globant.com>
6
6
  Keywords: geai,pygeai,orchestration,agents,ai,multi-agent,autogen,crewai
@@ -88,27 +88,37 @@ import asyncio
88
88
  from pygeai_orchestration import (
89
89
  GEAIAgent,
90
90
  AgentConfig,
91
+ PatternConfig,
92
+ PatternType,
91
93
  ReflectionPattern
92
94
  )
93
95
 
94
96
  async def main():
95
- # Create an agent
96
- config = AgentConfig(
97
+ # Create agent configuration
98
+ agent_config = AgentConfig(
97
99
  name="my-agent",
98
- model="gpt-4",
100
+ model="openai/gpt-4o-mini",
99
101
  temperature=0.7
100
102
  )
101
- agent = GEAIAgent(config)
103
+ agent = GEAIAgent(config=agent_config)
104
+
105
+ # Create pattern configuration
106
+ pattern_config = PatternConfig(
107
+ name="reflection-example",
108
+ pattern_type=PatternType.REFLECTION,
109
+ max_iterations=3
110
+ )
102
111
 
103
112
  # Create and execute pattern
104
- pattern = ReflectionPattern(agent=agent)
105
- result = await pattern.execute("Improve this text: Hello world")
113
+ pattern = ReflectionPattern(agent=agent, config=pattern_config)
114
+ result = await pattern.execute("Explain quantum computing in simple terms")
106
115
 
107
116
  print(f"Success: {result.success}")
108
- print(f"Result: {result.result}")
109
117
  print(f"Iterations: {result.iterations}")
118
+ print(f"Result: {result.result[:200]}...") # First 200 chars
110
119
 
111
- asyncio.run(main())
120
+ if __name__ == "__main__":
121
+ asyncio.run(main())
112
122
  ```
113
123
 
114
124
  ## Configuration
@@ -137,10 +147,24 @@ See [PyGEAI Configuration](https://docs.globant.ai/en/wiki?1149,Getting+started+
137
147
  Enables agents to self-critique and iteratively improve their outputs.
138
148
 
139
149
  ```python
140
- from pygeai_orchestration.patterns.reflection import ReflectionAgent
150
+ from pygeai_orchestration import GEAIAgent, AgentConfig, PatternConfig, PatternType, ReflectionPattern
151
+
152
+ agent = GEAIAgent(config=AgentConfig(
153
+ name="reflector",
154
+ model="openai/gpt-4o-mini",
155
+ temperature=0.7
156
+ ))
157
+
158
+ pattern = ReflectionPattern(
159
+ agent=agent,
160
+ config=PatternConfig(
161
+ name="reflection",
162
+ pattern_type=PatternType.REFLECTION,
163
+ max_iterations=3
164
+ )
165
+ )
141
166
 
142
- agent = ReflectionAgent(session=session, agent_id="critic-agent")
143
- result = agent.reflect_and_improve("Initial output", iterations=3)
167
+ result = await pattern.execute("Explain quantum computing in simple terms")
144
168
  ```
145
169
 
146
170
  **Use Cases:**
@@ -148,30 +172,28 @@ result = agent.reflect_and_improve("Initial output", iterations=3)
148
172
  - Code review and refinement
149
173
  - Self-correcting responses
150
174
 
151
- ### 2. Tool Use Pattern
152
- Integrates function calling and tool execution into agent workflows.
153
-
154
- ```python
155
- from pygeai_orchestration.patterns.tool_use import ToolUseAgent
156
-
157
- agent = ToolUseAgent(session=session)
158
- agent.register_tool("search", search_function)
159
- result = agent.execute("Search for information about AI")
160
- ```
161
-
162
- **Use Cases:**
163
- - API integration
164
- - External data retrieval
165
- - Action execution
166
-
167
- ### 3. ReAct Pattern
175
+ ### 2. ReAct Pattern
168
176
  Implements the Reasoning + Acting loop for step-by-step problem solving.
169
177
 
170
178
  ```python
171
- from pygeai_orchestration.patterns.react import ReActAgent
179
+ from pygeai_orchestration import GEAIAgent, AgentConfig, PatternConfig, PatternType, ReActPattern
180
+
181
+ agent = GEAIAgent(config=AgentConfig(
182
+ name="reasoner",
183
+ model="openai/gpt-4o-mini",
184
+ temperature=0.7
185
+ ))
186
+
187
+ pattern = ReActPattern(
188
+ agent=agent,
189
+ config=PatternConfig(
190
+ name="react",
191
+ pattern_type=PatternType.REACT,
192
+ max_iterations=5
193
+ )
194
+ )
172
195
 
173
- agent = ReActAgent(session=session, agent_id="reasoning-agent")
174
- result = agent.solve("Complex multi-step problem")
196
+ result = await pattern.execute("Research and summarize renewable energy benefits")
175
197
  ```
176
198
 
177
199
  **Use Cases:**
@@ -179,15 +201,28 @@ result = agent.solve("Complex multi-step problem")
179
201
  - Research tasks
180
202
  - Multi-step workflows
181
203
 
182
- ### 4. Planning Pattern
204
+ ### 3. Planning Pattern
183
205
  Creates and executes multi-step plans with adaptive execution.
184
206
 
185
207
  ```python
186
- from pygeai_orchestration.patterns.planning import PlanningAgent
208
+ from pygeai_orchestration import GEAIAgent, AgentConfig, PatternConfig, PatternType, PlanningPattern
209
+
210
+ agent = GEAIAgent(config=AgentConfig(
211
+ name="planner",
212
+ model="openai/gpt-4o-mini",
213
+ temperature=0.5
214
+ ))
215
+
216
+ pattern = PlanningPattern(
217
+ agent=agent,
218
+ config=PatternConfig(
219
+ name="planning",
220
+ pattern_type=PatternType.PLANNING,
221
+ max_iterations=1
222
+ )
223
+ )
187
224
 
188
- agent = PlanningAgent(session=session, planner_id="planner")
189
- plan = agent.create_plan("Build a web application")
190
- result = agent.execute_plan(plan)
225
+ result = await pattern.execute("Create a project plan for building a REST API")
191
226
  ```
192
227
 
193
228
  **Use Cases:**
@@ -195,16 +230,92 @@ result = agent.execute_plan(plan)
195
230
  - Task decomposition
196
231
  - Workflow automation
197
232
 
233
+ ### 4. Tool Use Pattern
234
+ Integrates function calling and tool execution into agent workflows.
235
+
236
+ ```python
237
+ from pygeai_orchestration import (
238
+ GEAIAgent, AgentConfig, PatternConfig, PatternType,
239
+ ToolUsePattern, BaseTool, ToolConfig, ToolResult, ToolCategory
240
+ )
241
+
242
+ class CalculatorTool(BaseTool):
243
+ def __init__(self):
244
+ super().__init__(ToolConfig(
245
+ name="calculator",
246
+ description="Performs calculations",
247
+ category=ToolCategory.COMPUTATION,
248
+ parameters_schema={"operation": "string", "values": "list"}
249
+ ))
250
+
251
+ def validate_parameters(self, parameters):
252
+ return "operation" in parameters and "values" in parameters
253
+
254
+ async def execute(self, operation, values, **kwargs):
255
+ if operation == "average":
256
+ result = sum(values) / len(values)
257
+ return ToolResult(success=True, result=result)
258
+ return ToolResult(success=False, error="Unknown operation")
259
+
260
+ agent = GEAIAgent(config=AgentConfig(name="calculator", model="openai/gpt-4o-mini"))
261
+ pattern = ToolUsePattern(
262
+ agent=agent,
263
+ config=PatternConfig(name="tools", pattern_type=PatternType.TOOL_USE),
264
+ tools=[CalculatorTool()]
265
+ )
266
+
267
+ result = await pattern.execute("Calculate average of: 10, 20, 30")
268
+ ```
269
+
270
+ **Use Cases:**
271
+ - API integration
272
+ - External data retrieval
273
+ - Action execution
274
+
198
275
  ### 5. Multi-Agent Pattern
199
276
  Coordinates multiple agents working collaboratively on complex tasks.
200
277
 
201
278
  ```python
202
- from pygeai_orchestration.patterns.multi_agent import MultiAgentCoordinator
279
+ from pygeai_orchestration import (
280
+ GEAIAgent, AgentConfig, PatternConfig, PatternType, MultiAgentPattern, AgentRole
281
+ )
282
+
283
+ # Create specialized agents
284
+ researcher = GEAIAgent(config=AgentConfig(
285
+ name="researcher",
286
+ model="openai/gpt-4o-mini",
287
+ system_prompt="You are a research specialist."
288
+ ))
289
+
290
+ writer = GEAIAgent(config=AgentConfig(
291
+ name="writer",
292
+ model="openai/gpt-4o-mini",
293
+ system_prompt="You are a technical writer."
294
+ ))
295
+
296
+ coordinator = GEAIAgent(config=AgentConfig(
297
+ name="coordinator",
298
+ model="openai/gpt-4o-mini",
299
+ system_prompt="You coordinate tasks and synthesize results."
300
+ ))
301
+
302
+ # Create agent roles
303
+ agent_roles = [
304
+ AgentRole(name="researcher", agent=researcher, role_description="Researches topics"),
305
+ AgentRole(name="writer", agent=writer, role_description="Writes reports")
306
+ ]
307
+
308
+ # Create multi-agent pattern
309
+ pattern = MultiAgentPattern(
310
+ agents=agent_roles,
311
+ coordinator_agent=coordinator,
312
+ config=PatternConfig(
313
+ name="collaboration",
314
+ pattern_type=PatternType.MULTI_AGENT
315
+ )
316
+ )
203
317
 
204
- coordinator = MultiAgentCoordinator(session=session)
205
- coordinator.add_agent("researcher", researcher_agent)
206
- coordinator.add_agent("writer", writer_agent)
207
- result = coordinator.execute("Create research report")
318
+ result = await pattern.execute("Create a report on AI in healthcare")
208
319
  ```
209
320
 
210
321
  **Use Cases:**
@@ -217,14 +328,13 @@ result = coordinator.execute("Create research report")
217
328
  - [Getting Started Guide](docs/getting-started.md)
218
329
  - [Pattern Documentation](docs/patterns/)
219
330
  - [API Reference](docs/api-reference/)
220
- - [Examples](snippets/)
331
+ - [Code Snippets](snippets/)
221
332
 
222
333
  ## Development
223
334
 
224
335
  ### Setup Development Environment
225
336
 
226
337
  ```bash
227
- git clone https://docs.globant.ai/en/wiki?1149,Getting+started+with+PyGEAI-orchestration.git
228
338
  cd pygeai-orchestration
229
339
  python -m venv venv
230
340
  source venv/bin/activate # On Windows: venv\Scripts\activate
@@ -247,15 +357,35 @@ python testing.py --coverage
247
357
 
248
358
  See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed development guidelines.
249
359
 
250
- ## Examples
360
+ ## Code Snippets
361
+
362
+ Check the [snippets/](snippets/) directory for working code examples:
251
363
 
252
- Check the [snippets/](snippets/) directory for working examples of each pattern:
364
+ ### Reflection Pattern
365
+ - [reflection_explanation.py](snippets/reflection_explanation.py) - Iterative explanation improvement
366
+ - [reflection_code_review.py](snippets/reflection_code_review.py) - Code review with self-critique
253
367
 
254
- - [Reflection Pattern Example](snippets/reflection/basic_reflection.py)
255
- - [Tool Use Pattern Example](snippets/tool_use/function_calling.py)
256
- - [ReAct Pattern Example](snippets/react/simple_react_loop.py)
257
- - [Planning Pattern Example](snippets/planning/multi_step_plan.py)
258
- - [Multi-Agent Pattern Example](snippets/multi_agent/collaborative_agents.py)
368
+ ### ReAct Pattern
369
+ - [react_research.py](snippets/react_research.py) - Structured research tasks
370
+ - [react_problem_solving.py](snippets/react_problem_solving.py) - Step-by-step problem solving
371
+
372
+ ### Planning Pattern
373
+ - [planning_project.py](snippets/planning_project.py) - Project planning and breakdown
374
+ - [planning_analysis.py](snippets/planning_analysis.py) - Data analysis planning
375
+
376
+ ### Tool Use Pattern
377
+ - [tool_use_calculator.py](snippets/tool_use_calculator.py) - Mathematical operations with tools
378
+ - [tool_use_data_processing.py](snippets/tool_use_data_processing.py) - Data validation and transformation
379
+
380
+ ### Multi-Agent Pattern
381
+ - [multi_agent_collaboration.py](snippets/multi_agent_collaboration.py) - Collaborative multi-agent workflow
382
+
383
+ Run any snippet:
384
+ ```bash
385
+ python snippets/reflection_explanation.py
386
+ python snippets/react_research.py
387
+ python snippets/planning_project.py
388
+ ```
259
389
 
260
390
  ## Contributing
261
391
 
@@ -1,4 +1,4 @@
1
- pygeai_orchestration/__init__.py,sha256=phPtSd0SgtSOicRoZAbgkSQCPv0wPeWHWz-lpcEujx0,1820
1
+ pygeai_orchestration/__init__.py,sha256=ZSKEjVRjkUzQtanmdtpFuXimNXShI-eqli8Lq52Cq8M,1840
2
2
  pygeai_orchestration/cli/__init__.py,sha256=d6wFWuMlcMLng3lBfjSOfhnO_tZINHfNUOmA7-zwPX4,134
3
3
  pygeai_orchestration/cli/__main__.py,sha256=2AmJiRvdlVSu3T6FmFAzQuu4a5llrUeMfUX8ShQxhus,157
4
4
  pygeai_orchestration/cli/error_handler.py,sha256=ReeeeX2TvJZBgdCc0hzvLZd8LYSQVqYI5hAEqJ4FCCM,3862
@@ -8,16 +8,16 @@ pygeai_orchestration/cli/interactive.py,sha256=KVZzgjMS89dDQM25XohcFb3dTbjpMsWV_
8
8
  pygeai_orchestration/cli/commands/__init__.py,sha256=PLWgWUXomwNCqR-wrl_-fWOYFN8PeIAvPnYvmzvzg0w,232
9
9
  pygeai_orchestration/cli/commands/base.py,sha256=BWjuxk06KkRVozCMbwjD_pkzrsAHWE9TgVKQegkIHoM,6558
10
10
  pygeai_orchestration/cli/texts/help.py,sha256=vHAA-2SSrSYpQLfLp3Ruz0-WEVb8UmCahgDkOZEcGGI,5423
11
- pygeai_orchestration/core/__init__.py,sha256=muVm1M6yfTgYDL6Fe1h6hdKB8QLJKQrWBgRj3svOSlk,2380
11
+ pygeai_orchestration/core/__init__.py,sha256=33I1phMJ3skCMBAsOHVKd3pQ8cBzCjaPR95DWxs8RRE,2294
12
12
  pygeai_orchestration/core/composition.py,sha256=j_mV0iNJfPkCO8h1rrzKY0eL00g77C8D_Hy6qPnDaMw,6654
13
13
  pygeai_orchestration/core/config.py,sha256=m2dbBejao9ku0od4jYo4Xn-HmDvq_d44EYJkZKGgd4I,11493
14
14
  pygeai_orchestration/core/exceptions.py,sha256=nZWQlPFQtyGmx-qtErydXvIfiqkXuBlsxoofDyDoRLQ,13282
15
15
  pygeai_orchestration/core/handlers.py,sha256=6OMo3xZvHwITdn8J4kX7Wi65iWGRwnL0ioHLNmFWwBQ,13474
16
- pygeai_orchestration/core/base/__init__.py,sha256=VuUeoAVxKN1DOXMLKwkhPSkfMFVcKPwU0LP5M9jKeaM,622
16
+ pygeai_orchestration/core/base/__init__.py,sha256=8w_BBaGo3x4_5xO_3H3DtfjF1i1AZYQ98ynfdtoZXNg,802
17
17
  pygeai_orchestration/core/base/agent.py,sha256=J_xRVE1MXPbXWC1ndwMHMVWY44S0myIzNfVPJzoE7Lo,4446
18
- pygeai_orchestration/core/base/geai_agent.py,sha256=PG0X8gmKiU0MxkRKJchvcBOztcVCk_eXwJ3kmcRi4aU,5097
19
- pygeai_orchestration/core/base/geai_orchestrator.py,sha256=sGEdUc4TeKJ_WiPw91FBkXCkEWO986WOXbm9LMp6CL8,2730
20
- pygeai_orchestration/core/base/orchestrator.py,sha256=83BIjYerW1ADnzWG_GGIzLTZF_nS93cb4uXp9KWryAU,4835
18
+ pygeai_orchestration/core/base/geai_agent.py,sha256=ZS_flu4CQK2orxvctGW-GWKFiUqwchWIAOwVkjgDDpU,4371
19
+ pygeai_orchestration/core/base/geai_orchestrator.py,sha256=QGkH1ovkpyrFPCIq_61E_-d-jSRGmiQ4dK0q02iVSkY,2120
20
+ pygeai_orchestration/core/base/orchestrator.py,sha256=ZA5pvtbLqsK5yfTYCLLoEUmtoTgc8ceiHqXkhxqVmyc,4895
21
21
  pygeai_orchestration/core/base/pattern.py,sha256=vuj1UXLuaZvbhjiifwqThnQ_4uaRBkv2VQ5FBrY8Xxs,6114
22
22
  pygeai_orchestration/core/base/tool.py,sha256=sypjwrMKiiuwi6VmbXIVoIOkQ4RZWpZD0aSlOCKYOSs,5491
23
23
  pygeai_orchestration/core/common/__init__.py,sha256=akhDVqt8uFH0u2k4w_STrKZJ3ndjtpRDkp46baxCn6U,416
@@ -25,10 +25,9 @@ pygeai_orchestration/core/common/context.py,sha256=mMch8-9mLReYglBMbIB2RCDYn7EGj
25
25
  pygeai_orchestration/core/common/memory.py,sha256=1jYrqc1sPJujuIcNQLITXbKnQ_WMGjkvcNTMDkoQU9o,5841
26
26
  pygeai_orchestration/core/common/message.py,sha256=4JB3ZPeegaRvEYf1MKy7NBHm76oCBYf8V6cuNIf9kzw,1732
27
27
  pygeai_orchestration/core/common/state.py,sha256=mHo7ozjvPdHZfd-sbVg6t9HLND7ll1xD6sm6v8nCrb4,5690
28
- pygeai_orchestration/core/utils/__init__.py,sha256=-DVGUjf1t4XeWNk4SPrMTJcVI1Nf87-j-QJ_7EagsPI,819
28
+ pygeai_orchestration/core/utils/__init__.py,sha256=X_CJGxoZM4ptt5aRS4SJr74r8TfHTLfpONkVNEb5DkI,845
29
29
  pygeai_orchestration/core/utils/cache.py,sha256=TJLtj115EXqlLrKLMoK7JCT-fZ1TGSjVxmJyW6n2p8c,4108
30
30
  pygeai_orchestration/core/utils/config.py,sha256=S2gzAsL20-h_AEFDj0izjlXhWucBLwbE7Vv4ovUiJIM,2775
31
- pygeai_orchestration/core/utils/logging.py,sha256=BPi0s9dU4i6e4E2HZU1omqI79JhaJ9js533RG_BFAtE,1812
32
31
  pygeai_orchestration/core/utils/metrics.py,sha256=Kw8hA-PS6UHMLf0pEG2XQZvcBbuIFhHdo1kWEMf6Vz8,6359
33
32
  pygeai_orchestration/core/utils/validators.py,sha256=EoVQSrJDmM8dGlqAoM_1q3B7SBAyI3yuLfcj3weZuio,5146
34
33
  pygeai_orchestration/dev/__init__.py,sha256=e-GSMmpkN1cINRDtInrjKTQogSJ2h-Q1ya_YaaMRF5s,476
@@ -36,11 +35,11 @@ pygeai_orchestration/dev/debug.py,sha256=0RJed1TCreaSm7HC9ijbd9EeMoh3zFn4osjrYDc
36
35
  pygeai_orchestration/dev/templates.py,sha256=J57-8Stg_m-f-cj_Zl9Yz_VNEZA-trGM8SKdsdzH7NQ,8143
37
36
  pygeai_orchestration/dev/testing.py,sha256=_zXvj3JHJNFEbZJnK-OdtL_tD-3xQeCHMrJ39UYqaqg,7826
38
37
  pygeai_orchestration/patterns/__init__.py,sha256=W5qROE1pbeVOgPx6xiKZtQp0eQPL9kEhL6Et3t6kBA8,376
39
- pygeai_orchestration/patterns/multi_agent.py,sha256=fe_9AS2L7b_M0-ahcwCgBjh_s8zYUi1nz7nS6OD5E6I,9857
40
- pygeai_orchestration/patterns/planning.py,sha256=JITIexKfmc1H2KTVCxbq9EhMGbwbYo4xwfVttW5zsc0,8885
41
- pygeai_orchestration/patterns/react.py,sha256=P1aNgjgrEPP-zUO5OfUx0q2GO9J_yvRakirRFiPJfho,9320
42
- pygeai_orchestration/patterns/reflection.py,sha256=KRthEpuGKH3LM0ceY0cahpC9kAmmH8HqXeF63r_kqUY,5728
43
- pygeai_orchestration/patterns/tool_use.py,sha256=trJPV_SzXOD6mXIAivJASHaahxYQZjBZcVmV57QQUv4,7594
38
+ pygeai_orchestration/patterns/multi_agent.py,sha256=Rn1HJUeNRav--zsn075IC9tka6oYbn7lC1-583__Eiw,9903
39
+ pygeai_orchestration/patterns/planning.py,sha256=rBDiX_DH5hE1HgOJt4MF6WOtOksoXH6JkbfaIFaYH8A,8931
40
+ pygeai_orchestration/patterns/react.py,sha256=hNKh9EgdfUGLsO7sUi3AK8lq2EJL9QrhYXF-xsxqyto,9366
41
+ pygeai_orchestration/patterns/reflection.py,sha256=MsjYlA4xHoZbs6wpI84ov_l-miXhHvO2W3Hy-CJcx4E,5774
42
+ pygeai_orchestration/patterns/tool_use.py,sha256=ET0Sa8R-a2RcHzRY60voSf1TRVt9geiVzihCKtCFh1o,7640
44
43
  pygeai_orchestration/tests/__init__.py,sha256=nzx1KsiYalL_YuXKE6acW8Dj5flmMg0-i4gyYO0gV54,22
45
44
  pygeai_orchestration/tests/test_base_classes.py,sha256=9VcME1C1fY1cijblzh639ZQhV6-iWGuEx80kDRpDr6k,5673
46
45
  pygeai_orchestration/tests/test_cache.py,sha256=t_iYB_La1mkKBEnFinl10kNa1IVtW_yWjKq0dz8-Z4w,5705
@@ -53,9 +52,9 @@ pygeai_orchestration/tests/test_exceptions.py,sha256=l_YlVxZguM-xcUNlOl8u9R3vx_O
53
52
  pygeai_orchestration/tests/test_handlers.py,sha256=t3ZCbif4npxsgoYM6vpCrxOru0q-7f0ARjYAE1SuK7Y,12166
54
53
  pygeai_orchestration/tests/test_metrics.py,sha256=GP36BuTxp7ydptG4nGo804yB91UkBHuskEfJuZwkZvE,6078
55
54
  pygeai_orchestration/tests/test_patterns.py,sha256=9qarHU_9R70nfWf98TzMiJO_XCfz9-kOn9Ju2RQnogs,5051
56
- pygeai_orchestration-0.1.0b5.dist-info/licenses/LICENSE,sha256=HrOw5fbeVfHobmqgadP4r7dOPCMDA4uOfFX8pE3MDT0,1072
57
- pygeai_orchestration-0.1.0b5.dist-info/METADATA,sha256=2-mOXNUKIch8AaNw25Ni8VMNupeBGI0_49eDrhjub6k,8311
58
- pygeai_orchestration-0.1.0b5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
59
- pygeai_orchestration-0.1.0b5.dist-info/entry_points.txt,sha256=p8ODRFqLwrrhoS6FlQW330_J59-0ZjSd6x8kAYYLm7E,69
60
- pygeai_orchestration-0.1.0b5.dist-info/top_level.txt,sha256=8gLeyR8RXLump7AkakhU7kFBh6O7XTvrJi1bKK4e39g,21
61
- pygeai_orchestration-0.1.0b5.dist-info/RECORD,,
55
+ pygeai_orchestration-0.1.0b7.dist-info/licenses/LICENSE,sha256=HrOw5fbeVfHobmqgadP4r7dOPCMDA4uOfFX8pE3MDT0,1072
56
+ pygeai_orchestration-0.1.0b7.dist-info/METADATA,sha256=kVYrupmNerxCJVa12LqrR80SPbofje58N-_nnOOLE-Q,11933
57
+ pygeai_orchestration-0.1.0b7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
58
+ pygeai_orchestration-0.1.0b7.dist-info/entry_points.txt,sha256=p8ODRFqLwrrhoS6FlQW330_J59-0ZjSd6x8kAYYLm7E,69
59
+ pygeai_orchestration-0.1.0b7.dist-info/top_level.txt,sha256=8gLeyR8RXLump7AkakhU7kFBh6O7XTvrJi1bKK4e39g,21
60
+ pygeai_orchestration-0.1.0b7.dist-info/RECORD,,
@@ -1,57 +0,0 @@
1
- import logging
2
- import sys
3
- from typing import Optional
4
-
5
-
6
- class OrchestrationLogger:
7
- _instance: Optional["OrchestrationLogger"] = None
8
-
9
- def __new__(cls):
10
- if cls._instance is None:
11
- cls._instance = super().__new__(cls)
12
- return cls._instance
13
-
14
- def __init__(self):
15
- if not hasattr(self, "_initialized"):
16
- self._logger = logging.getLogger("pygeai_orchestration")
17
- self._logger.setLevel(logging.INFO)
18
-
19
- if not self._logger.handlers:
20
- handler = logging.StreamHandler(sys.stdout)
21
- formatter = logging.Formatter(
22
- "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
23
- datefmt="%Y-%m-%d %H:%M:%S",
24
- )
25
- handler.setFormatter(formatter)
26
- self._logger.addHandler(handler)
27
-
28
- self._initialized = True
29
-
30
- def set_level(self, level: str) -> None:
31
- level_map = {
32
- "debug": logging.DEBUG,
33
- "info": logging.INFO,
34
- "warning": logging.WARNING,
35
- "error": logging.ERROR,
36
- "critical": logging.CRITICAL,
37
- }
38
- self._logger.setLevel(level_map.get(level.lower(), logging.INFO))
39
-
40
- def debug(self, message: str, **kwargs) -> None:
41
- self._logger.debug(message, **kwargs)
42
-
43
- def info(self, message: str, **kwargs) -> None:
44
- self._logger.info(message, **kwargs)
45
-
46
- def warning(self, message: str, **kwargs) -> None:
47
- self._logger.warning(message, **kwargs)
48
-
49
- def error(self, message: str, **kwargs) -> None:
50
- self._logger.error(message, **kwargs)
51
-
52
- def critical(self, message: str, **kwargs) -> None:
53
- self._logger.critical(message, **kwargs)
54
-
55
-
56
- def get_logger() -> OrchestrationLogger:
57
- return OrchestrationLogger()