parser
Module Contents
Classes
Base parser to process inputs and outputs of actions. |
|
Json parser to convert input string into a dictionary. |
|
Tuple parser to convert input string into a tuple. |
- exception lagent.actions.parser.ParseError(err_msg)
Bases:
ExceptionParsing exception class
- Parameters:
err_msg (str) –
- class lagent.actions.parser.BaseParser(action)
Base parser to process inputs and outputs of actions.
- Parameters:
action (
BaseAction) – action to validate
- PARAMETER_DESCRIPTION
declare the input format which LLMs should follow when generating arguments for decided tools.
- Type:
str
- PARAMETER_DESCRIPTION: str = ''
- parse_inputs(inputs, name='run')
parse inputs LLMs generate for the action
- Parameters:
inputs (
str) – input string extracted from responsesname (str) –
- Returns:
processed input
- Return type:
dict
- parse_outputs(outputs)
parser outputs returned by the action
- Parameters:
outputs (
Any) – raw output of the action- Returns:
- processed output of which each member is a
dictionary with two keys - ‘type’ and ‘content’.
- Return type:
List[dict]
- class lagent.actions.parser.JsonParser(action)
Bases:
BaseParserJson parser to convert input string into a dictionary.
- Parameters:
action (
BaseAction) – action to validate
- PARAMETER_DESCRIPTION = '如果调用该工具,你必须使用Json格式 {key: value} 传参,其中key为参数名称'
- parse_inputs(inputs, name='run')
parse inputs LLMs generate for the action
- Parameters:
inputs (
str) – input string extracted from responsesname (str) –
- Returns:
processed input
- Return type:
dict
- class lagent.actions.parser.TupleParser(action)
Bases:
BaseParserTuple parser to convert input string into a tuple.
- Parameters:
action (
BaseAction) – action to validate
- PARAMETER_DESCRIPTION = '如果调用该工具,你必须使用Tuple格式 (arg1, arg2, arg3) 传参,且参数是有序的'
- parse_inputs(inputs, name='run')
parse inputs LLMs generate for the action
- Parameters:
inputs (
str) – input string extracted from responsesname (str) –
- Returns:
processed input
- Return type:
dict