provider

package
v0.0.0-...-230ac96 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package provider holds inspection provider implementations.

Index

Constants

View Source
const RegexName = "regex"

RegexName is the provider name a policy profile uses to select this provider: `provider: regex`.

View Source
const ShieldstralName = "shieldstral"

ShieldstralName is the provider name a policy profile uses: `provider: shieldstral`.

View Source
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

func NewRegex(extra map[string]string) (*Regex, error)

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

func (r *Regex) Categories() []string

Categories implements inspect.Provider.

func (*Regex) Inspect

func (r *Regex) Inspect(ctx context.Context, req inspect.Request) (*inspect.Response, error)

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.

func (*Regex) IsLocal

func (r *Regex) IsLocal() bool

IsLocal implements inspect.LocalProvider: this provider makes no network calls, so the privacy gate lets it see content unconditionally.

func (*Regex) Name

func (r *Regex) Name() string

Name implements inspect.Provider.

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.

func (*Shieldstral) Inspect

func (s *Shieldstral) Inspect(ctx context.Context, req inspect.Request) (*inspect.Response, error)

Inspect implements inspect.Provider.

func (*Shieldstral) Name

func (s *Shieldstral) Name() string

Name implements inspect.Provider.

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

func (s *Sidecar) Categories() []string

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.

func (*Sidecar) Inspect

func (s *Sidecar) Inspect(ctx context.Context, req inspect.Request) (*inspect.Response, error)

Inspect implements inspect.Provider.

A profile with categories runs the PII endpoint; one with queries runs the safety endpoint; one with both runs both and merges. Validate already rejects a profile with neither.

func (*Sidecar) Name

func (s *Sidecar) Name() string

Name implements inspect.Provider.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL