EvalSuite at a system that’s actually serving users. Each target is just a callable that takes a string and returns a string, so you can pass it directly to suite.run() anywhere a model_fn is accepted.
Install the extras you need:
browser extra, also run playwright install chromium once.
DeployedAPITarget
Wraps a deployed REST endpoint as an eval target. Handles auth, retries, rate limiting, and response extraction from nested JSON.Parameters
Behavior
- Auth.
BearerAuth(token)sendsAuthorization: Bearer <token>.APIKeyAuth(key, header="X-API-Key")sends a custom header. Pass either one to theauthargument; their headers are merged withheaders. - Retries.
429and5xxresponses are retried with exponential backoff using(2 ** attempt) * 0.5seconds between attempts. After all retries are exhausted, aRuntimeErroris raised with the last status code and attempt count, e.g.DeployedAPITarget failed after 3 attempt(s): HTTP 503 after 3 attempt(s). - Missing dependency. If the
requestspackage isn’t installed, the constructor raisesImportErrorimmediately rather than failing on the first call. - Response extraction.
output_pathwalks the JSON response. Each segment is treated as a list index when the current value is a list, otherwise as a dict key. Missing keys return an empty string.
MultiTurnAPITarget
Session-aware target for evaluating multi-turn conversations. Initializes a session (optional), sends the running history on each turn, and supportsEvalCase.conversation.
Parameters
Behavior
- Calling
target(input)is a single-turn shortcut — it wrapsrun_conversationforsuite.run()compatibility. run_conversation(turns, evaluators=None)returns(final_response, eval_results). Eachuserturn is sent with the running history;assistantturns in the input are appended directly without making a request.- On error after all retries, the turn’s response is set to the literal string
"[API ERROR]"and the conversation continues.
BrowserTarget
Playwright-based target for browser-rendered AI applications. Opens a real browser, optionally logs in, submits input via a CSS selector, waits for the response, and extracts the response text.Parameters
When a call fails, the target returns the literal string
"[BROWSER ERROR: <message>]" so that the eval continues. Always call target.close() when finished.
simulate_users
Generate synthetic adversarial and edge-case user personas, run each one against any target, and evaluate the responses.Parameters
Persona types
Return value
A list of dicts, one per persona:output is set to "[TARGET ERROR: <message>]" and evaluation continues.
Auth helpers
Both targets accept the same auth helpers.
You can also implement your own — anything with a
headers() -> dict[str, str] method works.
