optimizer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package optimizer uses an OpenAI-compatible LLM endpoint to merge, deduplicate, and consolidate multiple instruction files into a single coherent output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcatRaw

func ConcatRaw(instructions []ContentInput) string

ConcatRaw is the fallback when LLM is not available — simple concatenation.

Types

type ContentInput

type ContentInput struct {
	Source  string
	Path    string
	Content string
}

ContentInput is the input to the optimizer.

type LLMConfig

type LLMConfig struct {
	// Endpoint is the base URL (e.g. "https://api.openai.com/v1").
	Endpoint string `yaml:"endpoint"`
	// Model is the model name (e.g. "gpt-4o-mini").
	Model string `yaml:"model"`
	// APIKey is the bearer token.
	APIKey string `yaml:"-"`
	// Enabled controls whether LLM optimization is on by default.
	Enabled bool `yaml:"enabled"`
}

LLMConfig configures the OpenAI-compatible LLM used to consolidate content.

type Optimizer

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

Optimizer calls an OpenAI-compatible chat completions endpoint to consolidate content.

func New

func New(cfg LLMConfig, client ...*http.Client) *Optimizer

New creates an Optimizer. Returns nil if LLM is not configured. An optional *http.Client can be passed to control proxy/TLS behavior; if nil, a default client with a 60 s timeout is used.

func (*Optimizer) Enabled

func (o *Optimizer) Enabled() bool

Enabled returns true if the optimizer is configured and available.

func (*Optimizer) Optimize

func (o *Optimizer) Optimize(ctx context.Context, instructions []ContentInput) (string, error)

Optimize takes multiple instruction contents and returns a single consolidated version.

Jump to

Keyboard shortcuts

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