Files
Memoh/internal/settings/types.go
T
Acbox Liu de62f94315 feat: add context compaction to automatically summarize old messages (#compaction) (#276)
When input tokens exceed a configurable threshold after a conversation round,
the system asynchronously compacts older messages into a summary. Cascading
compactions reference prior summaries via <prior_context> tags to maintain
conversational continuity without duplicating content.

- Add bot_history_message_compacts table and compact_id on messages
- Add compaction_enabled, compaction_threshold, compaction_model_id to bots
- Implement compaction service (internal/compaction) with LLM summarization
- Integrate into conversation flow: replace compacted messages with summaries
  wrapped in <summary> tags during context loading
- Add REST API endpoints (GET/DELETE /bots/:bot_id/compaction/logs)
- Add frontend Compaction tab with settings and log viewer
- Wire compaction service into both dev (cmd/agent) and prod (cmd/memoh) entry points
- Update test mocks to include new GetBotByID columns
2026-03-22 14:26:00 +08:00

51 lines
2.3 KiB
Go

package settings
const (
DefaultMaxContextLoadTime = 24 * 60
DefaultLanguage = "auto"
DefaultReasoningEffort = "medium"
DefaultHeartbeatInterval = 30
)
type Settings struct {
ChatModelID string `json:"chat_model_id"`
SearchProviderID string `json:"search_provider_id"`
MemoryProviderID string `json:"memory_provider_id"`
TtsModelID string `json:"tts_model_id"`
BrowserContextID string `json:"browser_context_id"`
MaxContextLoadTime int `json:"max_context_load_time"`
MaxContextTokens int `json:"max_context_tokens"`
Language string `json:"language"`
AllowGuest bool `json:"allow_guest"`
ReasoningEnabled bool `json:"reasoning_enabled"`
ReasoningEffort string `json:"reasoning_effort"`
HeartbeatEnabled bool `json:"heartbeat_enabled"`
HeartbeatInterval int `json:"heartbeat_interval"`
HeartbeatModelID string `json:"heartbeat_model_id"`
TitleModelID string `json:"title_model_id"`
CompactionEnabled bool `json:"compaction_enabled"`
CompactionThreshold int `json:"compaction_threshold"`
CompactionModelID string `json:"compaction_model_id,omitempty"`
}
type UpsertRequest struct {
ChatModelID string `json:"chat_model_id,omitempty"`
SearchProviderID string `json:"search_provider_id,omitempty"`
MemoryProviderID string `json:"memory_provider_id,omitempty"`
TtsModelID string `json:"tts_model_id,omitempty"`
BrowserContextID string `json:"browser_context_id,omitempty"`
MaxContextLoadTime *int `json:"max_context_load_time,omitempty"`
MaxContextTokens *int `json:"max_context_tokens,omitempty"`
Language string `json:"language,omitempty"`
AllowGuest *bool `json:"allow_guest,omitempty"`
ReasoningEnabled *bool `json:"reasoning_enabled,omitempty"`
ReasoningEffort *string `json:"reasoning_effort,omitempty"`
HeartbeatEnabled *bool `json:"heartbeat_enabled,omitempty"`
HeartbeatInterval *int `json:"heartbeat_interval,omitempty"`
HeartbeatModelID string `json:"heartbeat_model_id,omitempty"`
TitleModelID string `json:"title_model_id,omitempty"`
CompactionEnabled *bool `json:"compaction_enabled,omitempty"`
CompactionThreshold *int `json:"compaction_threshold,omitempty"`
CompactionModelID *string `json:"compaction_model_id,omitempty"`
}