Are you sure you want to delete this access key?
This example demonstrates how to leverage promptfoo's powerful extensions API to implement custom setup and teardown hooks for individual tests. These extensions can be defined in either Python or JavaScript, providing flexibility for your preferred programming environment.
promptfoo supports four types of extension hooks, each triggered at a specific point in the evaluation lifecycle:
beforeAll
: Executed once before the entire test suite beginsafterAll
: Executed once after the entire test suite completesbeforeEach
: Executed before each individual testafterEach
: Executed after each individual testEach hook receives a hookName
parameter and a context
object containing relevant data for that specific hook type.
For comprehensive information on implementing and using these hooks, refer to the Extension Hooks section in the official documentation.
Specify your extensions in the promptfooconfig.yaml
file:
extensions:
- file://path/to/your/extension.py:extension_hook
- file://path/to/your/extension.js:extensionHook
Note: You must include the function name after the file path, separated by a colon (:
).
Extensions in promptfoo empower you to:
These extensions function similarly to "before" and "after" hooks in popular unit testing frameworks, allowing you to set up and tear down test environments with precision and control.
To execute this example, use the following command in your terminal:
LOG_LEVEL=debug promptfoo eval
Then
promptfoo view
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?