Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextManager ¶
type ContextManager struct {
// contains filtered or unexported fields
}
ContextManager manages context windows for different models
func NewContextManager ¶
func NewContextManager() *ContextManager
NewContextManager creates a new context manager
func (*ContextManager) CreateWindow ¶
func (cm *ContextManager) CreateWindow(modelName string) *ContextWindow
CreateWindow creates a new context window for a model
func (*ContextManager) OptimizePrompt ¶
func (cm *ContextManager) OptimizePrompt( window *ContextWindow, messages []prompt.Message, tools []prompt.Tool, systemPrompt string, ) (string, error)
OptimizePrompt optimizes a prompt to fit within the context window
type ContextWindow ¶
type ContextWindow struct {
MaxTokens int
CurrentTokens int
Messages []Message
Tools []Tool
SystemPrompt string
ReservedTokens int // Reserved for output generation
}
ContextWindow represents the context window state
func (*ContextWindow) GetStatistics ¶
func (window *ContextWindow) GetStatistics() map[string]any
GetStatistics returns current window statistics
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
Tokens int `json:"tokens"`
Timestamp int64 `json:"timestamp"`
Priority int `json:"priority"` // Higher priority messages are kept longer
}
Message represents a conversation message with token count
type ModelContextConfig ¶
type ModelContextConfig struct {
ModelName string
MaxContextTokens int
OutputReserve int // Tokens reserved for output
CompressionRatio float64
}
ModelContextConfig contains model-specific context configuration
type SimpleTokenEstimator ¶
type SimpleTokenEstimator struct{}
SimpleTokenEstimator provides basic token estimation
func (*SimpleTokenEstimator) EstimateTokens ¶
func (e *SimpleTokenEstimator) EstimateTokens(text string) int
type SummaryCache ¶
type SummaryCache struct {
// contains filtered or unexported fields
}
SummaryCache caches conversation summaries
type TokenEstimator ¶
TokenEstimator estimates token count for text
Click to show internal directories.
Click to hide internal directories.