praisonaiagents 0.0.52__tar.gz → 0.0.53__tar.gz

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 (45) hide show
  1. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/PKG-INFO +1 -1
  2. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/agent/agent.py +19 -13
  3. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/agents/agents.py +4 -18
  4. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/llm/llm.py +19 -13
  5. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/task/task.py +18 -1
  6. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents.egg-info/PKG-INFO +1 -1
  7. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/pyproject.toml +1 -1
  8. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/__init__.py +0 -0
  9. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/agent/__init__.py +0 -0
  10. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/agents/__init__.py +0 -0
  11. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/agents/autoagents.py +0 -0
  12. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/knowledge/__init__.py +0 -0
  13. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/knowledge/chunking.py +0 -0
  14. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/knowledge/knowledge.py +0 -0
  15. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/llm/__init__.py +0 -0
  16. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/main.py +0 -0
  17. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/memory/memory.py +0 -0
  18. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/process/__init__.py +0 -0
  19. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/process/process.py +0 -0
  20. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/task/__init__.py +0 -0
  21. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/__init__.py +0 -0
  22. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/arxiv_tools.py +0 -0
  23. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/calculator_tools.py +0 -0
  24. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/csv_tools.py +0 -0
  25. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/duckdb_tools.py +0 -0
  26. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/duckduckgo_tools.py +0 -0
  27. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/excel_tools.py +0 -0
  28. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/file_tools.py +0 -0
  29. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/json_tools.py +0 -0
  30. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/newspaper_tools.py +0 -0
  31. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/pandas_tools.py +0 -0
  32. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/python_tools.py +0 -0
  33. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/shell_tools.py +0 -0
  34. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/spider_tools.py +0 -0
  35. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/test.py +0 -0
  36. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/tools.py +0 -0
  37. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/wikipedia_tools.py +0 -0
  38. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/xml_tools.py +0 -0
  39. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/yaml_tools.py +0 -0
  40. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents/tools/yfinance_tools.py +0 -0
  41. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents.egg-info/SOURCES.txt +0 -0
  42. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents.egg-info/dependency_links.txt +0 -0
  43. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents.egg-info/requires.txt +0 -0
  44. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/praisonaiagents.egg-info/top_level.txt +0 -0
  45. {praisonaiagents-0.0.52 → praisonaiagents-0.0.53}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: praisonaiagents
3
- Version: 0.0.52
3
+ Version: 0.0.53
4
4
  Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
5
5
  Author: Mervin Praison
6
6
  Requires-Dist: pydantic
@@ -318,7 +318,7 @@ class Agent:
318
318
  min_reflect: int = 1,
319
319
  reflect_llm: Optional[str] = None,
320
320
  user_id: Optional[str] = None,
321
- show_reasoning: bool = False
321
+ reasoning_steps: bool = False
322
322
  ):
323
323
  # Add check at start if memory is requested
324
324
  if memory is not None:
@@ -426,7 +426,7 @@ Your Goal: {self.goal}
426
426
 
427
427
  # Store user_id
428
428
  self.user_id = user_id or "praison"
429
- self.show_reasoning = show_reasoning
429
+ self.reasoning_steps = reasoning_steps
430
430
 
431
431
  # Check if knowledge parameter has any values
432
432
  if not knowledge:
@@ -528,7 +528,7 @@ Your Goal: {self.goal}
528
528
  def __str__(self):
529
529
  return f"Agent(name='{self.name}', role='{self.role}', goal='{self.goal}')"
530
530
 
531
- def _chat_completion(self, messages, temperature=0.2, tools=None, stream=True, show_reasoning=False):
531
+ def _chat_completion(self, messages, temperature=0.2, tools=None, stream=True, reasoning_steps=False):
532
532
  start_time = time.time()
533
533
  logging.debug(f"{self.name} sending messages to LLM: {messages}")
534
534
 
@@ -617,7 +617,7 @@ Your Goal: {self.goal}
617
617
  live.update(display_generating(full_response_text, start_time))
618
618
 
619
619
  # Update live display with reasoning content if enabled
620
- if show_reasoning and hasattr(chunk.choices[0].delta, "reasoning_content"):
620
+ if reasoning_steps and hasattr(chunk.choices[0].delta, "reasoning_content"):
621
621
  rc = chunk.choices[0].delta.reasoning_content
622
622
  if rc:
623
623
  reasoning_content += rc
@@ -644,8 +644,8 @@ Your Goal: {self.goal}
644
644
  display_error(f"Error in chat completion: {e}")
645
645
  return None
646
646
 
647
- def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pydantic=None, show_reasoning=False):
648
- show_reasoning = show_reasoning or self.show_reasoning
647
+ def chat(self, prompt, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False):
648
+ reasoning_steps = reasoning_steps or self.reasoning_steps
649
649
  # Search for existing knowledge if any knowledge is provided
650
650
  if self.knowledge:
651
651
  search_results = self.knowledge.search(prompt, agent_id=self.agent_id)
@@ -682,7 +682,7 @@ Your Goal: {self.goal}
682
682
  agent_role=self.role,
683
683
  agent_tools=[t.__name__ if hasattr(t, '__name__') else str(t) for t in self.tools],
684
684
  execute_tool_fn=self.execute_tool, # Pass tool execution function
685
- show_reasoning=show_reasoning
685
+ reasoning_steps=reasoning_steps
686
686
  )
687
687
 
688
688
  self.chat_history.append({"role": "user", "content": prompt})
@@ -752,7 +752,7 @@ Your Goal: {self.goal}
752
752
  agent_tools=agent_tools
753
753
  )
754
754
 
755
- response = self._chat_completion(messages, temperature=temperature, tools=tools if tools else None, show_reasoning=show_reasoning)
755
+ response = self._chat_completion(messages, temperature=temperature, tools=tools if tools else None, reasoning_steps=reasoning_steps)
756
756
  if not response:
757
757
  return None
758
758
 
@@ -811,6 +811,9 @@ Your Goal: {self.goal}
811
811
  if self.verbose:
812
812
  logging.debug(f"Agent {self.name} final response: {response_text}")
813
813
  display_interaction(original_prompt, response_text, markdown=self.markdown, generation_time=time.time() - start_time, console=self.console)
814
+ # Return only reasoning content if reasoning_steps is True
815
+ if reasoning_steps and hasattr(response.choices[0].message, 'reasoning_content'):
816
+ return response.choices[0].message.reasoning_content
814
817
  return response_text
815
818
 
816
819
  reflection_prompt = f"""
@@ -885,9 +888,9 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
885
888
  cleaned = cleaned[:-3].strip()
886
889
  return cleaned
887
890
 
888
- async def achat(self, prompt: str, temperature=0.2, tools=None, output_json=None, output_pydantic=None, show_reasoning=False):
891
+ async def achat(self, prompt: str, temperature=0.2, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False):
889
892
  """Async version of chat method. TODO: Requires Syncing with chat method."""
890
- show_reasoning = show_reasoning or self.show_reasoning
893
+ reasoning_steps = reasoning_steps or self.reasoning_steps
891
894
  try:
892
895
  # Search for existing knowledge if any knowledge is provided
893
896
  if self.knowledge:
@@ -919,7 +922,7 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
919
922
  agent_role=self.role,
920
923
  agent_tools=[t.__name__ if hasattr(t, '__name__') else str(t) for t in self.tools],
921
924
  execute_tool_fn=self.execute_tool_async,
922
- show_reasoning=show_reasoning
925
+ reasoning_steps=reasoning_steps
923
926
  )
924
927
 
925
928
  self.chat_history.append({"role": "user", "content": prompt})
@@ -1034,7 +1037,7 @@ Your Goal: {self.goal}
1034
1037
  display_error(f"Error in achat: {e}")
1035
1038
  return None
1036
1039
 
1037
- async def _achat_completion(self, response, tools, show_reasoning=False):
1040
+ async def _achat_completion(self, response, tools, reasoning_steps=False):
1038
1041
  """Async version of _chat_completion method"""
1039
1042
  try:
1040
1043
  message = response.choices[0].message
@@ -1102,7 +1105,7 @@ Your Goal: {self.goal}
1102
1105
  full_response_text += chunk.choices[0].delta.content
1103
1106
  live.update(display_generating(full_response_text, start_time))
1104
1107
 
1105
- if show_reasoning and hasattr(chunk.choices[0].delta, "reasoning_content"):
1108
+ if reasoning_steps and hasattr(chunk.choices[0].delta, "reasoning_content"):
1106
1109
  rc = chunk.choices[0].delta.reasoning_content
1107
1110
  if rc:
1108
1111
  reasoning_content += rc
@@ -1111,6 +1114,9 @@ Your Goal: {self.goal}
1111
1114
  self.console.print()
1112
1115
 
1113
1116
  final_response = process_stream_chunks(chunks)
1117
+ # Return only reasoning content if reasoning_steps is True
1118
+ if reasoning_steps and hasattr(final_response.choices[0].message, 'reasoning_content'):
1119
+ return final_response.choices[0].message.reasoning_content
1114
1120
  return final_response.choices[0].message.content if final_response else full_response_text
1115
1121
 
1116
1122
  except Exception as e:
@@ -390,15 +390,8 @@ Context:
390
390
  task.status = "completed"
391
391
  # Run execute_callback for memory operations
392
392
  try:
393
- try:
394
- # If a loop is already running, just create the task
395
- loop = asyncio.get_running_loop()
396
- loop.create_task(task.execute_callback(task_output))
397
- except RuntimeError:
398
- # Otherwise, create and set a new loop, and run the callback
399
- loop = asyncio.new_event_loop()
400
- asyncio.set_event_loop(loop)
401
- loop.create_task(task.execute_callback(task_output))
393
+ # Use the new sync wrapper to avoid pending coroutine issues
394
+ task.execute_callback_sync(task_output)
402
395
  except Exception as e:
403
396
  logger.error(f"Error executing memory callback for task {task_id}: {e}")
404
397
  logger.exception(e)
@@ -720,15 +713,8 @@ Context:
720
713
  task.status = "completed"
721
714
  # Run execute_callback for memory operations
722
715
  try:
723
- try:
724
- # If a loop is already running, just create the task
725
- loop = asyncio.get_running_loop()
726
- loop.create_task(task.execute_callback(task_output))
727
- except RuntimeError:
728
- # Otherwise, create and set a new loop, and run the callback
729
- loop = asyncio.new_event_loop()
730
- asyncio.set_event_loop(loop)
731
- loop.create_task(task.execute_callback(task_output))
716
+ # Use the new sync wrapper to avoid pending coroutine issues
717
+ task.execute_callback_sync(task_output)
732
718
  except Exception as e:
733
719
  logger.error(f"Error executing memory callback for task {task_id}: {e}")
734
720
  logger.exception(e)
@@ -148,7 +148,7 @@ class LLM:
148
148
  self.self_reflect = extra_settings.get('self_reflect', False)
149
149
  self.max_reflect = extra_settings.get('max_reflect', 3)
150
150
  self.min_reflect = extra_settings.get('min_reflect', 1)
151
- self.show_reasoning = extra_settings.get('show_reasoning', False)
151
+ self.reasoning_steps = extra_settings.get('reasoning_steps', False)
152
152
 
153
153
  # Enable error dropping for cleaner output
154
154
  litellm.drop_params = True
@@ -178,7 +178,7 @@ class LLM:
178
178
  """Enhanced get_response with all OpenAI-like features"""
179
179
  try:
180
180
  import litellm
181
- show_reasoning = kwargs.get('show_reasoning', self.show_reasoning)
181
+ reasoning_steps = kwargs.get('reasoning_steps', self.reasoning_steps)
182
182
  # Disable litellm debug messages
183
183
  litellm.set_verbose = False
184
184
 
@@ -233,8 +233,8 @@ class LLM:
233
233
  # Get response from LiteLLM
234
234
  start_time = time.time()
235
235
 
236
- # If show_reasoning is True, do a single non-streaming call
237
- if show_reasoning:
236
+ # If reasoning_steps is True, do a single non-streaming call
237
+ if reasoning_steps:
238
238
  resp = litellm.completion(
239
239
  model=self.model,
240
240
  messages=messages,
@@ -337,8 +337,8 @@ class LLM:
337
337
  "content": "Function returned an empty output"
338
338
  })
339
339
 
340
- # If show_reasoning is True, do a single non-streaming call
341
- if show_reasoning:
340
+ # If reasoning_steps is True, do a single non-streaming call
341
+ if reasoning_steps:
342
342
  resp = litellm.completion(
343
343
  model=self.model,
344
344
  messages=messages,
@@ -409,6 +409,9 @@ class LLM:
409
409
  if verbose:
410
410
  display_interaction(original_prompt, response_text, markdown=markdown,
411
411
  generation_time=time.time() - start_time, console=console)
412
+ # Return reasoning content if reasoning_steps is True
413
+ if reasoning_steps and reasoning_content:
414
+ return reasoning_content
412
415
  return response_text
413
416
 
414
417
  # Handle self-reflection
@@ -424,8 +427,8 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
424
427
  {"role": "user", "content": reflection_prompt}
425
428
  ]
426
429
 
427
- # If show_reasoning is True, do a single non-streaming call to capture reasoning
428
- if show_reasoning:
430
+ # If reasoning_steps is True, do a single non-streaming call to capture reasoning
431
+ if reasoning_steps:
429
432
  reflection_resp = litellm.completion(
430
433
  model=self.model,
431
434
  messages=reflection_messages,
@@ -554,7 +557,7 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
554
557
  """Async version of get_response with identical functionality."""
555
558
  try:
556
559
  import litellm
557
- show_reasoning = kwargs.get('show_reasoning', self.show_reasoning)
560
+ reasoning_steps = kwargs.get('reasoning_steps', self.reasoning_steps)
558
561
  litellm.set_verbose = False
559
562
 
560
563
  # Build messages list
@@ -659,7 +662,7 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
659
662
  formatted_tools = None
660
663
 
661
664
  response_text = ""
662
- if show_reasoning:
665
+ if reasoning_steps:
663
666
  # Non-streaming call to capture reasoning
664
667
  resp = await litellm.acompletion(
665
668
  model=self.model,
@@ -766,7 +769,7 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
766
769
 
767
770
  # Get response after tool calls
768
771
  response_text = ""
769
- if show_reasoning:
772
+ if reasoning_steps:
770
773
  # Non-streaming call to capture reasoning
771
774
  resp = await litellm.acompletion(
772
775
  model=self.model,
@@ -838,6 +841,9 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
838
841
  if verbose:
839
842
  display_interaction(original_prompt, response_text, markdown=markdown,
840
843
  generation_time=time.time() - start_time, console=console)
844
+ # Return reasoning content if reasoning_steps is True
845
+ if reasoning_steps and reasoning_content:
846
+ return reasoning_content
841
847
  return response_text
842
848
 
843
849
  # Handle self-reflection
@@ -853,8 +859,8 @@ Output MUST be JSON with 'reflection' and 'satisfactory'.
853
859
  {"role": "user", "content": reflection_prompt}
854
860
  ]
855
861
 
856
- # If show_reasoning is True, do a single non-streaming call to capture reasoning
857
- if show_reasoning:
862
+ # If reasoning_steps is True, do a single non-streaming call to capture reasoning
863
+ if reasoning_steps:
858
864
  reflection_resp = litellm.completion(
859
865
  model=self.model,
860
866
  messages=reflection_messages,
@@ -302,4 +302,21 @@ Expected Output: {self.expected_output}.
302
302
  Context:
303
303
 
304
304
  {' '.join(unique_contexts)}
305
- """
305
+ """
306
+
307
+ def execute_callback_sync(self, task_output: TaskOutput) -> None:
308
+ """
309
+ Synchronous wrapper to ensure that execute_callback is awaited,
310
+ preventing 'Task was destroyed but pending!' warnings if called
311
+ from non-async code.
312
+ """
313
+ import asyncio
314
+ try:
315
+ loop = asyncio.get_running_loop()
316
+ if loop.is_running():
317
+ loop.create_task(self.execute_callback(task_output))
318
+ else:
319
+ loop.run_until_complete(self.execute_callback(task_output))
320
+ except RuntimeError:
321
+ # If no loop is running in this context
322
+ asyncio.run(self.execute_callback(task_output))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: praisonaiagents
3
- Version: 0.0.52
3
+ Version: 0.0.53
4
4
  Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
5
5
  Author: Mervin Praison
6
6
  Requires-Dist: pydantic
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "praisonaiagents"
7
- version = "0.0.52"
7
+ version = "0.0.53"
8
8
  description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
9
9
  authors = [
10
10
  { name="Mervin Praison" }