agentsociety.cityagent.blocks.social_block¶
Module Contents¶
Classes¶
Manages the creation of message prompts by dynamically formatting templates with agent-specific data. |
|
NoneBlock |
|
Block for selecting an appropriate agent to socialize with based on relationship strength and context. |
|
Generate and send messages |
|
Orchestrates social interactions by dispatching to appropriate sub-blocks. |
API¶
- class agentsociety.cityagent.blocks.social_block.MessagePromptManager¶
Manages the creation of message prompts by dynamically formatting templates with agent-specific data.
Initialization
- async get_prompt(memory, step: dict[str, Any], environment_info: str, target: int, template: str)¶
Generates a formatted prompt for message creation.
Args: memory: Agent’s memory to retrieve status data. step: Current workflow step containing intention and context. target: ID of the target agent for communication. template: Raw template string to be formatted.
Returns: Formatted prompt string with placeholders replaced by agent-specific data.
- class agentsociety.cityagent.blocks.social_block.SocialNoneBlock(toolbox: agentsociety.agent.AgentToolbox, agent_memory: agentsociety.memory.Memory)¶
Bases:
agentsociety.agent.BlockNoneBlock
Initialization
- name¶
‘SocialNoneBlock’
- description¶
‘Handle all other cases if you are not trying to determine the social target or send a message to som…’
- async forward(context)¶
Executes default behavior when no specific block matches the intention.
Args: step: Current workflow step with ‘intention’ and other metadata. context: Additional execution context (e.g., agent’s plan).
Returns: A result dictionary indicating success/failure, time consumed, and execution details.
- class agentsociety.cityagent.blocks.social_block.FindPersonBlock(toolbox: agentsociety.agent.AgentToolbox, agent_memory: agentsociety.memory.Memory)¶
Bases:
agentsociety.agent.BlockBlock for selecting an appropriate agent to socialize with based on relationship strength and context.
Initialization
- name¶
‘FindPersonBlock’
- description¶
‘Find a suitable person to socialize with’
- async forward(context: agentsociety.agent.DotDict)¶
Identifies a target agent and interaction mode (online/offline).
Args: context: Additional execution context (may store selected target).
Returns: Result dict with target agent, interaction mode, and execution status.
- class agentsociety.cityagent.blocks.social_block.MessageBlock(toolbox: agentsociety.agent.AgentToolbox, agent_memory: agentsociety.memory.Memory)¶
Bases:
agentsociety.agent.BlockGenerate and send messages
Initialization
- name¶
‘MessageBlock’
- description¶
‘Send social message to someone (including online and offline, phone call, social post, etc.)’
- async forward(context: agentsociety.agent.DotDict)¶
Generates a message, sends it to the target, and updates chat history.
Args: context: Execution context (may contain pre-selected target).
Returns: Result dict with message content, target, and execution status.
- class agentsociety.cityagent.blocks.social_block.SocialBlockParams¶
Bases:
agentsociety.agent.BlockParams
- class agentsociety.cityagent.blocks.social_block.SocialBlockContext¶
Bases:
agentsociety.agent.BlockContext
- class agentsociety.cityagent.blocks.social_block.SocialBlock(toolbox: agentsociety.agent.AgentToolbox, agent_memory: agentsociety.memory.Memory, block_params: Optional[agentsociety.cityagent.blocks.social_block.SocialBlockParams] = None)¶
Bases:
agentsociety.agent.BlockOrchestrates social interactions by dispatching to appropriate sub-blocks.
Initialization
- ParamsType¶
None
- OutputType¶
None
- ContextType¶
None
- NeedAgent¶
True
- name¶
‘SocialBlock’
- description¶
‘Do social interactions, for example, find a friend, send a message, and other social activities.’
- actions¶
None
- async forward(agent_context: agentsociety.agent.DotDict) agentsociety.cityagent.sharing_params.SocietyAgentBlockOutput¶
Main entry point for social interactions. Dispatches to sub-blocks based on context.
Args: step: Workflow step containing intention and metadata. context: Additional execution context.
Returns: Result dict from the executed sub-block.