agentscope.agents.dialog_agent module
A general dialog agent.
- class agentscope.agents.dialog_agent.DialogAgent(*args: tuple, **kwargs: dict)[源代码]
基类:
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 [源代码]
Initialize the dialog agent.
- 参数:
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 [源代码]
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.
- 参数:
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.
- 返回:
The output message generated by the agent.
- 返回类型:
Msg