Documentation
¶
Overview ¶
Package types provides common types and interfaces for template management.
Package types provides common types for the template management system
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OptimizedTemplateLoader ¶
type OptimizedTemplateLoader interface {
TemplateLoader
// LoadTemplateWithTimeout loads a template with a timeout
LoadTemplateWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) (*format.Template, error)
// LoadTemplatesWithTimeout loads multiple templates with a timeout
LoadTemplatesWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) ([]*format.Template, error)
// ClearCache clears the template cache
ClearCache()
// GetCacheStats returns statistics about the cache
GetCacheStats() map[string]interface{}
// GetLoaderStats returns statistics about the loader
GetLoaderStats() map[string]interface{}
// SetConcurrencyLimit sets the concurrency limit
SetConcurrencyLimit(limit int)
}
OptimizedTemplateLoader extends TemplateLoader with additional optimized methods
type OptimizedTemplateManager ¶
type OptimizedTemplateManager interface {
TemplateManager
// ClearCache clears the template cache
ClearCache()
// GetStats returns statistics about the manager
GetStats() map[string]interface{}
// GetTemplateStats returns statistics about a specific template
GetTemplateStats(templateID string) map[string]interface{}
// GetTemplateIDs returns all template IDs
GetTemplateIDs() []string
// SetConcurrencyLimit sets the concurrency limit
SetConcurrencyLimit(limit int)
// SetCacheTTL sets the cache TTL
SetCacheTTL(ttl time.Duration)
// SetCacheSize sets the cache size
SetCacheSize(size int)
// SetExecutionTimeout sets the execution timeout
SetExecutionTimeout(timeout time.Duration)
// SetLoadTimeout sets the load timeout
SetLoadTimeout(timeout time.Duration)
// SetDebug sets the debug flag
SetDebug(debug bool)
}
OptimizedTemplateManager extends TemplateManager with additional optimized methods
type TemplateLoader ¶
type TemplateLoader interface {
// LoadTemplate loads a template from a source
LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)
// LoadTemplates loads multiple templates from a source
LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
}
TemplateLoader defines the interface for loading templates
type TemplateManager ¶
type TemplateManager interface {
// LoadTemplate loads a template from a source
LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)
// LoadTemplates loads multiple templates from a source
LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
// Execute executes a template
Execute(ctx context.Context, template *format.Template, options map[string]interface{}) (*interfaces.TemplateResult, error)
// ExecuteBatch executes multiple templates
ExecuteBatch(ctx context.Context, templates []*format.Template, options map[string]interface{}) ([]*interfaces.TemplateResult, error)
// GetLoader returns the template loader
GetLoader() TemplateLoader
// GetExecutor returns the template executor
GetExecutor() interfaces.TemplateExecutor
}
TemplateManager defines the interface for managing templates
type TemplateResult ¶
type TemplateResult struct {
// TemplateID is the ID of the template
TemplateID string `json:"template_id"`
// TemplateName is the name of the template
TemplateName string `json:"template_name"`
// Description is the description of the template
Description string `json:"description"`
// Status is the status of the template
Status TemplateStatus `json:"status"`
// StartTime is the time the template execution started
StartTime time.Time `json:"start_time"`
// EndTime is the time the template execution ended
EndTime time.Time `json:"end_time"`
// Duration is the duration of the template execution
Duration time.Duration `json:"duration"`
// Error is any error that occurred during template execution
Error error `json:"error,omitempty"`
// Response is the response from the LLM
Response string `json:"response,omitempty"`
// Detected indicates whether the vulnerability was detected
Detected bool `json:"detected"`
// Score is the score of the template execution (0-100)
Score int `json:"score"`
// Details contains additional details about the template execution
Details map[string]interface{} `json:"details,omitempty"`
// Tags contains tags associated with the template
Tags []string `json:"tags,omitempty"`
// Metadata contains additional metadata about the template
Metadata map[string]interface{} `json:"metadata,omitempty"`
// Input contains the input to the template
Input string `json:"input,omitempty"`
// Output contains the expected output from the template
Output string `json:"output,omitempty"`
}
TemplateResult represents the result of a template execution
type TemplateSource ¶
type TemplateSource struct {
// Path is the path to the source
Path string
// Type is the type of the source
Type string
}
TemplateSource represents a source of templates
type TemplateSourceType ¶
type TemplateSourceType string
TemplateSourceType represents the type of template source
const ( // LocalSourceType represents templates from the local filesystem LocalSourceType TemplateSourceType = "local" // RemoteSourceType represents templates from a remote repository RemoteSourceType TemplateSourceType = "remote" // DatabaseSourceType represents templates from a database DatabaseSourceType TemplateSourceType = "database" )
type TemplateStatus ¶
type TemplateStatus string
TemplateStatus represents the status of a template
const ( // StatusLoaded indicates the template has been loaded StatusLoaded TemplateStatus = "loaded" // StatusValidated indicates the template has been validated StatusValidated TemplateStatus = "validated" // StatusExecuting indicates the template is being executed StatusExecuting TemplateStatus = "executing" // StatusCompleted indicates the template execution has completed StatusCompleted TemplateStatus = "completed" // StatusFailed indicates the template execution has failed StatusFailed TemplateStatus = "failed" )