praisonaiagents 0.0.40__py3-none-any.whl → 0.0.41__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.
@@ -485,9 +485,9 @@ Your Role: {self.role}\n
485
485
  Your Goal: {self.goal}
486
486
  """
487
487
  if output_json:
488
- system_prompt += f"\nReturn ONLY a JSON object that matches this Pydantic model: {output_json.schema_json()}"
488
+ system_prompt += f"\nReturn ONLY a JSON object that matches this Pydantic model: {json.dumps(output_json.model_json_schema())}"
489
489
  elif output_pydantic:
490
- system_prompt += f"\nReturn ONLY a JSON object that matches this Pydantic model: {output_pydantic.schema_json()}"
490
+ system_prompt += f"\nReturn ONLY a JSON object that matches this Pydantic model: {json.dumps(output_pydantic.model_json_schema())}"
491
491
  else:
492
492
  system_prompt = None
493
493
 
@@ -677,9 +677,9 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
677
677
  # Build system prompt
678
678
  system_prompt = self.system_prompt
679
679
  if output_json:
680
- system_prompt += f"\nReturn ONLY a JSON object that matches this Pydantic model: {output_json.schema_json()}"
680
+ system_prompt += f"\nReturn ONLY a JSON object that matches this Pydantic model: {json.dumps(output_json.model_json_schema())}"
681
681
  elif output_pydantic:
682
- system_prompt += f"\nReturn ONLY a JSON object that matches this Pydantic model: {output_pydantic.schema_json()}"
682
+ system_prompt += f"\nReturn ONLY a JSON object that matches this Pydantic model: {json.dumps(output_pydantic.model_json_schema())}"
683
683
 
684
684
  # Build messages
685
685
  if isinstance(prompt, str):
@@ -229,15 +229,28 @@ You need to do the following task: {task.description}.
229
229
  Expected Output: {task.expected_output}.
230
230
  """
231
231
  if task.context:
232
- context_results = ""
233
- for context_task in task.context:
234
- if context_task.result:
235
- context_results += f"Result of previous task {context_task.name if context_task.name else context_task.description}: {context_task.result.raw}\n"
236
- else:
237
- context_results += f"Previous task {context_task.name if context_task.name else context_task.description} had no result.\n"
232
+ context_results = [] # Use list to avoid duplicates
233
+ for context_item in task.context:
234
+ if isinstance(context_item, str):
235
+ context_results.append(f"Input Content:\n{context_item}")
236
+ elif isinstance(context_item, list):
237
+ context_results.append(f"Input Content: {' '.join(str(x) for x in context_item)}")
238
+ elif hasattr(context_item, 'result'): # Task object
239
+ if context_item.result:
240
+ context_results.append(
241
+ f"Result of previous task {context_item.name if context_item.name else context_item.description}:\n{context_item.result.raw}"
242
+ )
243
+ else:
244
+ context_results.append(
245
+ f"Previous task {context_item.name if context_item.name else context_item.description} has no result yet."
246
+ )
247
+
248
+ # Join unique context results
249
+ unique_contexts = list(dict.fromkeys(context_results)) # Remove duplicates
238
250
  task_prompt += f"""
239
- Here are the results of previous tasks that might be useful:\n
240
- {context_results}
251
+ Context:
252
+
253
+ {' '.join(unique_contexts)}
241
254
  """
242
255
  task_prompt += "Please provide only the final result of your work. Do not add any conversation or extra explanation."
243
256
 
@@ -427,8 +440,16 @@ Here are the results of previous tasks that might be useful:\n
427
440
  else:
428
441
  self.run_task(task_id)
429
442
 
430
- async def astart(self):
443
+ async def astart(self, content=None, **kwargs):
431
444
  """Async version of start method"""
445
+ if content:
446
+ # Add content to context of all tasks
447
+ for task in self.tasks.values():
448
+ if isinstance(content, (str, list)):
449
+ if not task.context:
450
+ task.context = []
451
+ task.context.append(content)
452
+
432
453
  await self.arun_all_tasks()
433
454
  return {
434
455
  "task_status": self.get_all_tasks_status(),
@@ -485,16 +506,30 @@ You need to do the following task: {task.description}.
485
506
  Expected Output: {task.expected_output}.
486
507
  """
487
508
  if task.context:
488
- context_results = ""
489
- for context_task in task.context:
490
- if context_task.result:
491
- context_results += f"Result of previous task {context_task.name if context_task.name else context_task.description}: {context_task.result.raw}\n"
492
- else:
493
- context_results += f"Previous task {context_task.name if context_task.name else context_task.description} had no result.\n"
509
+ context_results = [] # Use list to avoid duplicates
510
+ for context_item in task.context:
511
+ if isinstance(context_item, str):
512
+ context_results.append(f"Input Content:\n{context_item}")
513
+ elif isinstance(context_item, list):
514
+ context_results.append(f"Input Content: {' '.join(str(x) for x in context_item)}")
515
+ elif hasattr(context_item, 'result'): # Task object
516
+ if context_item.result:
517
+ context_results.append(
518
+ f"Result of previous task {context_item.name if context_item.name else context_item.description}:\n{context_item.result.raw}"
519
+ )
520
+ else:
521
+ context_results.append(
522
+ f"Previous task {context_item.name if context_item.name else context_item.description} has no result yet."
523
+ )
524
+
525
+ # Join unique context results
526
+ unique_contexts = list(dict.fromkeys(context_results)) # Remove duplicates
494
527
  task_prompt += f"""
495
- Here are the results of previous tasks that might be useful:\n
496
- {context_results}
528
+ Context:
529
+
530
+ {' '.join(unique_contexts)}
497
531
  """
532
+
498
533
  # Add memory context if available
499
534
  if task.memory:
500
535
  try:
@@ -714,12 +749,24 @@ Here are the results of previous tasks that might be useful:\n
714
749
  return str(agent[0])
715
750
  return None
716
751
 
717
- def start(self):
752
+ def start(self, content=None, **kwargs):
753
+ """Start agent execution with optional content and config"""
754
+ if content:
755
+ # Add content to context of all tasks
756
+ for task in self.tasks.values():
757
+ if isinstance(content, (str, list)):
758
+ # If context is empty, initialize it
759
+ if not task.context:
760
+ task.context = []
761
+ # Add content to context
762
+ task.context.append(content)
763
+
764
+ # Run tasks as before
718
765
  self.run_all_tasks()
719
766
  return {
720
767
  "task_status": self.get_all_tasks_status(),
721
768
  "task_results": {task_id: self.get_task_result(task_id) for task_id in self.tasks}
722
- }
769
+ }
723
770
 
724
771
  def set_state(self, key: str, value: Any) -> None:
725
772
  """Set a state value"""
@@ -19,7 +19,7 @@ class Task:
19
19
  agent: Optional[Agent] = None,
20
20
  name: Optional[str] = None,
21
21
  tools: Optional[List[Any]] = None,
22
- context: Optional[List["Task"]] = None,
22
+ context: Optional[List[Union[str, List, 'Task']]] = None,
23
23
  async_execution: Optional[bool] = False,
24
24
  config: Optional[Dict[str, Any]] = None,
25
25
  output_file: Optional[str] = None,
@@ -219,4 +219,33 @@ class Task:
219
219
  self.callback(task_output)
220
220
  except Exception as e:
221
221
  logger.error(f"Task {self.id}: Failed to execute callback: {e}")
222
- logger.exception(e)
222
+ logger.exception(e)
223
+
224
+ task_prompt = f"""
225
+ You need to do the following task: {self.description}.
226
+ Expected Output: {self.expected_output}.
227
+ """
228
+ if self.context:
229
+ context_results = [] # Use list to avoid duplicates
230
+ for context_item in self.context:
231
+ if isinstance(context_item, str):
232
+ context_results.append(f"Input Content:\n{context_item}")
233
+ elif isinstance(context_item, list):
234
+ context_results.append(f"Input Content: {' '.join(str(x) for x in context_item)}")
235
+ elif hasattr(context_item, 'result'): # Task object
236
+ if context_item.result:
237
+ context_results.append(
238
+ f"Result of previous task {context_item.name if context_item.name else context_item.description}:\n{context_item.result.raw}"
239
+ )
240
+ else:
241
+ context_results.append(
242
+ f"Previous task {context_item.name if context_item.name else context_item.description} has no result yet."
243
+ )
244
+
245
+ # Join unique context results
246
+ unique_contexts = list(dict.fromkeys(context_results)) # Remove duplicates
247
+ task_prompt += f"""
248
+ Context:
249
+
250
+ {' '.join(unique_contexts)}
251
+ """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: praisonaiagents
3
- Version: 0.0.40
3
+ Version: 0.0.41
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,9 +1,9 @@
1
1
  praisonaiagents/__init__.py,sha256=MCgAj12hVJ0YZmVmdmZgYAAMfPdWSoNSiDlRJCvrJqA,1276
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=4yRT-bl4Tg6jXO_P3gXXhh2xiQ2TT-wKnCyZrCNyQ4w,37596
4
+ praisonaiagents/agent/agent.py,sha256=hP_I11Z3i7QvgnyQcFFEZnJTB5w_RIfimigFNq5C7Hs,37668
5
5
  praisonaiagents/agents/__init__.py,sha256=_1d6Pqyk9EoBSo7E68sKyd1jDRlN1vxvVIRpoMc0Jcw,168
6
- praisonaiagents/agents/agents.py,sha256=M-nR53A7Qcz_pJ-gyNc4xgM13Nhof7oM-5hXWzr85ho,31250
6
+ praisonaiagents/agents/agents.py,sha256=oGCnbyLE22PU1AqXFhJZpzBnoW926mXXfWi-Q2hhklg,33359
7
7
  praisonaiagents/agents/autoagents.py,sha256=bjC2O5oZmoJItJXIMPTWc2lsp_AJC9tMiTQOal2hwPA,13532
8
8
  praisonaiagents/knowledge/__init__.py,sha256=xL1Eh-a3xsHyIcU4foOWF-JdWYIYBALJH9bge0Ujuto,246
9
9
  praisonaiagents/knowledge/chunking.py,sha256=FzoNY0q8MkvG4gADqk4JcRhmH3lcEHbRdonDgitQa30,6624
@@ -12,7 +12,7 @@ praisonaiagents/memory/memory.py,sha256=ZxqSpOUxk9jeTKGW0ZiTifC0uZtym-EZILP3kuOO
12
12
  praisonaiagents/process/__init__.py,sha256=lkYbL7Hn5a0ldvJtkdH23vfIIZLIcanK-65C0MwaorY,52
13
13
  praisonaiagents/process/process.py,sha256=uSudOFI1ZlGM_nbT8qHD4iIP3y5Ygu8V-izLot2te70,26316
14
14
  praisonaiagents/task/__init__.py,sha256=VL5hXVmyGjINb34AalxpBMl-YW9m5EDcRkMTKkSSl7c,80
15
- praisonaiagents/task/task.py,sha256=mwmk98nesfz102qTnHSE5VuuPIgHiPDxjeEX7b7g2BA,10023
15
+ praisonaiagents/task/task.py,sha256=Tf3CzFNctfTBiy67wfOfT7RnopPGsBntsrHF8012BnE,11383
16
16
  praisonaiagents/tools/__init__.py,sha256=-0lV5n5cG54vYW6REjXIfuJnCLKnfQIDlXsySCaPB9s,7347
17
17
  praisonaiagents/tools/arxiv_tools.py,sha256=1stb31zTjLTon4jCnpZG5de9rKc9QWgC0leLegvPXWo,10528
18
18
  praisonaiagents/tools/calculator_tools.py,sha256=S1xPT74Geurvjm52QMMIG29zDXVEWJmM6nmyY7yF298,9571
@@ -33,7 +33,7 @@ praisonaiagents/tools/wikipedia_tools.py,sha256=pGko-f33wqXgxJTv8db7TbizY5XnzBQR
33
33
  praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxNMMs1A,17122
34
34
  praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
35
35
  praisonaiagents/tools/yfinance_tools.py,sha256=s2PBj_1v7oQnOobo2fDbQBACEHl61ftG4beG6Z979ZE,8529
36
- praisonaiagents-0.0.40.dist-info/METADATA,sha256=EzWmqwSIwOhOfnxHix9_P4VY10kLgzhVoun1N_SvJhQ,664
37
- praisonaiagents-0.0.40.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
38
- praisonaiagents-0.0.40.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
39
- praisonaiagents-0.0.40.dist-info/RECORD,,
36
+ praisonaiagents-0.0.41.dist-info/METADATA,sha256=MvJGnvkhUSu27RFe7WqT7aPPA-vqIYmoANXsggh8GZE,664
37
+ praisonaiagents-0.0.41.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
38
+ praisonaiagents-0.0.41.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
39
+ praisonaiagents-0.0.41.dist-info/RECORD,,