Key Modules
Agent Graph
The Agent Graph saves all the social agents in the simulation. In this section, we will introduce how to create an AgentGraph
and some useful methods within it.
Two ways to create an AgentGraph
:
- Option 1: Create an
AgentGraph
from acsv
orjson
file, which contains the agent profiles. - Option 2: Create an empty
AgentGraph
and add each customized agent.
Option 1: Create an AgentGraph
from the agent profile files
We support initializing the AgentGraph using a file that stores agent profiles. In addition, you need to specify the LLM model used by all agents and the set of available social actions.
The parameters for these two functions are as follows:
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
profile_path | str | ✔ | - | Path to a CSV or JSON file storing agent profiles. For details on different profile formats, see Agent Profile section. |
model | BaseModelBackend or List[BaseModelBackend] or ModelManager | ✗ | gpt-4o-mini | The large language model(s) used by the all agents. |
available_actions | list[ActionType] | ✗ | None | List of allowed actions in the social platform for all agents. For more details, see Actions - OASIS. If set to None , all actions are enabled by default. |
Example of initializing an AgentGraph
from a profile file
- Twitter user profile style
- Reddit user profile style
Option 2: Create an empty AgentGraph
and customize each agent
Step 1: Create an empty AgentGraph
Step 2: Add each customized agent to the AgentGraph
You can initialize some social agents and add them to the AgentGraph
.
For more details on how to customize the SocialAgent
class, see Social Agent Module.
Other Methods of AgentGraph
1. agent_graph.get_agent(agent_id)
- Description: Get an
SocialAgent
byagent_id
. - Parameters:
agent_id
: Theagent_id
of theSocialAgent
to get.
- Returns:
SocialAgent
: TheSocialAgent
with the givenagent_id
.
- Example:
2. agent_graph.get_all_agents()
- Description: Get all
SocialAgent
in theAgentGraph
. - Parameters:
- None
- Returns:
- list[tuple[int, SocialAgent]]: A list of tuples, each containing an
agent_id
and the correspondingSocialAgent
.
- list[tuple[int, SocialAgent]]: A list of tuples, each containing an
- Example:
3. agent_graph.get_num_nodes()
- Description: Get the number of
SocialAgent
in theAgentGraph
. - Parameters:
- None
- Returns:
- int: The number of
SocialAgent
in theAgentGraph
.
- int: The number of
- Example: