Skip to content

Commit

Permalink
Update version to 0.0.46 and enhance memory feature checks
Browse files Browse the repository at this point in the history
- Bumped the version of the `praisonaiagents` package from 0.0.45 to 0.0.46 in `pyproject.toml` and `uv.lock` to reflect the latest updates.
- Added import checks for memory features in the `Agent`, `PraisonAIAgents`, and `Task` classes to ensure proper handling of memory dependencies.
- Removed the obsolete `Memory` import from the `__init__.py` file to streamline the codebase.

These changes improve the robustness of the PraisonAI framework by ensuring that memory features are only utilized when the necessary dependencies are installed.
  • Loading branch information
MervinPraison committed Jan 21, 2025
1 parent 298a50a commit 5779819
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
2 changes: 0 additions & 2 deletions agents/praisonaiagents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from .agents.autoagents import AutoAgents
from .knowledge.knowledge import Knowledge
from .knowledge.chunking import Chunking
from .memory.memory import Memory
from .main import (
TaskOutput,
ReflectionOutput,
Expand Down Expand Up @@ -38,7 +37,6 @@
'TaskOutput',
'ReflectionOutput',
'AutoAgents',
'Memory',
'display_interaction',
'display_self_reflection',
'display_instruction',
Expand Down
11 changes: 11 additions & 0 deletions agents/praisonaiagents/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ def __init__(
reflect_llm: Optional[str] = None,
user_id: Optional[str] = None
):
# Add check at start if memory is requested
if memory is not None:
try:
from ..memory.memory import Memory
MEMORY_AVAILABLE = True
except ImportError:
raise ImportError(
"Memory features requested in Agent but memory dependencies not installed. "
"Please install with: pip install \"praisonaiagents[memory]\""
)

# Handle backward compatibility for required fields
if all(x is None for x in [name, role, goal, backstory, instructions]):
raise ValueError("At least one of name, role, goal, backstory, or instructions must be provided")
Expand Down
11 changes: 11 additions & 0 deletions agents/praisonaiagents/agents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ def process_video(video_path: str, seconds_per_frame=2):

class PraisonAIAgents:
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):
# Add check at the start if memory is requested
if memory:
try:
from ..memory.memory import Memory
MEMORY_AVAILABLE = True
except ImportError:
raise ImportError(
"Memory features requested but memory dependencies not installed. "
"Please install with: pip install \"praisonaiagents[memory]\""
)

if not agents:
raise ValueError("At least one agent must be provided")

Expand Down
2 changes: 1 addition & 1 deletion agents/praisonaiagents/memory/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
CHROMADB_AVAILABLE = True
except ImportError:
CHROMADB_AVAILABLE = False
logger.warning("To use memory features, please run: pip install \"praisonaiagents[memory]\"")
pass

try:
import mem0
Expand Down
11 changes: 11 additions & 0 deletions agents/praisonaiagents/task/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ def __init__(
quality_check=True,
input_file: Optional[str] = None
):
# Add check if memory config is provided
if memory is not None or (config and config.get('memory_config')):
try:
from ..memory.memory import Memory
MEMORY_AVAILABLE = True
except ImportError:
raise ImportError(
"Memory features requested in Task but memory dependencies not installed. "
"Please install with: pip install \"praisonaiagents[memory]\""
)

self.input_file = input_file
self.id = str(uuid.uuid4()) if id is None else str(id)
self.name = name
Expand Down
2 changes: 1 addition & 1 deletion agents/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "praisonaiagents"
version = "0.0.45"
version = "0.0.46"
description = "Praison AI agents for completing complex tasks with Self Reflection Agents"
authors = [
{ name="Mervin Praison" }
Expand Down
2 changes: 1 addition & 1 deletion agents/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5779819

Please sign in to comment.