$git clone https://github.com/masci/banksBanks) is the linguist professor who will help you generate meaningful LLM prompts using a template language that makes sense. If you're still using f-strings for the job, keep reading.
| 1 | # banks |
| 2 | |
| 3 | [](https://pypi.org/project/banks) |
| 4 | [](https://pypi.org/project/banks) |
| 5 | [](https://coveralls.io/github/masci/banks?branch=main) |
| 6 | |
| 7 | [](https://github.com/masci/banks/actions/workflows/release.yml) |
| 8 | [](https://github.com/masci/banks/actions/workflows/test.yml) |
| 9 | [](https://github.com/masci/banks/actions/workflows/docs.yml) |
| 10 | |
| 11 | [](https://github.com/pypa/hatch) |
| 12 | [](https://github.com/astral-sh/ruff) |
| 13 | [](https://mypy-lang.org/) |
| 14 | [](https://spdx.org/licenses/) |
| 15 | |
| 16 | [Banks](https://en.wikipedia.org/wiki/Arrival_(film)) is the linguist professor who will help you generate meaningful |
| 17 | LLM prompts using a template language that makes sense. If you're still using `f-strings` for the job, keep reading. |
| 18 | |
| 19 | Docs are available [here](https://masci.github.io/banks/). |
| 20 | |
| 21 |  |
| 22 | |
| 23 | ----- |
| 24 | |
| 25 | **Table of Contents** |
| 26 | |
| 27 | - [banks](#banks) |
| 28 | - [Installation](#installation) |
| 29 | - [Features](#features) |
| 30 | - [Cookbook](#cookbook) |
| 31 | - [Examples](#examples) |
| 32 | - [:point\_right: Render a prompt template as chat messages](#point_right-render-a-prompt-template-as-chat-messages) |
| 33 | - [:point\_right: Add images to the prompt for vision models](#point_right-add-images-to-the-prompt-for-vision-models) |
| 34 | - [:point\_right: Use a LLM to generate a text while rendering a prompt](#point_right-use-a-llm-to-generate-a-text-while-rendering-a-prompt) |
| 35 | - [:point\_right: Function calling directly from the prompt](#point_right-function-calling-directly-from-the-prompt) |
| 36 | - [:point\_right: Use prompt caching from Anthropic](#point_right-use-prompt-caching-from-anthropic) |
| 37 | - [Reuse templates from registries](#reuse-templates-from-registries) |
| 38 | - [Async support](#async-support) |
| 39 | - [Contributing](#contributing) |
| 40 | - [License](#license) |
| 41 | |
| 42 | ## Installation |
| 43 | |
| 44 | ```console |
| 45 | pip install banks |
| 46 | |
| 47 | # install optional deps; litellm, redis |
| 48 | pip install "banks[all]" |
| 49 | ``` |
| 50 | |
| 51 | ## Features |
| 52 | |
| 53 | Prompts are instrumental for the success of any LLM application, and Banks focuses around specific areas of their |
| 54 | lifecycle: |
| 55 | - :orange_book: **Templating**: Banks provides tools and functions to build prompts text and chat messages from generic blueprints. |
| 56 | - :tickets: **Versioning and metadata**: Banks supports attaching metadata to prompts to ease their management, and versioning is |
| 57 | first-class citizen. |
| 58 | - :file_cabinet: **Management**: Banks provides ways to store prompts on disk along with their metadata. |
| 59 | |
| 60 | ## Cookbook |
| 61 | |
| 62 | - :blue_book: [In-prompt chat completion](./cookbook/in_prompt_completion.ipynb) |
| 63 | - :blue_book: [Prompt caching with Anthropic](./cookbook/Prompt_Caching_with_Anthropic.ipynb) |
| 64 | - :blue_book: [Prompt versioning](./cookbook/Prompt_Versioning.ipynb) |
| 65 | |
| 66 | ## Examples |
| 67 | |
| 68 | For a more extensive set of code examples, [see the documentation page](https://masci.github.io/banks/examples/). |
| 69 | |
| 70 | ### :point_right: Render a prompt template as chat messages |
| 71 | |
| 72 | You'll find yourself feeding an LLM a list of chat messages instead of plain text |
| 73 | more often than not. Banks will help you remove the boilerplate by defining the |
| 74 | messages already at the prompt level. |
| 75 | |
| 76 | ```py |
| 77 | from banks import Prompt |
| 78 | |
| 79 | |
| 80 | prompt_template = """ |
| 81 | {% chat role="system" %} |
| 82 | You are a {{ persona }}. |
| 83 | {% endchat %} |
| 84 | |
| 85 | {% chat role="user" %} |
| 86 | Hello, how are you? |
| 87 | {% endchat %} |
| 88 | """ |
| 89 | |
| 90 | p = |