SocialAgent class

A Social Agent in OASIS is an LLM-based social media user, inherited from CAMEL’s ChatAgent. It can perform actions on social media (e.g., posting), use external tools (such as Google Search), and has features like user information and a memory module. When initializing a SocialAgent, you can configure the following core parameters:
ParameterTypeRequiredDefaultDescription
agent_idint-The unique ID of the agent, used as the primary key to distinguish different agents. Each SocialAgent must have a unique agent_id.
user_infoUserInfo-A dataclass containing the agent’s user registration info. For more details, see UserInfo.
user_info_templateTextPrompt NoneA text template that describes the agent when deciding what action to take. If None, a default prompt template will be selected based on recsys_type in UserInfo.
agent_graphAgentGraph -The AgentGraph instance that the SocialAgent belongs to.
modelBaseModelBackend or List[BaseModelBackend] or ModelManager or NoneNoneThe llm model(s) to be used for the agent’s actions. If None, the gpt-4o-mini model will be used.
available_actionslist[ActionType] or NoneNoneList of allowed actions in the social platform. For more details, see Actions Module. If None, all actions are enabled by default.
toolsList[Union[FunctionTool, Callable]] or NoneNoneExternal tools the agent can use, such as a get_weather function, a Toolkit, or an MCPToolkit from CAMEL. If set to None, the agent will not be able to use any external tools.
single_iterationboolTrueWhether the agent performs only a single round of reasoning when taking an LLM action. If False, the agent may continue acting based on the outcome of previous actions or tool calls.
interview_recordboolFalseWhether to record the interview prompt and result in the agent’s memory.
For more details on the model and the tools parameter, see Models Module and Toolkits Module.

UserInfo class

A dataclass containing the agent’s user registration info. Fields like user_name, name, and description must not be empty. The profile field is a dictionary whose keys must match those specified in user_info_template.
@dataclass
class UserInfo:
   user_name: str
   name: str
   description: str
   profile: dict[str, Any]  # If user_info_template is provided, the keys must match those in the template.
   recsys_type: RecsysType # Ignored if user_info_template is provided.
  • Example of a user_info_template and corresponding UserInfo.profile class:
from camel.prompts import TextPrompt

seller_template = TextPrompt('Your aim is: {aim} Your task is: {task}')

profile = {
    "aim": "Persuade people to buy `GlowPod` lamp.",
    "task": "Using roleplay to tell some story about the product.",
}

Default User Info Template

Twitter Style Template

def to_twitter_system_message(self) -> str:
    name_string = ""
    description_string = ""
    if self.name is not None:
        name_string = f"Your name is {self.name}."
    if self.profile is None:
        description = name_string
    elif "other_info" not in self.profile:
        description = name_string
    elif "user_profile" in self.profile["other_info"]:
        if self.profile["other_info"]["user_profile"] is not None:
            user_profile = self.profile["other_info"]["user_profile"]
            description_string = f"Your have profile: {user_profile}."
            description = f"{name_string}\n{description_string}"

    system_content = f"""
# OBJECTIVE
You're a Twitter user, and I'll present you with some posts. After you see the posts, choose some actions from the following functions.

# SELF-DESCRIPTION
Your actions should be consistent with your self-description and personality.
{description}

# RESPONSE METHOD
Please perform actions by tool calling.
"""
    return system_content

Reddit Style Template

def to_reddit_system_message(self) -> str:
    name_string = ""
    description_string = ""
    if self.name is not None:
        name_string = f"Your name is {self.name}."
    if self.profile is None:
        description = name_string
    elif "other_info" not in self.profile:
        description = name_string
    elif "user_profile" in self.profile["other_info"]:
        if self.profile["other_info"]["user_profile"] is not None:
            user_profile = self.profile["other_info"]["user_profile"]
            description_string = f"Your have profile: {user_profile}."
            description = f"{name_string}\n{description_string}"
            print(self.profile['other_info'])
            description += (
                f"You are a {self.profile['other_info']['gender']}, "
                f"{self.profile['other_info']['age']} years old, with an MBTI "
                f"personality type of {self.profile['other_info']['mbti']} from "
                f"{self.profile['other_info']['country']}.")

    system_content = f"""
# OBJECTIVE
You're a Reddit user, and I'll present you with some tweets. After you see the tweets, choose some actions from the following functions.

# SELF-DESCRIPTION
Your actions should be consistent with your self-description and personality.
{description}

# RESPONSE METHOD
Please perform actions by tool calling.
"""
    return system_content