Skip to main content

Prompt Guard | Golang SDK

Guard

func (e *promptGuard) Guard(ctx context.Context, input *GuardRequest) (*pangea.PangeaResponse[GuardResult], error)

Guard messages.

context.Context
input := &prompt_guard.GuardRequest{Messages: []prompt_guard.Message{{Role: "user", Content: "how are you?"}}}
response, err := client.Guard(ctx, input)

Type Classification

type Classification struct

string `json:"category"`
bool `json:"detected"`
float32 `json:"confidence"`
type Classification struct {
	Category	string	`json:"category"`	// Classification category
	Detected	bool	`json:"detected"`	// Classification detection result
	Confidence	float32	`json:"confidence"`	// Confidence score for the classification
}

Type Client

type Client interface

Prompt Guard API client.

func(ctx context.Context, input *GuardRequest) (*pangea.PangeaResponse[GuardResult], error)
context.Context
pangea.BaseServicer

Base service methods.

type Client interface {
	Guard(ctx context.Context, input *GuardRequest) (*pangea.PangeaResponse[GuardResult], error)

	// Base service methods.
	pangea.BaseServicer
}

Type GuardRequest

type GuardRequest struct

[]Message `json:"messages"`
[]string `json:"analyzers,omitempty"`
bool `json:"classify,omitempty"`
type GuardRequest struct {
	pangea.BaseRequest

	Messages	[]Message	`json:"messages"`		// Prompt content and role array. The content is the text that will be analyzed for redaction.
	Analyzers	[]string	`json:"analyzers,omitempty"`	// Specific analyzers to be used in the call
	Classify	bool		`json:"classify,omitempty"`	// Boolean to enable classification of the content
}

Type GuardResult

type GuardResult struct

bool `json:"detected"`
string `json:"type,omitempty"`
string `json:"analyzer,omitempty"`
float32 `json:"confidence"`
string `json:"info,omitempty"`
type GuardResult struct {
	Detected	bool			`json:"detected"`		// Boolean response for if the prompt was considered malicious or not
	Type		string			`json:"type,omitempty"`		// Type of analysis, either direct or indirect
	Analyzer	string			`json:"analyzer,omitempty"`	// Prompt Analyzers for identifying and rejecting properties of prompts
	Confidence	float32			`json:"confidence"`		// Percent of confidence in the detection result, ranging from 0 to 1
	Info		string			`json:"info,omitempty"`		// Extra information about the detection result
	Classifications	[]Classification	`json:"classifications"`	// List of classification results with labels and confidence scores
}

Type Message

type Message struct

string `json:"role"`
string `json:"content"`
type Message struct {
	Role	string	`json:"role"`
	Content	string	`json:"content"`
}

Type promptGuard

type promptGuard struct
type promptGuard struct {
	pangea.BaseService
}