Langchain文档 模板格式

273 阅读1分钟

模板格式

默认情况下,PromptTemplate将把提供的模板视为Python f-string。您可以通过template_format参数指定其他模板格式:

# Make sure jinja2 is installed before running this

jinja2_template = "Tell me a {{ adjective }} joke about {{ content }}"
prompt_template = PromptTemplate.from_template(template=jinja2_template, template_format="jinja2")

prompt_template.format(adjective="funny", content="chickens")
# -> Tell me a funny joke about chickens.

目前,PromptTemplate仅支持jinja2和f-string模板格式。如果您想使用任何其他模板格式,请随时在Github页面上打开问题。