Skip to main content
View module source on GitHub

TestRunBuilder

Builder for test runs. Execution flow: With platform evaluators only (e.g. "Bias"), the SDK pushes entries and the Maxim platform runs the prompt or workflow. With local evaluators or yields_output(), the SDK runs the prompt/workflow locally (or calls your output function) and then runs evaluators locally.

__init__

Constructor

with_data_structure

Set the data structure for the test run Arguments: Returns:

with_data

Set the data for the test run Arguments: Returns:

with_evaluators

Add evaluators to the test run. Use platform evaluators by name (e.g. "Bias") or BaseEvaluator instances for local evaluators. With local evaluators, the SDK runs the prompt/workflow locally to get output before evaluating. Arguments: Returns:

with_human_evaluation_config

Set the human evaluation configuration for the test run Arguments: Returns:

with_workflow_id

Set the workflow ID for the test run. Optionally, you can also set the context to evaluate for the workflow. (Note: setting the context to evaluate will end up overriding the CONTEXT_TO_EVALUATE dataset column value) Arguments: Returns: Raises:
  • ValueError - If a prompt version ID, prompt chain version ID or output function is already set for this run builder

with_prompt_version_id

Set the prompt version ID for the test run. Optionally, you can also set the context to evaluate for the prompt. (Note: setting the context to evaluate will end up overriding the CONTEXT_TO_EVALUATE dataset column value) Arguments: Returns: Raises:
  • ValueError - If a workflow ID, prompt chain version ID or output function is already set for this run builder

with_prompt_chain_version_id

Set the prompt chain version ID for the test run. Optionally, you can also set the context to evaluate for the prompt chain. (Note: setting the context to evaluate will end up overriding the CONTEXT_TO_EVALUATE dataset column value) Arguments: Returns: Raises:
  • ValueError - If a workflow ID, prompt version ID or output function is already set for this run builder

with_simulation_config

Set the simulation configuration for the test run. Use this to run AI-simulated multi-turn conversations against your prompt or workflow. Execution flow: With platform evaluators only, the simulation runs on the Maxim platform. With local evaluators, the SDK fetches simulation output and runs your evaluators locally. When used with yields_output(), the SDK runs your output function locally in a turn-by-turn loop. You can omit both with_prompt_version_id() and with_workflow_id() for SDK-only simulation. Your function receives SimulationContext with conversation_history, current_user_input, turn_number, total_cost, and total_tokens. Use turn.response.get("output", "") for the assistant’s text in each turn. Arguments: Returns: Raises:
  • ValueError - If simulation config is used with with_prompt_chain_version_id (use with_workflow_id or with_prompt_version_id instead)

with_preset

Set a preset (test configuration) to use for this test run. The preset provides default values for datasets, evaluators, simulation config, and context-to-evaluate settings. Any values explicitly set via other builder methods will take priority over preset defaults. Requires an entity to be set first via with_workflow_id(), with_prompt_version_id(), or with_prompt_chain_version_id(), as the preset is scoped to a specific entity. Arguments: Returns: Raises:
  • ValueError - If preset_name is empty or not a string

yields_output

Set the output function for the test run. When combined with with_simulation_config(), enables local-execution simulation where your function is called turn-by-turn with SimulationContext (conversation history, current user input, turn number, total_cost, total_tokens). You can omit both with_prompt_version_id() and with_workflow_id() for SDK-only simulation. Use turn.response.get("output", "") for the assistant’s text in each turn of conversation_history. Arguments: Returns: Raises:
  • ValueError - If a workflow ID, prompt chain version ID or prompt version ID is already set for this run builder

with_concurrency

Set the concurrency level for the test run Arguments: Returns:

with_logger

Set the logger for the test run Arguments: Returns:

run

Run the test Arguments: Returns: