stream
Module Contents
Classes
Agent is the basic unit of the system. It is responsible for |
|
Agent is the basic unit of the system. It is responsible for |
|
Asynchronous variant of the Agent class |
|
Asynchronous variant of the Agent class |
Functions
|
Attributes
- lagent.agents.stream.API_PREFIX = Multiline-String
Show Value
"""This is the subfunction for tool '{tool_name}', you can use this tool. The description of this function is: {description}"""
- lagent.agents.stream.META_CN = '当开启工具以及代码时,根据需求选择合适的工具进行调用'
- lagent.agents.stream.INTERPRETER_CN = '你现在已经能够在一个有状态的 Jupyter 笔记本环境中运行 Python 代码。当你向 python 发送含有 Python...
- lagent.agents.stream.PLUGIN_CN = Multiline-String
Show Value
"""你可以使用如下工具: {prompt} 如果你已经获得足够信息,请直接给出答案. 避免不必要的工具调用! 同时注意你可以使用的工具,不要随意捏造!"""
- lagent.agents.stream.get_plugin_prompt(actions, api_desc_template='{description}')
- class lagent.agents.stream.AgentForInternLM(llm, plugins=None, interpreter=None, template=None, memory=dict(type=Memory), output_format=dict(type=MixedToolParser, template=META_CN, parsers=[dict(type=PluginParser, template=PLUGIN_CN), dict(type=InterpreterParser, template=INTERPRETER_CN)]), aggregator=dict(type=InternLMToolAggregator), action_hooks=[dict(type=InternLMActionProcessor)], finish_condition=lambda m: ..., max_turn=4, **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.
plugins (Union[dict, List[dict]]) –
interpreter (dict) –
action_hooks (List) –
finish_condition (Callable[[lagent.schema.AgentMessage], bool]) –
max_turn (int) –
- 返回:
The response message.
- 返回类型:
- agent
- plugin_executor = None
- interpreter_executor = None
- finish_condition
- max_turn = 4
- forward(message, session_id=0, **kwargs)
- 参数:
message (lagent.schema.AgentMessage) –
- get_steps(session_id=0)
- class lagent.agents.stream.MathCoder(llm, interpreter=dict(type=IPythonInteractive, timeout=20, max_out_len=8192), template=None, memory=dict(type=Memory), output_format=dict(type=InterpreterParser, template="Integrate step-by-step reasoning and Python code to solve math problems using the following guidelines:\n- Analyze the question and write jupyter code to solve the problem;\n- Present the final result in LaTeX using a '\\boxed{{}}' without any units. \n"), aggregator=dict(type=InternLMToolAggregator), action_hooks=[dict(type=InternLMActionProcessor)], finish_condition=lambda m: ..., max_turn=6, **kwargs)
Bases:
AgentForInternLMAgent 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.
interpreter (dict) –
action_hooks (List) –
finish_condition (Callable[[lagent.schema.AgentMessage], bool]) –
max_turn (int) –
- 返回:
The response message.
- 返回类型:
- class lagent.agents.stream.AsyncAgentForInternLM(llm, plugins=None, interpreter=None, template=None, memory=dict(type=Memory), output_format=dict(type=MixedToolParser, template=META_CN, parsers=[dict(type=PluginParser, template=PLUGIN_CN), dict(type=InterpreterParser, template=INTERPRETER_CN)]), aggregator=dict(type=InternLMToolAggregator), action_hooks=[dict(type=InternLMActionProcessor)], finish_condition=lambda m: ..., max_turn=4, **kwargs)
Bases:
lagent.agents.agent.AsyncAgentAsynchronous variant of the Agent class
- 参数:
llm (Union[lagent.llms.BaseLLM, Dict]) –
plugins (Union[dict, List[dict]]) –
interpreter (dict) –
template (Union[str, dict, List[dict]]) –
memory (Dict) –
output_format (Dict) –
aggregator (Dict) –
action_hooks (List) –
finish_condition (Callable[[lagent.schema.AgentMessage], bool]) –
max_turn (int) –
- agent
- plugin_executor = None
- interpreter_executor = None
- finish_condition
- max_turn = 4
- async forward(message, session_id=0, **kwargs)
- 参数:
message (lagent.schema.AgentMessage) –
- get_steps(session_id=0)
- class lagent.agents.stream.AsyncMathCoder(llm, interpreter=dict(type=AsyncIPythonInterpreter), template=None, memory=dict(type=Memory), output_format=dict(type=InterpreterParser, template="Integrate step-by-step reasoning and Python code to solve math problems using the following guidelines:\n- Analyze the question and write jupyter code to solve the problem;\n- Present the final result in LaTeX using a '\\boxed{{}}' without any units. \n"), aggregator=dict(type=InternLMToolAggregator), action_hooks=[dict(type=InternLMActionProcessor)], finish_condition=lambda m: ..., max_turn=6, **kwargs)
Bases:
AsyncAgentForInternLMAsynchronous variant of the Agent class
- 参数:
llm (Union[lagent.llms.BaseLLM, Dict]) –
interpreter (dict) –
template (Union[str, dict, List[dict]]) –
memory (Dict) –
output_format (Dict) –
aggregator (Dict) –
action_hooks (List) –
finish_condition (Callable[[lagent.schema.AgentMessage], bool]) –
max_turn (int) –
- async forward(message, session_id=0, **kwargs)
- 参数:
message (lagent.schema.AgentMessage) –