Skip to main content

AI Guard | Golang SDK

Text guard (Beta)

func (e *aiGuard) GuardText(ctx context.Context, input *TextGuardRequest) (*pangea.PangeaResponse[TextGuardResult], error)

Guard text.

required parameters

context.Context
input := &ai_guard.TextGuardRequest{Text: "hello world"}
response, err := client.GuardText(ctx, input)

Type AnalyzerResponse

type AnalyzerResponse struct

required parameters

string `json:"analyzer"`
float64 `json:"confidence"`
type AnalyzerResponse struct {
	Analyzer	string	`json:"analyzer"`
	Confidence	float64	`json:"confidence"`
}

Type Client

type Client interface

AI Guard API client.

required parameters

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

Base service methods.

type Client interface {
	GuardText(ctx context.Context, input *TextGuardRequest) (*pangea.PangeaResponse[TextGuardResult], error)

	// Base service methods.
	pangea.BaseServicer
}

Type MaliciousEntity

type MaliciousEntity struct

required parameters

string `json:"type"`
string `json:"value"`
*bool `json:"redacted,omitempty"`
*int `json:"start_pos,omitempty"`
map[string]interface{} `json:"raw,omitempty"`
type 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 struct

required parameters

[]MaliciousEntity `json:"entities"`
type MaliciousEntityResult struct {
	Entities []MaliciousEntity `json:"entities"`
}

Type PiiEntity

type PiiEntity struct

required parameters

string `json:"type"`
string `json:"value"`
bool `json:"redacted"`
*int `json:"start_pos,omitempty"`
type PiiEntity struct {
	Type		string	`json:"type"`
	Value		string	`json:"value"`
	Redacted	bool	`json:"redacted"`
	StartPos	*int	`json:"start_pos,omitempty"`
}

Type PiiEntityResult

type PiiEntityResult struct

required parameters

[]PiiEntity `json:"entities"`
type PiiEntityResult struct {
	Entities []PiiEntity `json:"entities"`
}

Type PromptInjectionResult

type PromptInjectionResult struct

required parameters

[]AnalyzerResponse `json:"analyzer_responses"`
type PromptInjectionResult struct {
	AnalyzerResponses []AnalyzerResponse `json:"analyzer_responses"`
}

Type TextGuardDetector

type TextGuardDetector[T any] struct

required parameters

any
bool `json:"detected"`
*T `json:"data,omitempty"`
type TextGuardDetector[T any] struct {
	Detected	bool	`json:"detected"`
	Data		*T	`json:"data,omitempty"`
}

Type TextGuardDetectors

type TextGuardDetectors struct

required parameters

*TextGuardDetector[PromptInjectionResult] `json:"prompt_injection,omitempty"`
*TextGuardDetector[PiiEntityResult] `json:"pii_entity,omitempty"`
*TextGuardDetector[MaliciousEntityResult] `json:"malicious_entity,omitempty"`
type 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 struct

required parameters

string `json:"text"`
string `json:"recipe,omitempty"`
bool `json:"debug,omitempty"`
type TextGuardRequest struct {
	pangea.BaseRequest

	Text	string	`json:"text"`
	Recipe	string	`json:"recipe,omitempty"`
	Debug	bool	`json:"debug,omitempty"`
}

Type TextGuardResult

type TextGuardResult struct

required parameters

TextGuardDetectors `json:"detectors"`
string `json:"prompt"`
type TextGuardResult struct {
	Detectors	TextGuardDetectors	`json:"detectors"`
	Prompt		string			`json:"prompt"`
}

Type aiGuard

type aiGuard struct
type aiGuard struct {
	pangea.BaseService
}