Skip to content

Commit

Permalink
config docs
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Jun 2, 2024
1 parent fea547f commit 82a524e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
37 changes: 37 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Configuration

Banks can smoothly run with defaults, but you can configure the library by changing the `config` object or by
setting the correspondent environment variables.

Example usage:

```python
from banks import config


config.ASYNC_ENABLED = True
```


### ASYNC_ENABLED

| | |
| -------------- | ----------------------- |
| Type: | `bool` or truthy string |
| Default value: | `False` |
| Env var: | `BANKS_ASYNC_ENABLED` |

Whether or not to use `asyncio` for template rendering and LLM generation. This setting won't speed up your
application, only set it to `True` if you need to integrate Banks into an async codebase.


### USER_DATA_PATH

| | |
| -------------- | ---------------------- |
| Type: | `Path` or path string |
| Default value: | depending on OS |
| Env var: | `BANKS_USER_DATA_PATH` |

A user-writable folder where Banks will store its data. Banks uses a meaningful default for your operating system, so
change it only if you have to.
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ are replaced by actual data provided by the user.
* [Filters](prompt.md#filters): useful to manipulate the text during template rendering.
* [Extensions](prompt.md#extensions): useful to support custom functions (e.g. text generation via OpenAI).
* [Macros](prompt.md#macros): useful to implement complex logic in the template itself instead of Python code.
* [Configuration](config.md): how to configure the library.

## Installation

Expand Down
5 changes: 3 additions & 2 deletions src/banks/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import os
from pathlib import Path

from platformdirs import user_data_path

from .utils import strtobool


class BanksConfig:
ASYNC_ENABLED = strtobool(os.environ.get("BANKS_ASYNC_ENABLED", "false"))
USER_DATA_PATH = user_data_path(os.environ.get("BANKS_USER_DATA_PATH", "banks"))
ASYNC_ENABLED: bool = strtobool(os.environ.get("BANKS_ASYNC_ENABLED", "false"))
USER_DATA_PATH: Path = Path(os.environ.get("BANKS_USER_DATA_PATH", "")) or user_data_path("banks")


config = BanksConfig()

0 comments on commit 82a524e

Please sign in to comment.