Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 2 additions & 58 deletions src/praisonai/praisonai/agents_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# Import new architecture components
from .framework_adapters.base import FrameworkAdapter
from .framework_adapters.registry import FrameworkAdapterRegistry, get_default_registry
from .tool_registry import ToolRegistry

# Import availability flags
# Compatibility imports - now handled by centralized detection
Expand Down Expand Up @@ -299,13 +298,9 @@ def __init__(self, agent_file, framework, config_list, log_level=None, agent_cal
elif os.environ.get('LOGLEVEL'):
self.logger.setLevel(getattr(logging, os.environ.get('LOGLEVEL', 'INFO').upper(), logging.INFO))

# Keep tool registry for backward compatibility with autogen adapters
self.tool_registry = ToolRegistry()
self.tool_registry.register_builtin_autogen_adapters(_suppress_deprecation_warning=True)

# Initialize tool resolver with the registry wired in (single source of truth for tool resolution)
# Initialize tool resolver (single source of truth for tool resolution)
from .tool_resolver import ToolResolver
self.tool_resolver = ToolResolver(registry=self.tool_registry)
self.tool_resolver = ToolResolver()

# DI-friendly: tests/multi-tenant runtimes pass their own registry;
# CLI users get the process default.
Expand Down Expand Up @@ -472,57 +467,6 @@ def is_function_or_decorated(self, obj):
"""
return inspect.isfunction(obj) or hasattr(obj, '__call__')

def load_tools_from_module(self, module_path):
"""
Load function tools from a user-supplied module (gated by PRAISONAI_ALLOW_LOCAL_TOOLS).

Parameters:
module_path (str): The path to the module containing the tools.

Returns:
dict: A dictionary containing the names of the tools as keys and the corresponding functions or objects as values.
Returns an empty dict if the module cannot be loaded (path missing, loading blocked by PRAISONAI_ALLOW_LOCAL_TOOLS, or any other load error).
"""
from ._safe_loader import load_user_module
module = load_user_module(module_path, name="tools_module")
if module is None:
return {}
return {name: obj for name, obj in inspect.getmembers(module, self.is_function_or_decorated)}

def load_tools_from_module_class(self, module_path):
"""
Load BaseTool / langchain tool classes from a user-supplied module (gated by PRAISONAI_ALLOW_LOCAL_TOOLS).
"""
from ._safe_loader import load_user_module
module = load_user_module(module_path, name="tools_module")
if module is None:
return {}
return self.tool_resolver._extract_tool_classes(module)

def load_tools_from_package(self, package_path):
"""
Loads tools from a specified package path containing modules with functions or classes.

Parameters:
package_path (str): The path to the package containing the tools.

Returns:
dict: A dictionary containing the names of the tools as keys and the corresponding initialized instances of the classes as values.

Raises:
FileNotFoundError: If the specified package path does not exist.

This function iterates through all the .py files in the specified package path, excluding those that start with "__". For each file, it imports the corresponding module and checks if it contains any functions or classes that can be loaded as tools. The function then returns a dictionary containing the names of the tools as keys and the corresponding initialized instances of the classes as values.
"""
tools_dict = {}
for module_file in os.listdir(package_path):
if module_file.endswith('.py') and not module_file.startswith('__'):
module_name = f"{package_path.name}.{module_file[:-3]}" # Remove .py for import
module = importlib.import_module(module_name)
for name, obj in inspect.getmembers(module, self.is_function_or_decorated):
tools_dict[name] = obj
return tools_dict


def generate_crew_and_kickoff(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,4 @@ def tool_fn(**kwargs):
if not result_content:
result_content = "Task completed."

return f"### AG2 Output ###\n{result_content}"
return f"### AG2 Output ###\n{result_content}"
3 changes: 1 addition & 2 deletions src/praisonai/praisonai/framework_adapters/crewai_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,4 @@ def run(
except Exception as e: # noqa: BLE001 -- agentops errors must not crash the caller
logger.warning(f"agentops.end_session failed: {e}")

return result

return result
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,4 @@ def run(
from praisonai._async_bridge import run_sync
run_sync(interactive_runtime.stop())
except Exception as e:
logger.error(f"Error stopping InteractiveRuntime: {e}")

logger.error(f"Error stopping InteractiveRuntime: {e}")
75 changes: 0 additions & 75 deletions src/praisonai/praisonai/storage/__init__.py

This file was deleted.

Loading