Overview
In the SDK, every construct is generally represented as a Python object (constructed with Pydantic). To create a test suite, you can first create aSuite object, then call create().
Basic Test Suite Creation
Here’s a simple example of creating a test suite:Tests with Files
Our system also supports testing files as input. For example, you may want to test a model’s ability to answer questions about a contract, or extract information from an image. To add files to a test, you can do the following:Adding Context
We also support adding arbitrary information to the input of each test, in addition to the input and the files. For example, you may want to provide a chat history to the model, provide information about the user who asked the question, specify where in an application the question was asked, etc. You can provide this with thecontext parameter of the Test:
NOTE: Context field values can be either raw strings or JSON objects. If it is a JSON object, it will be parsed correctly and pretty-printed in the UI.
Adding Tags
You can also add tags to a test. These tags are searchable in the test suite and run result, and you can see a performance breakdown by tag.Adding Global Checks
If you want certain checks to be run on every test, you can add them to the suite with theglobal_checks parameter. For example, this is how you would check the grammar of every test by default.
Advanced Check Modifiers
Each check has a set of modifiers that can be used to change its behavior:- severity: Allows you to weight some checks higher than others
- examples: Allows you to provide in-context examples of outputs that should pass or fail
- extractor: Allows you to extract items from the output before the check is evaluated
- conditional: Allows you to only run the check if another check evaluates to true
- category: Allows you to override the default category of the check (correctness, formatting, etc.). This is also similar to tags, but allows you to do it on a more granular level.
Downloading / Pulling a Test Suite
If a test suite is already in the platform, you can pull it locally to edit or save it. Just copy the suite ID from the test suite page (or from the last portion of the test suite URL). Then callSuite.from_id:
Updating a Test Suite
You can also update the test suite that you have locally. For example, let’s say you want to change the global checks of a suite. You can do this as follows:Loading a Test Suite from a File
Although it’s preferred to create a Test Suite with python objects, the test suite can also be loaded from a local JSON file. To create a test suite suite from a file, you can use theSuite.from_file() function.
Using “Right Answers”
To add tests with right answers, just use thegolden_answer field in the test. A full example is as follows: