Prompt Guard | Golang SDK
Guard
func (e *promptGuard) Guard(ctx context.Context, input *GuardRequest) (*pangea.PangeaResponse[GuardResult], error)Guard messages.
input := &prompt_guard.GuardRequest{Messages: []prompt_guard.Message{{Role: "user", Content: "how are you?"}}}
response, err := client.Guard(ctx, input)
Type Classification
type Classification structtype 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 interfacePrompt Guard API client.
type Client interface {
Guard(ctx context.Context, input *GuardRequest) (*pangea.PangeaResponse[GuardResult], error)
// Base service methods.
pangea.BaseServicer
}
Type GuardRequest
type GuardRequest structtype 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 structtype 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 structtype Message struct {
Role string `json:"role"`
Content string `json:"content"`
}
Type promptGuard
type promptGuard structtype promptGuard struct {
pangea.BaseService
}