praisonaiagents 0.0.45__py3-none-any.whl → 0.0.47__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.
- praisonaiagents/__init__.py +0 -2
- praisonaiagents/agent/agent.py +413 -237
- praisonaiagents/agents/agents.py +33 -6
- praisonaiagents/llm/__init__.py +20 -0
- praisonaiagents/llm/llm.py +823 -0
- praisonaiagents/main.py +9 -0
- praisonaiagents/memory/memory.py +1 -1
- praisonaiagents/task/task.py +11 -0
- {praisonaiagents-0.0.45.dist-info → praisonaiagents-0.0.47.dist-info}/METADATA +5 -1
- {praisonaiagents-0.0.45.dist-info → praisonaiagents-0.0.47.dist-info}/RECORD +12 -10
- {praisonaiagents-0.0.45.dist-info → praisonaiagents-0.0.47.dist-info}/WHEEL +0 -0
- {praisonaiagents-0.0.45.dist-info → praisonaiagents-0.0.47.dist-info}/top_level.txt +0 -0
praisonaiagents/agents/agents.py
CHANGED
@@ -46,6 +46,17 @@ def process_video(video_path: str, seconds_per_frame=2):
|
|
46
46
|
|
47
47
|
class PraisonAIAgents:
|
48
48
|
def __init__(self, agents, tasks=None, verbose=0, completion_checker=None, max_retries=5, process="sequential", manager_llm=None, memory=False, memory_config=None, embedder=None, user_id=None, max_iter=10):
|
49
|
+
# Add check at the start if memory is requested
|
50
|
+
if memory:
|
51
|
+
try:
|
52
|
+
from ..memory.memory import Memory
|
53
|
+
MEMORY_AVAILABLE = True
|
54
|
+
except ImportError:
|
55
|
+
raise ImportError(
|
56
|
+
"Memory features requested but memory dependencies not installed. "
|
57
|
+
"Please install with: pip install \"praisonaiagents[memory]\""
|
58
|
+
)
|
59
|
+
|
49
60
|
if not agents:
|
50
61
|
raise ValueError("At least one agent must be provided")
|
51
62
|
|
@@ -379,7 +390,15 @@ Context:
|
|
379
390
|
task.status = "completed"
|
380
391
|
# Run execute_callback for memory operations
|
381
392
|
try:
|
382
|
-
|
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))
|
383
402
|
except Exception as e:
|
384
403
|
logger.error(f"Error executing memory callback for task {task_id}: {e}")
|
385
404
|
logger.exception(e)
|
@@ -388,7 +407,12 @@ Context:
|
|
388
407
|
if task.callback:
|
389
408
|
try:
|
390
409
|
if asyncio.iscoroutinefunction(task.callback):
|
391
|
-
|
410
|
+
if asyncio.get_event_loop().is_running():
|
411
|
+
asyncio.create_task(task.callback(task_output))
|
412
|
+
else:
|
413
|
+
loop = asyncio.new_event_loop()
|
414
|
+
asyncio.set_event_loop(loop)
|
415
|
+
loop.run_until_complete(task.callback(task_output))
|
392
416
|
else:
|
393
417
|
task.callback(task_output)
|
394
418
|
except Exception as e:
|
@@ -696,12 +720,15 @@ Context:
|
|
696
720
|
task.status = "completed"
|
697
721
|
# Run execute_callback for memory operations
|
698
722
|
try:
|
699
|
-
|
700
|
-
|
701
|
-
|
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
|
702
729
|
loop = asyncio.new_event_loop()
|
703
730
|
asyncio.set_event_loop(loop)
|
704
|
-
loop.
|
731
|
+
loop.create_task(task.execute_callback(task_output))
|
705
732
|
except Exception as e:
|
706
733
|
logger.error(f"Error executing memory callback for task {task_id}: {e}")
|
707
734
|
logger.exception(e)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import logging
|
2
|
+
import warnings
|
3
|
+
|
4
|
+
# Suppress all relevant logs at module level
|
5
|
+
logging.getLogger("litellm").setLevel(logging.ERROR)
|
6
|
+
logging.getLogger("openai").setLevel(logging.ERROR)
|
7
|
+
logging.getLogger("httpx").setLevel(logging.ERROR)
|
8
|
+
logging.getLogger("httpcore").setLevel(logging.ERROR)
|
9
|
+
logging.getLogger("pydantic").setLevel(logging.ERROR)
|
10
|
+
|
11
|
+
# Suppress pydantic warnings
|
12
|
+
warnings.filterwarnings("ignore", category=UserWarning, module="pydantic")
|
13
|
+
|
14
|
+
# Configure logging to suppress all INFO messages
|
15
|
+
logging.basicConfig(level=logging.WARNING)
|
16
|
+
|
17
|
+
# Import after suppressing warnings
|
18
|
+
from .llm import LLM, LLMContextLengthExceededException
|
19
|
+
|
20
|
+
__all__ = ["LLM", "LLMContextLengthExceededException"]
|