AI Guard | Golang SDK
Text guard (Beta)
func (e *aiGuard) GuardText(ctx context.Context, input *TextGuardRequest) (*pangea.PangeaResponse[TextGuardResult], error)Guard text.
input := &ai_guard.TextGuardRequest{Text: "hello world"}
response, err := client.GuardText(ctx, input)
Type AnalyzerResponse
type AnalyzerResponse structtype AnalyzerResponse struct {
Analyzer string `json:"analyzer"`
Confidence float64 `json:"confidence"`
}
Type Client
type Client interfaceAI Guard API client.
type Client interface {
GuardText(ctx context.Context, input *TextGuardRequest) (*pangea.PangeaResponse[TextGuardResult], error)
// Base service methods.
pangea.BaseServicer
}
Type MaliciousEntity
type MaliciousEntity structtype MaliciousEntity struct {
Type string `json:"type"`
Value string `json:"value"`
Redacted *bool `json:"redacted,omitempty"`
StartPos *int `json:"start_pos,omitempty"`
Raw map[string]interface{} `json:"raw,omitempty"`
}
Type MaliciousEntityResult
type MaliciousEntityResult structtype MaliciousEntityResult struct {
Entities []MaliciousEntity `json:"entities"`
}
Type PiiEntity
type PiiEntity structtype PiiEntity struct {
Type string `json:"type"`
Value string `json:"value"`
Redacted bool `json:"redacted"`
StartPos *int `json:"start_pos,omitempty"`
}
Type PiiEntityResult
type PiiEntityResult structtype PiiEntityResult struct {
Entities []PiiEntity `json:"entities"`
}
Type PromptInjectionResult
type PromptInjectionResult structtype PromptInjectionResult struct {
AnalyzerResponses []AnalyzerResponse `json:"analyzer_responses"`
}
Type TextGuardDetector
type TextGuardDetector[T any] structtype TextGuardDetector[T any] struct {
Detected bool `json:"detected"`
Data *T `json:"data,omitempty"`
}
Type TextGuardDetectors
type TextGuardDetectors structtype TextGuardDetectors struct {
PromptInjection *TextGuardDetector[PromptInjectionResult] `json:"prompt_injection,omitempty"`
PiiEntity *TextGuardDetector[PiiEntityResult] `json:"pii_entity,omitempty"`
MaliciousEntity *TextGuardDetector[MaliciousEntityResult] `json:"malicious_entity,omitempty"`
}
Type TextGuardRequest
type TextGuardRequest structtype TextGuardRequest struct {
pangea.BaseRequest
Text string `json:"text"`
Recipe string `json:"recipe,omitempty"`
Debug bool `json:"debug,omitempty"`
}
Type TextGuardResult
type TextGuardResult structtype TextGuardResult struct {
Detectors TextGuardDetectors `json:"detectors"`
Prompt string `json:"prompt"`
}
Type aiGuard
type aiGuard structtype aiGuard struct {
pangea.BaseService
}