Skip to content

Commit

Permalink
reorganize docs
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Apr 13, 2024
1 parent d4f0565 commit c557a2d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 31 deletions.
6 changes: 0 additions & 6 deletions docs/extensions.md

This file was deleted.

22 changes: 0 additions & 22 deletions docs/filters.md

This file was deleted.

36 changes: 36 additions & 0 deletions docs/macros.md → docs/prompt.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 1 addition & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c557a2d

Please sign in to comment.