You can find a complete runnable example of this guide on GitHub.
Split your configuration into multiple files
As your project grows in complexity, it might be a good idea to split your configuration into multiple files. This makes it easier to manage and maintain your configuration. For example, you can create separate TOML files for different projects, environments, and so on. You can also move deprecated entries like functions to a separate file. You can instruct TensorZero to load multiple configuration files by specifying a glob pattern that matches all the relevant TOML files:- TensorZero Gateway: Set the CLI flag
--config-path path/to/**/*.toml
. - TensorZero UI: Set the environment variable
TENSORZERO_UI_CONFIG_PATH=path/to/**/*.toml
.
Enable template file system access to reuse shared snippets
You can decompose your templates into smaller, reusable snippets. This makes it easier to maintain and reuse code across multiple templates. Templates can reference other templates using the MiniJinja directives{% include %}
and {% import %}
.
To use these directives, you need to enable template file system access with gateway.template_filesystem_access
in your configuration file.
By default, file system access is disabled for security reasons, since template imports are evaluated dynamically and could potentially access sensitive files.
You should ensure that only trusted templates are allowed access to the file system.
base_path
itself is relative, it’ll be relative to the configuration file in which it’s defined.