compressor

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Instructions = SystemInstructions{
	Minimalist: `You are a context compression assistant. Your task is to summarize conversations concisely, preserving key facts, decisions, and context needed for continuation.`,
	Expert: `
	You are a context compression specialist. Your task is to analyze the conversation history and compress it while preserving all essential information.

	## Instructions:
	1. **Preserve Critical Information**: Keep all important facts, decisions, code snippets, file paths, function names, and technical details
	2. **Remove Redundancy**: Eliminate repetitive discussions, failed attempts, and conversational fluff
	3. **Maintain Chronology**: Keep the logical flow and order of important events
	4. **Summarize Discussions**: Convert long discussions into concise summaries with key takeaways
	5. **Keep Context**: Ensure the compressed version provides enough context for continuing the conversation

	## Output Format:
	Return a compressed version of the conversation that:
	- Uses clear, concise language
	- Groups related topics together
	- Highlights key decisions and outcomes
	- Preserves technical accuracy
	- Maintains references to files, functions, and code

	## Compression Guidelines:
	- Remove: Greetings, acknowledgments, verbose explanations, failed attempts
	- Keep: Facts, code, decisions, file paths, function signatures, error messages, requirements
	- Summarize: Long discussions into bullet points with essential information
	`,
}
View Source
var Prompts = CompressionPrompts{

	Minimalist: `Summarize the conversation history concisely, preserving key facts, decisions, and context needed for continuation.`,
	Structured: `Compress this conversation into a brief summary including:
		- Main topics discussed
		- Key decisions/conclusions
		- Important context for next exchanges
		Keep it under 200 words.
	`,
	UltraShort:      `Summarize this conversation: extract key facts, decisions, and essential context only.`,
	ContinuityFocus: `Create a compact summary of this conversation that preserves all information needed to continue the discussion naturally.`,
}

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

Agent represents a simplified compressor agent that hides OpenAI SDK details

func NewAgent

func NewAgent(
	ctx context.Context,
	agentConfig agents.AgentConfig,
	modelConfig models.Config,
	options ...AgentOption,
) (*Agent, error)

NewAgent creates a new simplified compressor agent

func (*Agent) CompressContext

func (agent *Agent) CompressContext(messagesList []messages.Message) (*CompressionResult, error)

CompressMessages compresses a list of messages and returns the compressed result

func (*Agent) CompressContextStream

func (agent *Agent) CompressContextStream(
	messagesList []messages.Message,
	callback StreamCallback,
) (*CompressionResult, error)

CompressMessagesStream compresses a list of messages and streams the result via callback

func (*Agent) GetKind added in v0.0.3

func (agent *Agent) GetKind() agents.Kind

func (*Agent) GetName added in v0.0.3

func (agent *Agent) GetName() string

func (*Agent) SetCompressionPrompt

func (agent *Agent) SetCompressionPrompt(prompt string)

SetCompressionPrompt sets a custom compression prompt for the agent

type AgentOption

type AgentOption func(*BaseAgent)

func WithCompressionPrompt

func WithCompressionPrompt(prompt string) AgentOption

WithCompressionPrompt sets a custom compression prompt for the agent

type BaseAgent

type BaseAgent struct {
	// contains filtered or unexported fields
}

func NewBaseAgent

func NewBaseAgent(
	ctx context.Context,
	agentConfig agents.AgentConfig,
	modelConfig openai.ChatCompletionNewParams,
	options ...AgentOption,
) (compressorAgent *BaseAgent, err error)

NewBaseAgent creates a new CompressorAgent instance

func (*BaseAgent) CompressContext

func (agent *BaseAgent) CompressContext(messagesList []openai.ChatCompletionMessageParamUnion) (response string, finishReason string, err error)

func (*BaseAgent) CompressContextStream

func (agent *BaseAgent) CompressContextStream(
	messagesList []openai.ChatCompletionMessageParamUnion,
	callBack func(partialResponse string, finishReason string) error) (response string, finishReason string, err error)

func (*BaseAgent) SetCompressionPrompt

func (agent *BaseAgent) SetCompressionPrompt(prompt string)

type CompressionPrompts

type CompressionPrompts struct {
	Minimalist      string
	Structured      string
	UltraShort      string
	ContinuityFocus string
}

type CompressionResult

type CompressionResult struct {
	CompressedText string
	FinishReason   string
}

CompressionResult represents the result of a context compression

type StreamCallback

type StreamCallback func(chunk string, finishReason string) error

StreamCallback is a function called for each chunk of streaming response

type SystemInstructions

type SystemInstructions struct {
	Minimalist string
	Expert     string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL