Documentation
¶
Overview ¶
Package summarizer provides interfaces and implementations for summarizing text content within the ProjectMemory service.
Index ¶
Constants ¶
const ( // Default settings DefaultTimeout = 30 * time.Second DefaultMaxRetries = 3 DefaultRetryDelay = 2 * time.Second DefaultCacheCapacity = 1000 DefaultCacheTTL = 24 * time.Hour )
const ( // DefaultMaxSummaryLength defines the default maximum length for summaries. DefaultMaxSummaryLength = 500 // DefaultPreserveKeyTerms indicates whether key terms should be preserved in summaries. DefaultPreserveKeyTerms = true )
Variables ¶
var ( ErrProviderNotSupported = errors.New("provider not supported") ErrSummarizationFailed = errors.New("summarization failed") ErrConfigError = errors.New("configuration error") ErrContextCanceled = errors.New("context canceled") )
Errors
Functions ¶
func CreateHealthReportJSON ¶
func CreateHealthReportJSON(summarizer *AISummarizer) (string, error)
CreateHealthReportJSON generates a JSON health report for the AI summarizer
func ResetMetrics ¶
func ResetMetrics(summarizer *AISummarizer) error
ResetMetrics resets all metrics for the AI summarizer
Types ¶
type AISummarizer ¶
type AISummarizer struct {
// contains filtered or unexported fields
}
AISummarizer is an implementation of the Summarizer interface that uses LLMs to create high-quality summaries
func NewAISummarizer ¶
func NewAISummarizer(config *AISummarizerConfig) *AISummarizer
NewAISummarizer creates a new AISummarizer with the specified provider and settings
func (*AISummarizer) CheckProviderHealth ¶
func (s *AISummarizer) CheckProviderHealth() map[string]bool
CheckProviderHealth tests if all providers are operational
func (*AISummarizer) GetMetrics ¶
func (s *AISummarizer) GetMetrics() *telemetry.MetricsCollector
GetMetrics returns the metrics collector for this summarizer
func (*AISummarizer) Initialize ¶
func (s *AISummarizer) Initialize() error
Initialize sets up the summarizer with required configuration
type AISummarizerConfig ¶
type AISummarizerConfig struct {
ProviderName string
ModelID string
APIKey string
MaxSummaryLength int
Timeout time.Duration
MaxRetries int
RetryDelay time.Duration
CacheCapacity int
CacheTTL time.Duration
FallbackProviders []struct {
Name string
ModelID string
APIKey string
}
}
AISummarizerConfig holds configuration for the AISummarizer
type BasicSummarizer ¶
type BasicSummarizer struct {
// contains filtered or unexported fields
}
BasicSummarizer is a simple implementation of the Summarizer interface. It extracts the first few sentences from the text as a summary.
func NewBasicSummarizer ¶
func NewBasicSummarizer(maxSummaryLen int) *BasicSummarizer
NewBasicSummarizer creates a new BasicSummarizer instance.
func (*BasicSummarizer) Initialize ¶
func (s *BasicSummarizer) Initialize() error
Initialize sets up the summarizer with any required configuration.
type HealthReport ¶
type HealthReport struct {
Status HealthStatus `json:"status"`
Timestamp time.Time `json:"timestamp"`
Components map[string]string `json:"components"`
Providers map[string]bool `json:"providers"`
ResponseTimes map[string]float64 `json:"response_times_ms"`
CacheStats map[string]int64 `json:"cache_stats"`
SuccessRate float64 `json:"success_rate"`
TotalRequests int64 `json:"total_requests"`
Version string `json:"version"`
}
HealthReport contains information about the current health of the AI summarizer
func CreateHealthReport ¶
func CreateHealthReport(summarizer *AISummarizer) (*HealthReport, error)
CreateHealthReport generates a health report for the AI summarizer
type HealthStatus ¶
type HealthStatus string
HealthStatus represents the health status of a component
const ( // StatusHealthy indicates a component is fully operational StatusHealthy HealthStatus = "healthy" // StatusDegraded indicates a component is operational but with reduced capability StatusDegraded HealthStatus = "degraded" // StatusUnhealthy indicates a component is not operational StatusUnhealthy HealthStatus = "unhealthy" )
type Summarizer ¶
type Summarizer interface {
// Summarize takes a text input and returns a condensed summary.
Summarize(text string) (string, error)
// Initialize sets up the summarizer with any required configuration.
Initialize() error
}
Summarizer defines the interface for summarizing text content.