Updated `Getting Started` page of `Prompt Templates` to showcase more
features provided by the class. Might need some proof reading because
apparently English is not my first language.
If you do not wish to specify `input_variables` manually, you can also create a `PromptTemplate` using `from_templates` class method. `langchain` will automatically infer the `input_variables` based on the `template` passed.
```python
template = "Tell me a {adjective} joke about {content}."
You can create custom prompt templates that format the prompt in any way you want. For more information, see [Custom Prompt Templates](examples/custom_prompt_template.ipynb).
You can create custom prompt templates that format the prompt in any way you want. For more information, see [Custom Prompt Templates](examples/custom_prompt_template.ipynb).
<!-- TODO(shreya): Add link to Jinja -->
<!-- TODO(shreya): Add link to Jinja -->
:::{note}
## Template formats
Currently, the template should be formatted as a Python f-string. We also support Jinja2 templates (see [Using Jinja templates](examples/custom_prompt_template.ipynb)). In the future, we will support more templating languages such as Mako.
:::
By default, `PromptTemplate` will treat the provided template as a Python f-string. You can specify other template format through `template_format` argument:
## Load a prompt template from LangChainHub
```python
# Make sure jinja2 is installed before running this
jinja2_template = "Tell me a {{ adjective }} joke about {{ content }}"
LangChainHub contains a collection of prompts which can be loaded directly via LangChain.
Currently, `PromptTemplate` only supports `jinja2` and `f-string` templating format. If there is any other templating format that you would like to use, feel free to open an issue in the [Github](https://github.com/hwchase17/langchain/issues) page.
## Validate template
By default, `PromptTemplate` will validate the `template` string by checking whether the `input_variables` match the variables defined in `template`. You can disable this behavior by setting `validate_template` to `False`
```python
template = "I am learning langchain because {reason}."
You can save your `PromptTemplate` into a file in your local filesystem. `langchain` will automatically infer the file format through the file extension name. Currently, `langchain` supports saving template to YAML and JSON file.
```python
prompt_template.save("awesome_prompt.json") # Save to JSON file
`langchain` also supports loading prompt template from LangChainHub, which contains a collection of useful prompts you can use in your project. You can read more about LangChainHub and the prompts available with it [here](https://github.com/hwchase17/langchain-hub).