From c557a2d701982207d1c8400ceae67b4837b650a6 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Sat, 13 Apr 2024 17:07:17 +0200 Subject: [PATCH] reorganize docs --- docs/extensions.md | 6 ------ docs/filters.md | 22 --------------------- docs/{macros.md => prompt.md} | 36 +++++++++++++++++++++++++++++++++++ mkdocs.yml | 4 +--- 4 files changed, 37 insertions(+), 31 deletions(-) delete mode 100644 docs/extensions.md delete mode 100644 docs/filters.md rename docs/{macros.md => prompt.md} (51%) diff --git a/docs/extensions.md b/docs/extensions.md deleted file mode 100644 index d479fe0..0000000 --- a/docs/extensions.md +++ /dev/null @@ -1,6 +0,0 @@ -Extensions are custom functions that can be used to add new tags to the template engine. -Banks supports the following ones, specific for prompt engineering. - -::: banks.extensions.generate - options: - show_root_heading: false \ No newline at end of file diff --git a/docs/filters.md b/docs/filters.md deleted file mode 100644 index f592566..0000000 --- a/docs/filters.md +++ /dev/null @@ -1,22 +0,0 @@ -Filters are Python functions that are called during the rendering of a certain tag. For example, if a prompt template -contains the tag: - -```jinja -{{ 'hello' | upper }} -``` - -a Python function named `upper` (in this case provided by Jinja) will be called passing the string 'hello' as a -parameter, and its return value will replace the tag in the final text: - -```python -from banks import Prompt - -p = Prompt("{{ 'hello' | upper }}") -p.text() ## outputs 'HELLO' -``` - -In addition to all the [builtin filters](https://jinja.palletsprojects.com/en/3.1.x/templates/#list-of-builtin-filters) -provided by Jinja, Banks supports the following ones, specific for prompt engineering. - - -::: banks.filters.lemmatize.lemmatize diff --git a/docs/macros.md b/docs/prompt.md similarity index 51% rename from docs/macros.md rename to docs/prompt.md index 0f816ab..466b262 100644 --- a/docs/macros.md +++ b/docs/prompt.md @@ -1,3 +1,39 @@ +## Filters + +Filters are Python functions that are called during the rendering of a certain tag. For example, if a prompt template +contains the tag: + +```jinja +{{ 'hello' | upper }} +``` + +a Python function named `upper` (in this case provided by Jinja) will be called passing the string 'hello' as a +parameter, and its return value will replace the tag in the final text: + +```python +from banks import Prompt + +p = Prompt("{{ 'hello' | upper }}") +p.text() ## outputs 'HELLO' +``` + +In addition to all the [builtin filters](https://jinja.palletsprojects.com/en/3.1.x/templates/#list-of-builtin-filters) +provided by Jinja, Banks supports the following ones, specific for prompt engineering. + + +::: banks.filters.lemmatize.lemmatize + +## Extensions + +Extensions are custom functions that can be used to add new tags to the template engine. +Banks supports the following ones, specific for prompt engineering. + +::: banks.extensions.generate + options: + show_root_heading: false + +## Macros + Macros are a way to implement complex logic in the template itself, think about defining functions but using Jinja code instead of Python. Banks provides a set of macros out of the box that are useful in prompt engineering, for example to generate a prompt and call OpenAI on-the-fly, during the template rendering. diff --git a/mkdocs.yml b/mkdocs.yml index 6d2d7a8..6367e62 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,10 +8,8 @@ theme: nav: - Home: 'index.md' - - filters.md - - extensions.md - - macros.md - Python API: 'python.md' + - Prompt API: 'prompt.md' plugins: - search