agentsociety.agent.block

Module Contents

Classes

BlockParams

BlockOutput

Block

A foundational component similar to a layer in PyTorch, used for building complex systems.

Data

API

agentsociety.agent.block.TRIGGER_INTERVAL

1

agentsociety.agent.block.__all__

[‘Block’, ‘BlockParams’, ‘BlockOutput’]

class agentsociety.agent.block.BlockParams

Bases: pydantic.BaseModel

block_memory: Optional[dict[str, Any]]

None

class agentsociety.agent.block.BlockOutput

Bases: pydantic.BaseModel

class agentsociety.agent.block.Block(toolbox: agentsociety.agent.toolbox.AgentToolbox, agent_memory: Optional[agentsociety.memory.Memory] = None, block_params: Optional[Any] = None)

A foundational component similar to a layer in PyTorch, used for building complex systems.

Initialization

  • Description:

    • Initializes a new instance of the Block class with optional LLM, Memory, Simulator, and Trigger components.

  • Args:

    • name (str): The name of the block.

    • llm (Optional[LLM], optional): An instance of LLM. Defaults to None.

    • environment (Optional[Environment], optional): An instance of Environment. Defaults to None.

    • memory (Optional[Memory], optional): An instance of Memory. Defaults to None.

ParamsType

None

Context

None

OutputType

None

NeedAgent: bool

False

name: str = <Multiline-String>
description: str = <Multiline-String>
actions: dict[str, str]

None

classmethod default_params() ParamsType
classmethod default_context() Context
classmethod __init_subclass__(**kwargs)
set_agent(agent: Any)
property agent: Any
property toolbox: agentsociety.agent.toolbox.AgentToolbox
property llm: agentsociety.llm.LLM
property memory: agentsociety.memory.Memory
property agent_memory: agentsociety.memory.Memory
property block_memory: agentsociety.memory.KVMemory
property environment: agentsociety.environment.Environment
async before_forward()

Before forward - prepare context

async after_forward()

After forward - update/clean context

abstract async forward(agent_context: agentsociety.agent.context.DotDict)
  • Description:

    • Each block performs a specific reasoning task. This method should be overridden by subclasses.

    • Subclasses can define their own parameters as needed.

  • Args:

    • *args: Variable length argument list.

    • **kwargs: Arbitrary keyword arguments.

  • Raises:

    • NotImplementedError: Subclasses must implement this method.