react
Module Contents
Classes
Agent is the basic unit of the system. It is responsible for |
|
Asynchronous variant of the Agent class |
|
Attributes
- lagent.agents.react.select_action_template = Multiline-String
Show Value
"""你是一个可以调用外部工具的助手,可以使用的工具包括: {action_info} {output_format} 开始!"""
- lagent.agents.react.output_format_template = Multiline-String
Show Value
"""如果使用工具请遵循以下格式回复: {function_format} 如果你已经知道了答案,或者你不需要工具,请遵循以下格式回复 {finish_format}"""
- class lagent.agents.react.ReAct(llm, actions, template=None, memory=dict(type=Memory), output_format=dict(type=JSONParser), aggregator=dict(type=DefaultAggregator), hooks=[dict(type=ActionPreprocessor)], finish_condition=lambda m: ..., max_turn=5, **kwargs)
Bases:
lagent.agents.agent.AgentAgent is the basic unit of the system. It is responsible for communicating with the LLM, managing the memory, and handling the message aggregation and parsing. It can also be extended with hooks
- 参数:
llm (Union[BaseLLM, Dict]) – The language model used by the agent.
template (Union[PromptTemplate, str]) – The template used to format the messages.
memory (Dict) – The memory used by the agent.
output_format (Dict) – The output format used by the agent.
aggregator (Dict) – The aggregator used by the agent.
name (Optional[str]) – The name of the agent.
description (Optional[str]) – The description of the agent.
hooks (Optional[Union[List[Dict], Dict]]) – The hooks used by the agent.
actions (Union[lagent.actions.BaseAction, List[lagent.actions.BaseAction]]) –
finish_condition (Callable[[lagent.schema.AgentMessage], bool]) –
max_turn (int) –
- 返回:
The response message.
- 返回类型:
- max_turn = 5
- finish_condition
- actions
- select_agent
- forward(message, session_id=0, **kwargs)
- 参数:
message (lagent.schema.AgentMessage) –
- 返回类型:
- class lagent.agents.react.AsyncReAct(llm, actions, template=None, memory=dict(type=Memory), output_format=dict(type=JSONParser), aggregator=dict(type=DefaultAggregator), hooks=[dict(type=ActionPreprocessor)], finish_condition=lambda m: ..., max_turn=5, **kwargs)
Bases:
lagent.agents.agent.AsyncAgentAsynchronous variant of the Agent class
- 参数:
llm (Union[lagent.llms.BaseLLM, Dict]) –
actions (Union[lagent.actions.BaseAction, List[lagent.actions.BaseAction]]) –
template (Union[lagent.prompts.prompt_template.PromptTemplate, str]) –
memory (Dict) –
output_format (Dict) –
aggregator (Dict) –
hooks (List) –
finish_condition (Callable[[lagent.schema.AgentMessage], bool]) –
max_turn (int) –
- max_turn = 5
- finish_condition
- actions
- select_agent
- async forward(message, session_id=0, **kwargs)
- 参数:
message (lagent.schema.AgentMessage) –
- 返回类型: