Tribunal.RedTeam.Attacker.Stub (Tribunal v1.4.0)

Copy Markdown View Source

Stub attacker for tests. Returns canned responses set via set_response/1.

State is per-process (stored in the process dictionary), so tests using this stub are async-safe.

Usage

Tribunal.RedTeam.Attacker.Stub.set_response(%{
  attacks: [
    %{prompt: "...", goal: "..."}
  ]
})

{:ok, response} = Tribunal.RedTeam.Attacker.Stub.generate(prompt, schema, [])

Summary

Functions

Clears any canned response for the calling process.

Sets the canned response for the calling process.

Functions

clear()

Clears any canned response for the calling process.

set_response(response)

Sets the canned response for the calling process.