checks

package
v0.0.0-...-6ec82fb Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package checks uses the GCP Checks API to check LLM inputs and outputs against policies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Scrub

func Scrub(req *http.Request) error

Scrub is a scrubber for use with rsc.io/httprr when writing tests that access checks through an httprr.RecordReplay. It removes auth credentials and the GCP project from the request.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

A Checker is an implementation of llm.PolicyChecker that uses the GCP Checks API.

func New

func New(ctx context.Context, lg *slog.Logger, gcpproject string, policies []*llm.PolicyConfig) (*Checker, error)

New returns a new Checker. gcpproject is the GCP project to use when connecting to the GCP Checks API. policies are the policies to apply in calls to Checker.CheckText.

func (*Checker) CheckText

func (c *Checker) CheckText(ctx context.Context, text string, prompt ...llm.Part) ([]*llm.PolicyResult, error)

Implements llm.PolicyChecker.CheckText.

func (*Checker) Name

func (c *Checker) Name() string

Implements llm.PolicyChecker.Name.

func (*Checker) Policies

func (c *Checker) Policies() []*llm.PolicyConfig

Implements llm.PolicyChecker.Policies.

type ClassifyContentRequest

Shorthands for gcpchecks types.

type ClassifyContentResponse

Shorthands for gcpchecks types.

type TextInput

Shorthands for gcpchecks types.

Jump to

Keyboard shortcuts

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