prompt_template
Module Contents
Classes
prompt templates. |
- class lagent.prompts.prompt_template.PromptTemplate(template, format_type='json')
prompt templates.
- 参数:
template (str) – The template string.
variables (Optional[Union[Dict[str, str], BaseModel, Any]]) – Variables for the template.
format_type (str) – The format type of the template (‘json’ or ‘jinja’).
- template
- format_type = 'json'
- parse_template(template)
Extract variables from the template.
- 参数:
template (str) – The template string.
- 返回:
A dictionary of variables with None values.
- 返回类型:
Dict[str, str]
- format_json(template, variables)
Format the JSON template.
- 参数:
template (str) – The JSON template string.
variables (Dict[str, str]) – The variables to fill in the template.
- 返回:
The formatted JSON string.
- 返回类型:
str
- 抛出:
ValueError – If the template is not a valid JSON.
- format_jinja(template, variables)
Format the Jinja template.
- 参数:
template (str) – The Jinja template string.
variables (Dict[str, str]) – The variables to fill in the template.
- 返回:
The formatted Jinja string.
- 返回类型:
str
- 抛出:
ValueError – If the template is not a valid Jinja template.
- format(**kwargs)
- 参数:
kwargs (Optional[Union[Dict[str, str], pydantic.BaseModel, Any]]) –
- 返回类型:
Any
- property actions_info: Dict[str, Any] | None
Get the action information.
- 返回类型:
Optional[Dict[str, Any]]
- property agents_info: Dict[str, Any] | None
Get the agent information.
- 返回类型:
Optional[Dict[str, Any]]