Documentation ¶
Overview ¶
Package moderation provides moderation capabilities using different nlp services.
Index ¶
- type AmazonComprehendPII
- func (c *AmazonComprehendPII) Call(ctx context.Context, inputs schema.ChainValues, ...) (schema.ChainValues, error)
- func (c *AmazonComprehendPII) Callbacks() []schema.Callback
- func (c *AmazonComprehendPII) InputKeys() []string
- func (c *AmazonComprehendPII) Memory() schema.Memory
- func (c *AmazonComprehendPII) OutputKeys() []string
- func (c *AmazonComprehendPII) Type() string
- func (c *AmazonComprehendPII) Verbose() bool
- type AmazonComprehendPIIClient
- type AmazonComprehendPIIOptions
- type AmazonComprehendPromptSafety
- func (c *AmazonComprehendPromptSafety) Call(ctx context.Context, inputs schema.ChainValues, ...) (schema.ChainValues, error)
- func (c *AmazonComprehendPromptSafety) Callbacks() []schema.Callback
- func (c *AmazonComprehendPromptSafety) InputKeys() []string
- func (c *AmazonComprehendPromptSafety) Memory() schema.Memory
- func (c *AmazonComprehendPromptSafety) OutputKeys() []string
- func (c *AmazonComprehendPromptSafety) Type() string
- func (c *AmazonComprehendPromptSafety) Verbose() bool
- type AmazonComprehendPromptSafetyClient
- type AmazonComprehendPromptSafetyOptions
- type AmazonComprehendToxicity
- func (c *AmazonComprehendToxicity) Call(ctx context.Context, inputs schema.ChainValues, ...) (schema.ChainValues, error)
- func (c *AmazonComprehendToxicity) Callbacks() []schema.Callback
- func (c *AmazonComprehendToxicity) InputKeys() []string
- func (c *AmazonComprehendToxicity) Memory() schema.Memory
- func (c *AmazonComprehendToxicity) OutputKeys() []string
- func (c *AmazonComprehendToxicity) Type() string
- func (c *AmazonComprehendToxicity) Verbose() bool
- type AmazonComprehendToxicityClient
- type AmazonComprehendToxicityOptions
- type OpenAI
- func (c *OpenAI) Call(ctx context.Context, inputs schema.ChainValues, ...) (schema.ChainValues, error)
- func (c *OpenAI) Callbacks() []schema.Callback
- func (c *OpenAI) InputKeys() []string
- func (c *OpenAI) Memory() schema.Memory
- func (c *OpenAI) OutputKeys() []string
- func (c *OpenAI) Type() string
- func (c *OpenAI) Verbose() bool
- type OpenAIClient
- type OpenAIOptions
- type RedactFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AmazonComprehendPII ¶
type AmazonComprehendPII struct {
// contains filtered or unexported fields
}
AmazonComprehendPII is a struct representing the Amazon Comprehend PII moderation functionality.
func NewAmazonComprehendPII ¶
func NewAmazonComprehendPII(client AmazonComprehendPIIClient, optFns ...func(o *AmazonComprehendPIIOptions)) *AmazonComprehendPII
NewAmazonComprehendPII creates a new instance of AmazonComprehendPII with the provided client and options.
func (*AmazonComprehendPII) Call ¶
func (c *AmazonComprehendPII) Call(ctx context.Context, inputs schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error)
Call executes the amazon comprehend moderation chain with the given context and inputs. It returns the outputs of the chain or an error, if any.
func (*AmazonComprehendPII) Callbacks ¶
func (c *AmazonComprehendPII) Callbacks() []schema.Callback
Callbacks returns the callbacks associated with the chain.
func (*AmazonComprehendPII) InputKeys ¶
func (c *AmazonComprehendPII) InputKeys() []string
InputKeys returns the expected input keys.
func (*AmazonComprehendPII) Memory ¶
func (c *AmazonComprehendPII) Memory() schema.Memory
Memory returns the memory associated with the chain.
func (*AmazonComprehendPII) OutputKeys ¶
func (c *AmazonComprehendPII) OutputKeys() []string
OutputKeys returns the output keys the chain will return.
func (*AmazonComprehendPII) Type ¶
func (c *AmazonComprehendPII) Type() string
Type returns the type of the chain.
func (*AmazonComprehendPII) Verbose ¶
func (c *AmazonComprehendPII) Verbose() bool
Verbose returns the verbosity setting of the chain.
type AmazonComprehendPIIClient ¶
type AmazonComprehendPIIClient interface { // ContainsPiiEntities is an interface method that checks if the input text contains Personally Identifiable Information (PII) entities. ContainsPiiEntities(ctx context.Context, params *comprehend.ContainsPiiEntitiesInput, optFns ...func(*comprehend.Options)) (*comprehend.ContainsPiiEntitiesOutput, error) // DetectPiiEntities is an interface method that checks if the input text contains Personally Identifiable Information (PII) entities and returns information about them. DetectPiiEntities(ctx context.Context, params *comprehend.DetectPiiEntitiesInput, optFns ...func(*comprehend.Options)) (*comprehend.DetectPiiEntitiesOutput, error) }
AmazonComprehendPIIClient is an interface for the Amazon Comprehend client.
type AmazonComprehendPIIOptions ¶
type AmazonComprehendPIIOptions struct { // CallbackOptions embeds CallbackOptions to include the verbosity setting and callbacks. *schema.CallbackOptions // InputKey is the key to extract the input text from the input ChainValues. InputKey string // OutputKey is the key to store the output of the moderation in the output ChainValues. OutputKey string // LanguageCode is the language code to specify the language of the input text. LanguageCode string // Labels is a list of labels to check for in the PII analysis. Labels []string // Threshold is the threshold for determining if PII content is found. Threshold float32 // Redact enables redaction of detected PII entities. Redact bool // MaskMarker is the redaction mask character in case redaction MaskMarker rune // RedactFunc defines how to redact PII entities found in the text. RedactFunc RedactFunc }
AmazonComprehendPIIOptions contains options for the Amazon Comprehend PII moderation.
type AmazonComprehendPromptSafety ¶ added in v0.0.89
type AmazonComprehendPromptSafety struct {
// contains filtered or unexported fields
}
AmazonComprehendPromptSafety is a struct representing the Amazon Comprehend Prompt Safety moderation functionality.
func NewAmazonComprehendPromptSafety ¶ added in v0.0.89
func NewAmazonComprehendPromptSafety(client AmazonComprehendPromptSafetyClient, optFns ...func(o *AmazonComprehendPromptSafetyOptions)) *AmazonComprehendPromptSafety
NewAmazonComprehendPromptSafety creates a new instance of AmazonComprehendPromptSafety with the provided client and options.
func (*AmazonComprehendPromptSafety) Call ¶ added in v0.0.89
func (c *AmazonComprehendPromptSafety) Call(ctx context.Context, inputs schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error)
Call executes the amazon comprehend moderation chain with the given context and inputs. It returns the outputs of the chain or an error, if any.
func (*AmazonComprehendPromptSafety) Callbacks ¶ added in v0.0.89
func (c *AmazonComprehendPromptSafety) Callbacks() []schema.Callback
Callbacks returns the callbacks associated with the chain.
func (*AmazonComprehendPromptSafety) InputKeys ¶ added in v0.0.89
func (c *AmazonComprehendPromptSafety) InputKeys() []string
InputKeys returns the expected input keys.
func (*AmazonComprehendPromptSafety) Memory ¶ added in v0.0.89
func (c *AmazonComprehendPromptSafety) Memory() schema.Memory
Memory returns the memory associated with the chain.
func (*AmazonComprehendPromptSafety) OutputKeys ¶ added in v0.0.89
func (c *AmazonComprehendPromptSafety) OutputKeys() []string
OutputKeys returns the output keys the chain will return.
func (*AmazonComprehendPromptSafety) Type ¶ added in v0.0.89
func (c *AmazonComprehendPromptSafety) Type() string
Type returns the type of the chain.
func (*AmazonComprehendPromptSafety) Verbose ¶ added in v0.0.89
func (c *AmazonComprehendPromptSafety) Verbose() bool
Verbose returns the verbosity setting of the chain.
type AmazonComprehendPromptSafetyClient ¶ added in v0.0.89
type AmazonComprehendPromptSafetyClient interface { // Options returns the options associated with the Amazon Comprehend Prompt Safety client. Options() comprehend.Options // ClassifyDocument analyzes the provided text and classifies it as safe or unsafe based on predefined categories. ClassifyDocument(ctx context.Context, params *comprehend.ClassifyDocumentInput, optFns ...func(*comprehend.Options)) (*comprehend.ClassifyDocumentOutput, error) }
AmazonComprehendPromptSafetyClient is an interface for the Amazon Comprehend Prompt Safety client.
type AmazonComprehendPromptSafetyOptions ¶ added in v0.0.89
type AmazonComprehendPromptSafetyOptions struct { // CallbackOptions embeds CallbackOptions to include the verbosity setting and callbacks. *schema.CallbackOptions // InputKey is the key to extract the input text from the input ChainValues. InputKey string // OutputKey is the key to store the output of the moderation in the output ChainValues. OutputKey string // Threshold is the confidence threshold for determining if an input is considered unsafe. Threshold float32 // Endpoint is the URL endpoint for the external service that performs unsafe content detection. Endpoint string }
AmazonComprehendPromptSafetyOptions contains options for the Amazon Comprehend Prompt Safety moderation.
type AmazonComprehendToxicity ¶
type AmazonComprehendToxicity struct {
// contains filtered or unexported fields
}
AmazonComprehendToxicity is a content moderation chain using Amazon Comprehend for toxicity detection.
func NewAmazonComprehendToxicity ¶
func NewAmazonComprehendToxicity(client AmazonComprehendToxicityClient, optFns ...func(o *AmazonComprehendToxicityOptions)) *AmazonComprehendToxicity
NewAmazonComprehendToxicity creates a new instance of AmazonComprehendToxicity with the provided client and options.
func (*AmazonComprehendToxicity) Call ¶
func (c *AmazonComprehendToxicity) Call(ctx context.Context, inputs schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error)
Call executes the amazon comprehend moderation chain with the given context and inputs. It returns the outputs of the chain or an error, if any.
func (*AmazonComprehendToxicity) Callbacks ¶
func (c *AmazonComprehendToxicity) Callbacks() []schema.Callback
Callbacks returns the callbacks associated with the chain.
func (*AmazonComprehendToxicity) InputKeys ¶
func (c *AmazonComprehendToxicity) InputKeys() []string
InputKeys returns the expected input keys.
func (*AmazonComprehendToxicity) Memory ¶
func (c *AmazonComprehendToxicity) Memory() schema.Memory
Memory returns the memory associated with the chain.
func (*AmazonComprehendToxicity) OutputKeys ¶
func (c *AmazonComprehendToxicity) OutputKeys() []string
OutputKeys returns the output keys the chain will return.
func (*AmazonComprehendToxicity) Type ¶
func (c *AmazonComprehendToxicity) Type() string
Type returns the type of the chain.
func (*AmazonComprehendToxicity) Verbose ¶
func (c *AmazonComprehendToxicity) Verbose() bool
Verbose returns the verbosity setting of the chain.
type AmazonComprehendToxicityClient ¶
type AmazonComprehendToxicityClient interface { // DetectToxicContent is an interface function that analyzes a given text for toxic content. DetectToxicContent(ctx context.Context, params *comprehend.DetectToxicContentInput, optFns ...func(*comprehend.Options)) (*comprehend.DetectToxicContentOutput, error) }
AmazonComprehendToxicityClient is an interface for the Amazon Comprehend client used for toxicity detection.
type AmazonComprehendToxicityOptions ¶
type AmazonComprehendToxicityOptions struct { // CallbackOptions embeds CallbackOptions to include the verbosity setting and callbacks. *schema.CallbackOptions // InputKey is the key to extract the input text from the input ChainValues. InputKey string // OutputKey is the key to store the output of the moderation in the output ChainValues. OutputKey string // LanguageCode is the language code used for toxicity detection (default is "en"). LanguageCode string // Labels is a list of specific toxicity labels to check for. Labels []string // Threshold is the threshold score for considering content as toxic (default is 0.8). Threshold float32 }
AmazonComprehendToxicityOptions contains options for configuring the AmazonComprehendToxicity instance.
type OpenAI ¶
type OpenAI struct {
// contains filtered or unexported fields
}
OpenAI represents a chain that performs moderation using the OpenAI API.
func NewOpenAI ¶
func NewOpenAI(apiKey string, optFns ...func(o *OpenAIOptions)) *OpenAI
NewOpenAI creates a new instance of the OpenAI chain using the provided API key and options.
func NewOpenAIFromClient ¶
func NewOpenAIFromClient(client OpenAIClient, optFns ...func(o *OpenAIOptions)) *OpenAI
NewOpenAIFromClient creates a new instance of the OpenAI chain with the given OpenAI client and options.
func (*OpenAI) Call ¶
func (c *OpenAI) Call(ctx context.Context, inputs schema.ChainValues, optFns ...func(o *schema.CallOptions)) (schema.ChainValues, error)
Call executes the openai moderation chain with the given context and inputs. It returns the outputs of the chain or an error, if any.
func (*OpenAI) OutputKeys ¶
OutputKeys returns the output keys the chain will return.
type OpenAIClient ¶
type OpenAIClient interface { // Moderations sends a moderation request to the OpenAI API and receives the response. // It takes the context and a ModerationRequest as input and returns a ModerationResponse or an error. Moderations(ctx context.Context, request openai.ModerationRequest) (response openai.ModerationResponse, err error) }
OpenAIClient is an interface representing an OpenAI client that can make moderation requests.
type OpenAIOptions ¶
type OpenAIOptions struct { // CallbackOptions embeds CallbackOptions to include the verbosity setting and callbacks. *schema.CallbackOptions // ModelName is the name of the OpenAI model to use for moderation. ModelName string // InputKey is the key to extract the input text from the input ChainValues. InputKey string // OutputKey is the key to store the output of the moderation in the output ChainValues. OutputKey string }
OpenAIOptions contains options for configuring the OpenAI chain.