Documentation
¶
Index ¶
- func AuditLogs(message string, logType string, apiKeyID uuid.UUID, messageType string, ...) *models.AuditLogs
- func AuthOpenShieldMiddleware(next http.HandlerFunc) http.HandlerFunc
- func DB() *gorm.DB
- func ErrorResponse(w http.ResponseWriter, err error)
- func GetCache(key string) ([]byte, bool, error)
- func GetContextCache(prompt string, productID string) (string, error)
- func GetModel(model string) (models.AiModels, error)
- func HashKey(key string) string
- func InitRedisClient(config *Configuration)
- func KeyByRealIP(r *http.Request) (string, error)
- func LogUsage(modelName string, predictedTokensCount int, promptTokensCount int, ...)
- func SetCache(key string, value interface{}) error
- func SetConfig(config Configuration)
- func SetContextCache(prompt, answer, productID string) error
- func SetDB(customDB *gorm.DB)
- func TokenizerHandler(c *fiber.Ctx) error
- type Action
- type ActionType
- type CacheConfig
- type Config
- type Configuration
- type ContextCache
- type Database
- type DatabaseConfig
- type FeatureToggle
- type Log
- type Network
- type OpenAIRoutes
- type Option
- type ProviderAnthropic
- type ProviderHuggingFace
- type ProviderNvidia
- type ProviderOpenAI
- type Providers
- type RateLimiting
- type Redis
- type RedisConfig
- type RedisSettings
- type Route
- type RouteSettings
- type Routes
- type Rule
- type RuleServer
- type Rules
- type Secrets
- type ServiceLlamaGuard
- type ServicePromptGuard
- type Services
- type Setting
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthOpenShieldMiddleware ¶
func AuthOpenShieldMiddleware(next http.HandlerFunc) http.HandlerFunc
func ErrorResponse ¶
func ErrorResponse(w http.ResponseWriter, err error)
func GetContextCache ¶ added in v0.3.1
func InitRedisClient ¶
func InitRedisClient(config *Configuration)
func SetConfig ¶
func SetConfig(config Configuration)
func SetContextCache ¶ added in v0.3.1
func TokenizerHandler ¶
Types ¶
type Action ¶
type Action struct {
Type ActionType `mapstructure:"type"`
}
Action defines what actions are associated with filters
type CacheConfig ¶
type CacheConfig struct {
Enabled bool `mapstructure:"enabled,default=false"`
TTL int `mapstructure:"ttl,default=60"`
Prefix string `mapstructure:"prefix,default=openshield"`
}
CacheConfig holds configuration for cache settings
type Config ¶
type Config struct {
PluginName string `mapstructure:"plugin_name"`
Relation string `mapstructure:"relation,omitempty"`
Threshold float64 `mapstructure:"threshold,omitempty"`
Url string `mapstructure:"url,omitempty"`
ApiKey string `mapstructure:"api_key,omitempty"`
PIIService interface{} `mapstructure:"piiservice,omitempty"`
Categories []string `mapstructure:"categories,omitempty"`
}
Config holds the configuration specifics of a filter
func (*Config) SetDefaults ¶ added in v0.3.3
func (c *Config) SetDefaults()
Add this function to set default values
type Configuration ¶
type Configuration struct {
Settings Setting `mapstructure:"settings"`
Rules Rules `mapstructure:"rules"`
Secrets Secrets `mapstructure:"secrets"`
Providers Providers `mapstructure:"providers"`
Services Services `mapstructure:"services"`
}
Configuration Represents the entire YAML configuration
var AppConfig Configuration
AppConfig ActionType constants
func GetConfig ¶
func GetConfig() Configuration
type ContextCache ¶ added in v0.3.1
type ContextCache struct {
Enabled bool `mapstructure:"enabled,default=false"`
URL string `mapstructure:"url,default=http://localhost:8001"`
}
ContextCache holds configuration for the context cache
type DatabaseConfig ¶
type DatabaseConfig struct {
URI string `mapstructure:"uri"`
AutoMigration bool `mapstructure:"auto_migration,default=false"`
}
DatabaseConfig holds configuration for the database
type FeatureToggle ¶
type FeatureToggle struct {
Enabled bool `mapstructure:"enabled,default=false"`
}
FeatureToggle is used to enable or disable features
type Network ¶
type Network struct {
Port int `mapstructure:"port,default=8080"`
}
Network holds configuration for network settings
type OpenAIRoutes ¶
type ProviderAnthropic ¶ added in v0.3.1
type ProviderHuggingFace ¶ added in v0.3.1
type ProviderNvidia ¶ added in v0.3.1
type ProviderOpenAI ¶
type Providers ¶
type Providers struct {
OpenAI *ProviderOpenAI `mapstructure:"openai"`
Anthropic *ProviderAnthropic `mapstructure:"anthropic"`
Nvidia *ProviderNvidia `mapstructure:"nvidia"`
HuggingFace *ProviderHuggingFace `mapstructure:"huggingface"`
}
type RateLimiting ¶
type RateLimiting struct {
*FeatureToggle
Window int `mapstructure:"window"`
Max int `mapstructure:"max"`
}
RateLimiting holds configuration for rate limiting settings
type RedisConfig ¶
type RedisConfig struct {
URI string `mapstructure:"uri"`
SSL bool `mapstructure:"ssl,default=false"`
}
RedisConfig holds configuration for the redis cache
type RedisSettings ¶
type Route ¶
type Route struct {
RateLimit RateLimiting
}
type RouteSettings ¶
type RouteSettings struct {
RateLimit *RateLimiting
Redis Redis
}
func GetRouteSettings ¶
func GetRouteSettings() (RouteSettings, error)
type Rule ¶
type Rule struct {
Enabled bool `mapstructure:"enabled,default=false"`
Name string `mapstructure:"name"`
Type string `mapstructure:"type"`
Config Config `mapstructure:"config"`
Action Action `mapstructure:"action"`
OrderNumber int `mapstructure:"order_number"`
}
Rule defines a rule configuration
type RuleServer ¶
type RuleServer struct {
Url string `mapstructure:"url,default=http://localhost:8000"`
}
RuleServer holds configuration for the rule server
type Rules ¶
type Rules struct {
Input []Rule `mapstructure:"input,default=[]"`
Output []Rule `mapstructure:"output,default=[]"`
}
Rules section contains input and output rule configurations
type Secrets ¶
type Secrets struct {
OpenAIApiKey string `mapstructure:"openai_api_key"`
HuggingFaceApiKey string `mapstructure:"huggingface_api_key"`
AnthropicApiKey string `mapstructure:"anthropic_api_key"`
NvidiaApiKey string `mapstructure:"nvidia_api_key"`
}
Secrets section contains all the secrets
type ServiceLlamaGuard ¶ added in v0.4.0
type ServicePromptGuard ¶ added in v0.4.0
type Services ¶ added in v0.4.0
type Services struct {
LlamaGuard *ServiceLlamaGuard `mapstructure:"llamaguard"`
PromptGuard *ServicePromptGuard `mapstructure:"promptguard"`
}
type Setting ¶
type Setting struct {
Redis *RedisConfig `mapstructure:"redis"`
Database *DatabaseConfig `mapstructure:"database"`
Cache *CacheConfig `mapstructure:"cache"`
ContextCache *ContextCache `mapstructure:"context_cache"`
AuditLogging *FeatureToggle `mapstructure:"audit_logging,default=false"`
UsageLogging *FeatureToggle `mapstructure:"usage_logging,default=false"`
Network *Network `mapstructure:"network"`
RateLimit *RateLimiting `mapstructure:"rate_limiting"`
RuleServer *RuleServer `mapstructure:"rule_server"`
EnglishDetectionURL string `mapstructure:"english_detection_url"`
}
Setting can include various configurations like database, cache, and different logging types