Documentation
¶
Overview ¶
Package provider holds inspection provider implementations.
Index ¶
Constants ¶
const RegexName = "regex"
RegexName is the provider name a policy profile uses to select this provider: `provider: regex`.
const ShieldstralName = "shieldstral"
ShieldstralName is the provider name a policy profile uses: `provider: shieldstral`.
const SidecarName = "sidecar"
SidecarName is the provider name a policy profile uses: `provider: sidecar`.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Regex ¶
type Regex struct {
// contains filtered or unexported fields
}
Regex is a local, in-process inspection provider backed by regular expressions.
It exists so the inspection path is provable end to end with no model, no sidecar and no network: a rule matches, content is inspected, a decision resolves to deny or redact. It is genuinely useful beyond testing as the cheap pre-pass in front of an expensive model, but it is not a PII detector -- it has no notion of context, so it cannot tell a customer's phone number from a support line in a code comment.
func NewRegex ¶
NewRegex builds a provider over the built-in patterns, plus any extras. An extra whose name matches a built-in replaces it.
func (*Regex) Categories ¶
Categories implements inspect.Provider.
func (*Regex) Inspect ¶
Inspect implements inspect.Provider.
The profile's Categories field selects which patterns run. An empty Categories list runs every one: a profile that names no categories is asking for a general sweep, and running nothing would report clean.
A category the provider does not know is an error, not a skip. Silently ignoring it would mean a profile asking for `secret` against a provider with no secret pattern comes back clean, which is the fail-open this whole design exists to prevent.
type Shieldstral ¶
type Shieldstral struct {
// contains filtered or unexported fields
}
Shieldstral is a safety classifier reached over an OpenAI-compatible chat endpoint.
Shieldstral ships no server of its own, but it needs none: vLLM, llama.cpp and SGLang all serve it behind the OpenAI chat-completions API, and its whole contract is one forward pass returning a single yes/no token. That is exactly what `max_tokens: 1` with `logprobs` returns, so this is an HTTP client and about forty lines of arithmetic rather than a sidecar.
It is deliberately NOT a LocalProvider: content sent here leaves the process, and on a remote base URL leaves the machine, so the privacy gate must have a say. A server bound to 127.0.0.1 is still gated, because nothing in an HTTP URL proves where it actually resolves to.
func NewShieldstral ¶
func NewShieldstral(cfg ShieldstralConfig) (*Shieldstral, error)
NewShieldstral builds a Shieldstral provider.
func (*Shieldstral) Categories ¶
func (s *Shieldstral) Categories() []string
Categories implements inspect.Provider.
Shieldstral has no fixed taxonomy: that is the point of it. The moderation criteria are the profile's own natural-language queries, supplied at inference time, and a finding's category is the query's id. So there is no list to publish, and a profile using `categories:` here is a mistake -- Inspect refuses it rather than answering a question the model was never asked.
type ShieldstralConfig ¶
type ShieldstralConfig struct {
// BaseURL is the OpenAI-compatible root, e.g. http://127.0.0.1:8000/v1.
// A trailing /chat/completions is added.
BaseURL string
// Model is the name the server knows the checkpoint by, e.g.
// mistralai/Shieldstral-1.0-3B for vLLM or the GGUF alias for
// llama-server.
Model string
// APIKey, when set, is sent as a bearer token.
APIKey string
// Concurrency bounds simultaneous queries. Zero uses
// defaultShieldstralConcurrency.
Concurrency int
// MaxAttempts, BaseBackoff and MaxBackoff tune the retry client. Zero
// values use httpretry's defaults.
MaxAttempts int
BaseBackoff time.Duration
MaxBackoff time.Duration
// Transport is for tests.
Transport http.RoundTripper
}
ShieldstralConfig configures a Shieldstral provider.
type Sidecar ¶
type Sidecar struct {
// contains filtered or unexported fields
}
Sidecar is an HTTP inspection provider speaking the agentmon inspection contract:
POST {base}/v1/inspect/pii {text, categories} -> {spans, redacted_text}
POST {base}/v1/inspect/safety {document, instruct, queries} -> {results}
It is deliberately NOT a LocalProvider: content sent here leaves the process, and on a remote base URL leaves the machine, so the privacy gate must have a say. A sidecar bound to 127.0.0.1 is still gated, because nothing in an HTTP URL proves where it actually resolves to.
The contract is the boundary, not the model. Anything that serves these two endpoints works, which is what keeps the choice of inference runtime -- a Python service, an ONNX Runtime process, llama.cpp behind a shim -- out of this codebase.
func NewSidecar ¶
func NewSidecar(cfg SidecarConfig) (*Sidecar, error)
NewSidecar builds a Sidecar provider.
func (*Sidecar) Categories ¶
Categories implements inspect.Provider.
The sidecar's taxonomy is fixed by the models behind it, so this is the Privacy Filter label set. A profile naming something outside it is rejected before any content is sent -- a category the sidecar will not look for must not come back as a clean result.
type SidecarConfig ¶
type SidecarConfig struct {
// BaseURL is the sidecar root, e.g. http://127.0.0.1:8731.
BaseURL string
// APIKey, when set, is sent as a bearer token.
APIKey string
// MaxAttempts, BaseBackoff and MaxBackoff tune the retry client. Zero
// values use httpretry's defaults.
MaxAttempts int
BaseBackoff time.Duration
MaxBackoff time.Duration
// Transport is for tests.
Transport http.RoundTripper
}
SidecarConfig configures a Sidecar provider.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package onnxrt calls ONNX Runtime from Go without cgo.
|
Package onnxrt calls ONNX Runtime from Go without cgo. |
|
gen
command
Command gen-ort-api extracts the OrtApi struct member order from onnxruntime_c_api.h and writes it as Go constants.
|
Command gen-ort-api extracts the OrtApi struct member order from onnxruntime_c_api.h and writes it as Go constants. |
|
Package privacyfilter decodes OpenAI Privacy Filter output into spans.
|
Package privacyfilter decodes OpenAI Privacy Filter output into spans. |
|
modelcache
Package modelcache downloads and verifies model files.
|
Package modelcache downloads and verifies model files. |
|
tokenizer
Package tokenizer implements the byte-level BPE tokenizer that openai/privacy-filter was trained with.
|
Package tokenizer implements the byte-level BPE tokenizer that openai/privacy-filter was trained with. |