praisonaiagents 0.0.33__py3-none-any.whl → 0.0.35__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,8 @@ from ..main import (
16
16
  display_self_reflection,
17
17
  ReflectionOutput,
18
18
  client,
19
- error_logs
19
+ error_logs,
20
+ adisplay_instruction
20
21
  )
21
22
  import inspect
22
23
 
@@ -10,14 +10,16 @@ class LoopItems(BaseModel):
10
10
  items: List[Any]
11
11
 
12
12
  class Process:
13
- def __init__(self, tasks: Dict[str, Task], agents: List[Agent], manager_llm: Optional[str] = None, verbose: bool = False):
13
+ def __init__(self, tasks: Dict[str, Task], agents: List[Agent], manager_llm: Optional[str] = None, verbose: bool = False, max_iter: int = 10):
14
14
  self.tasks = tasks
15
15
  self.agents = agents
16
16
  self.manager_llm = manager_llm
17
17
  self.verbose = verbose
18
+ self.max_iter = max_iter
18
19
 
19
20
  async def aworkflow(self) -> AsyncGenerator[str, None]:
20
21
  """Async version of workflow method"""
22
+ current_iter = 0 # Track how many times we've looped
21
23
  # Build workflow relationships first
22
24
  for task in self.tasks.values():
23
25
  if task.next_tasks:
@@ -41,7 +43,12 @@ class Process:
41
43
  visited_tasks = set()
42
44
  loop_data = {} # Store loop-specific data
43
45
 
44
- while current_task and current_task.id not in visited_tasks:
46
+ while current_task:
47
+ current_iter += 1
48
+ if current_iter > self.max_iter:
49
+ logging.info(f"Max iteration limit {self.max_iter} reached, ending workflow.")
50
+ break
51
+
45
52
  task_id = current_task.id
46
53
  logging.info(f"Executing workflow task: {current_task.name if current_task.name else task_id}")
47
54
 
@@ -111,6 +118,11 @@ Return a JSON object with an 'items' array containing the items to process.
111
118
  yield task_id
112
119
  visited_tasks.add(task_id)
113
120
 
121
+ # Reset completed task to "not started" so it can run again
122
+ if self.tasks[task_id].status == "completed":
123
+ logging.debug(f"Task {task_id} was completed, resetting to 'not started' for next iteration.")
124
+ self.tasks[task_id].status = "not started"
125
+
114
126
  # Handle loop progression
115
127
  if current_task.task_type == "loop":
116
128
  loop_key = f"loop_{current_task.name}"
@@ -291,6 +303,7 @@ Provide a JSON with the structure:
291
303
 
292
304
  def workflow(self):
293
305
  """Synchronous version of workflow method"""
306
+ current_iter = 0 # Track how many times we've looped
294
307
  # Build workflow relationships first
295
308
  for task in self.tasks.values():
296
309
  if task.next_tasks:
@@ -314,7 +327,12 @@ Provide a JSON with the structure:
314
327
  visited_tasks = set()
315
328
  loop_data = {} # Store loop-specific data
316
329
 
317
- while current_task and current_task.id not in visited_tasks:
330
+ while current_task:
331
+ current_iter += 1
332
+ if current_iter > self.max_iter:
333
+ logging.info(f"Max iteration limit {self.max_iter} reached, ending workflow.")
334
+ break
335
+
318
336
  task_id = current_task.id
319
337
  logging.info(f"Executing workflow task: {current_task.name if current_task.name else task_id}")
320
338
 
@@ -378,6 +396,11 @@ Return a JSON object with an 'items' array containing the items to process.
378
396
  yield task_id
379
397
  visited_tasks.add(task_id)
380
398
 
399
+ # Reset completed task to "not started" so it can run again
400
+ if self.tasks[task_id].status == "completed":
401
+ logging.debug(f"Task {task_id} was completed, resetting to 'not started' for next iteration.")
402
+ self.tasks[task_id].status = "not started"
403
+
381
404
  # Handle loop progression
382
405
  if current_task.task_type == "loop":
383
406
  loop_key = f"loop_{current_task.name}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: praisonaiagents
3
- Version: 0.0.33
3
+ Version: 0.0.35
4
4
  Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
5
5
  Author: Mervin Praison
6
6
  Requires-Dist: pydantic
@@ -1,13 +1,13 @@
1
1
  praisonaiagents/__init__.py,sha256=Pm_HNlIsenf5zIstcVNk6nteJmOEnI4nB-zB-YL0Jgo,1160
2
2
  praisonaiagents/main.py,sha256=uMBdwxjnJKHLPUzr_5vXlkuhCUO6EW5O8XC0M-h47sE,13915
3
3
  praisonaiagents/agent/__init__.py,sha256=sKO8wGEXvtCrvV1e834r1Okv0XAqAxqZCqz6hKLiTvA,79
4
- praisonaiagents/agent/agent.py,sha256=DDyA8JlHkKoKliWlBC3iNccR2q5rdYljbwogAi1vaUY,34581
4
+ praisonaiagents/agent/agent.py,sha256=vY3RnrRoXQv_0-_Yo-qw-M_P4SKS4tzEbchD7Qi6rzc,34607
5
5
  praisonaiagents/agents/__init__.py,sha256=_1d6Pqyk9EoBSo7E68sKyd1jDRlN1vxvVIRpoMc0Jcw,168
6
6
  praisonaiagents/agents/agents.py,sha256=Os_k25-temlpzzncyElqbQI-e29nlcxqfJYy_ZUIprY,31004
7
7
  praisonaiagents/agents/autoagents.py,sha256=bjC2O5oZmoJItJXIMPTWc2lsp_AJC9tMiTQOal2hwPA,13532
8
8
  praisonaiagents/memory/memory.py,sha256=ZxqSpOUxk9jeTKGW0ZiTifC0uZtym-EZILP3kuOOKkU,35626
9
9
  praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
10
- praisonaiagents/process/process.py,sha256=_tNdptYceCqh8tVIW7faCnxZ4fWtdT20hFfWucVhEEg,25209
10
+ praisonaiagents/process/process.py,sha256=uSudOFI1ZlGM_nbT8qHD4iIP3y5Ygu8V-izLot2te70,26316
11
11
  praisonaiagents/task/__init__.py,sha256=VL5hXVmyGjINb34AalxpBMl-YW9m5EDcRkMTKkSSl7c,80
12
12
  praisonaiagents/task/task.py,sha256=mwmk98nesfz102qTnHSE5VuuPIgHiPDxjeEX7b7g2BA,10023
13
13
  praisonaiagents/tools/__init__.py,sha256=-0lV5n5cG54vYW6REjXIfuJnCLKnfQIDlXsySCaPB9s,7347
@@ -30,7 +30,7 @@ praisonaiagents/tools/wikipedia_tools.py,sha256=pGko-f33wqXgxJTv8db7TbizY5XnzBQR
30
30
  praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxNMMs1A,17122
31
31
  praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
32
32
  praisonaiagents/tools/yfinance_tools.py,sha256=nmzjS7G_5GqMQD4r867mt17dHg5xvtsYDDfOPh68SgE,8105
33
- praisonaiagents-0.0.33.dist-info/METADATA,sha256=BaYWcI0jrYHHjKXo7v3zZsFIb68NtFQpQMQZQ8_9g3o,306
34
- praisonaiagents-0.0.33.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
35
- praisonaiagents-0.0.33.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
36
- praisonaiagents-0.0.33.dist-info/RECORD,,
33
+ praisonaiagents-0.0.35.dist-info/METADATA,sha256=I_0EBHLqimghdba20GP1Cf_cvJxjhM18i9bC6OgN85c,306
34
+ praisonaiagents-0.0.35.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
35
+ praisonaiagents-0.0.35.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
36
+ praisonaiagents-0.0.35.dist-info/RECORD,,