Skip to main content

Overview

ScopeGuard-2 checks whether a user message is in scope for your AI service before your LLM answers it. On the hosted API it runs on our servers: you send the conversation and your AI service description, and get back one of seven scope classes, with nothing to download or serve.

The hosted API serves one model, scope-guard-v2-pro-2609, the Pro version of ScopeGuard-2, not published on Hugging Face. It is the default when you leave out model.

See it in the PlaygroundExample conversations, each with what ScopeGuard-2 returned.

Quickstart​

With your API key, send the conversation so far, ending with the user's message:

Setup
pip install orbitals # Python 3.10 or later
export PRINCIPLED_API_KEY="principled_..."
first_call.py
from orbitals.scope_guard_v2 import ScopeGuardV2

sg = ScopeGuardV2(
backend="api",
api_url="https://api.orbitals.principled.app",
)

result = sg.validate(
[
{
"role": "user",
"content": "I ordered a package, tracking number 1234567890",
},
{
"role": "assistant",
"content": (
"Great, the package is in transit. "
"What would you like to know?"
),
},
{
"role": "user",
"content": "If it does not arrive tomorrow, can I get a refund?",
},
],
ai_service_description=(
"A virtual assistant for a parcel delivery service. "
"It tracks packages by tracking number "
"and gives expected delivery dates. "
"It never handles refund requests."
),
)

print(result.scope_class.value)
Run it
$ python first_call.py
Restricted

Your code branches on scope_class. Every other field and endpoint is in the Reference.