{"id":1944,"library":"banks","title":"banks","description":"Banks (version 2.4.1) is a Python library designed as a prompt programming language for Large Language Models (LLMs). It simplifies the creation, templating, versioning, and management of LLM prompts, offering an intuitive alternative to f-strings for complex prompt engineering. The library maintains an active and frequent release cadence, continuously adding features and improvements.","status":"active","version":"2.4.1","language":"en","source_language":"en","source_url":"https://github.com/masci/banks","tags":["prompt engineering","LLM","AI","language model","templating","chatbots"],"install":[{"cmd":"pip install banks","lang":"bash","label":"Core library"},{"cmd":"pip install \"banks[all]\"","lang":"bash","label":"With optional dependencies (litellm, redis)"}],"dependencies":[{"reason":"Required for internal path management, added in v2.1.1. [cite: `v2.1.1` changelog]","package":"platformdirs"},{"reason":"Optional dependency for LLM-generated text within prompts and other LLM integrations.","package":"litellm","optional":true},{"reason":"Optional dependency for prompt caching mechanisms.","package":"redis","optional":true}],"imports":[{"symbol":"Prompt","correct":"from banks import Prompt"},{"note":"Used for loading templates from the filesystem.","symbol":"DirectoryTemplateRegistry","correct":"from banks.registries import DirectoryTemplateRegistry"}],"quickstart":{"code":"from banks import Prompt\n\n# Define a prompt template using Banks' templating language\nprompt_template = \"\"\"\n{% chat role=\"system\" %}\nYou are a {{ persona }}.\n{% endchat %}\n\n{% chat role=\"user\" %}\nHello {{ name }}!\n{% endchat %}\n\"\"\"\n\n# Create a Prompt object\np = Prompt(prompt_template)\n\n# Render the prompt with context to generate chat messages\nchat_messages = p.chat_messages({\"persona\": \"friendly assistant\", \"name\": \"Alice\"})\n\n# Print the generated chat messages (e.g., for use with an LLM client)\nprint(chat_messages)\n\n# Expected output:\n# [{'role': 'system', 'content': 'You are a friendly assistant.'},\n#  {'role': 'user', 'content': 'Hello Alice!'}]","lang":"python","description":"This example demonstrates how to define a multi-turn chat prompt using Banks' templating syntax and then render it into a list of chat messages suitable for Large Language Model (LLM) APIs."},"warnings":[{"fix":"Upgrade to Banks v2.4.1 or later if using Python 3.9. Consider using Python 3.10+ for broader compatibility.","message":"Python 3.9 compatibility was temporarily removed in v2.3.0 (stopping testing) but re-added in v2.4.1. Users on Python 3.9 should ensure they are using Banks v2.4.1 or newer to avoid compatibility issues.","severity":"gotcha","affected_versions":">=2.3.0, <2.4.1"},{"fix":"Modify your installation command to `pip install \"banks[all]\"` or install specific extras like `\"banks[litellm]\"` if only certain optional features are needed.","message":"In v1.8.0, `litellm` and `redis` transitioned from direct requirements to optional dependencies. If your application relies on features that use these libraries (e.g., LLM text generation within prompts or caching), you must install Banks with the `[all]` extra (e.g., `pip install \"banks[all]\"`).","severity":"breaking","affected_versions":">=1.8.0"},{"fix":"Set `os.environ['BANKS_ASYNC_ENABLED'] = 'true'` before initializing your application, and ensure you are importing and using `AsyncPrompt` where async functionality is desired.","message":"For asynchronous operations, the environment variable `BANKS_ASYNC_ENABLED` must be set to `true`, and you should use the `AsyncPrompt` class instead of `Prompt`. Failure to set the environment variable will result in synchronous behavior even with `AsyncPrompt`.","severity":"gotcha","affected_versions":"All versions with async support"},{"fix":"Review the Banks v2.0.0 changelog and your project's dependency resolution. It might be necessary to recreate virtual environments or manually update/pin specific dependency versions.","message":"Version 2.0.0 introduced breaking changes specifically related to dependencies, noted as `[breaking] fix deps again`. Users upgrading from versions prior to 2.0.0 may encounter issues with their dependency tree.","severity":"breaking","affected_versions":"2.0.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}