from trusttest.catalog.off_topic import OffTopicScenarioBuilder, SubCategory
from trusttest.targets.http import HttpTarget, PayloadConfig
target = HttpTarget(
url="https://your-model-endpoint.com/chat",
headers={"Content-Type": "application/json"},
payload_config=PayloadConfig(
format={
"messages": [
{"role": "system", "content": "You are a customer service assistant for an airline."},
{"role": "user", "content": "{{ test }}"}
]
},
message_regex="{{ test }}",
),
)
builder = OffTopicScenarioBuilder(target=target, num_test_cases=20)
scenario = builder.get_scenario(SubCategory.COMPETITORS_CHECK)
test_set = scenario.probe.get_test_set()
results = scenario.eval.evaluate(test_set)
results.display_summary()