agentscope.agents.dialog_agent module
A general dialog agent.
- class agentscope.agents.dialog_agent.DialogAgent(*args: tuple, **kwargs: dict)[source]
Bases:
AgentBase
A simple agent used to perform a dialogue. Your can set its role by sys_prompt.
- __init__(name: str, sys_prompt: str, model_config_name: str, use_memory: bool = True, **kwargs: Any) None [source]
Initialize the dialog agent.
- Parameters:
name (str) – The name of the agent.
sys_prompt (Optional[str]) – The system prompt of the agent, which can be passed by args or hard-coded in the agent.
model_config_name (str) – The name of the model config, which is used to load model from configuration.
use_memory (bool, defaults to True) – Whether the agent has memory.
- reply(x: Sequence[Msg] | Msg | None = None) Msg [source]
Reply function of the agent. Processes the input data, generates a prompt using the current dialogue memory and system prompt, and invokes the language model to produce a response. The response is then formatted and added to the dialogue memory.
- Parameters:
x (Optional[Union[Msg, Sequence[Msg]]], defaults to None) – The input message(s) to the agent, which also can be omitted if the agent doesn’t need any input.
- Returns:
The output message generated by the agent.
- Return type:
Msg