Skip to main content

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 a Suite object, then call create().

Basic Test Suite Creation

Here’s a simple example of creating a test suite:
This creates a simple test suite with a single test.

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:
Both the model and the operators will have access to the file content.

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 the context 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 the global_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.
  • optional: Do not include this check towards the final pass percentage
  • display_metrics: If true, will display the metrics for the check in the UI
See the modifiers page for more information.

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 call Suite.from_id:
You can also download any files attached to the suite:

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 from a file, you can use the Suite.from_json_file() function.
Here is an example of what the test suite file looks like:

Listing and Deleting Suites

You can list all test suites in a project and delete suites:

Exporting a Suite

You can export a suite to JSON or CSV:

Projects

By default, suites are created in the "default-project" project. You can specify a different project:

Using “Right Answers”

To add tests with right answers, use the right_answer field in the Test object. A full example is as follows:
See the web app for more information.