diff --git a/swarms/structs/__init__.py b/swarms/structs/__init__.py index 330d5edd..ea5da7a1 100644 --- a/swarms/structs/__init__.py +++ b/swarms/structs/__init__.py @@ -28,6 +28,8 @@ from swarms.structs.utils import ( parse_tasks, detect_markdown, ) +from swarms.structs.task import Task +from swarms.structs.block_wrapper import block __all__ = [ "Agent", @@ -66,5 +68,10 @@ __all__ = [ ======= "BaseStructure", "detect_markdown", +<<<<<<< HEAD >>>>>>> 1df42a3 ([BUGFIX][Conversation] [swarm.tools]) +======= + "Task", + "block" +>>>>>>> 8e1a024 ([FEATS] [BlockList] [BlockDict] [block]) ] diff --git a/swarms/structs/block_wrapper.py b/swarms/structs/block_wrapper.py index a6811b8f..7b16d757 100644 --- a/swarms/structs/block_wrapper.py +++ b/swarms/structs/block_wrapper.py @@ -1,6 +1,5 @@ +from typing import Callable, Any import logging -from functools import wraps -from typing import Any, Callable logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @@ -20,8 +19,6 @@ def block( Returns: Callable[..., Any]: The transformed function. """ - - @wraps(function) def wrapper(*args, **kwargs): # Here you can add code to execute the function on various hardwares # For now, we'll just call the function normally diff --git a/swarms/structs/blockslist.py b/swarms/structs/blockslist.py index b2a4db08..93ab0afa 100644 --- a/swarms/structs/blockslist.py +++ b/swarms/structs/blockslist.py @@ -36,15 +36,6 @@ class BlocksList(BaseStructure): get_by_parent_name(parent_name: str): Get blocks by parent name. get_by_parent_type(parent_type: str): Get blocks by parent type. get_by_parent_description(parent_description: str): Get blocks by parent description. - - - Examples: - >>> from swarms.structs.block import Block - >>> from swarms.structs.blockslist import BlocksList - >>> block = Block("block", "A block") - >>> blockslist = BlocksList("blockslist", "A list of blocks", [block]) - >>> blockslist - """ def __init__( @@ -56,10 +47,8 @@ class BlocksList(BaseStructure): **kwargs, ): super().__init__(name=name, description=description, **kwargs) - self.name = name - self.description = description - self.blocks = blocks self.parent = parent + self.blocks = blocks def add(self, block: Any): self.blocks.append(block) @@ -76,26 +65,6 @@ class BlocksList(BaseStructure): def get_all(self): return self.blocks - def run_block(self, block: Any, task: str, *args, **kwargs): - """Run the block for the specified task. - - Args: - task (str): The task to be performed by the block. - *args: Variable length argument list. - **kwargs: Arbitrary keyword arguments. - - Returns: - The output of the block. - - Raises: - Exception: If an error occurs during the execution of the block. - """ - try: - return block.run(task, *args, **kwargs) - except Exception as error: - print(f"[Error] [Block] {error}") - raise error - def get_by_name(self, name: str): return [block for block in self.blocks if block.name == name]