llm

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableModels added in v0.4.0

func AvailableModels() map[string][]ModelInfo

AvailableModels returns models grouped by provider based on available CLIs. If ANTHROPIC_API_KEY is set, it will fetch the latest models from the API.

func ListAvailableAdapters

func ListAvailableAdapters(config Config) []string

ListAvailableAdapters returns all adapters that could be used.

Types

type Adapter

type Adapter interface {
	// Name returns the adapter identifier for logging.
	Name() string

	// IsAvailable checks if this adapter can be used (CLI installed, API key set, etc.)
	IsAvailable() bool

	// Generate sends prompts to the LLM and returns parsed response.
	Generate(ctx context.Context, systemPrompt, userPrompt string) (*core.ParseResponse, error)
}

Adapter is the interface all LLM adapters must implement.

func DetectBestAdapter

func DetectBestAdapter(config Config) (Adapter, error)

DetectBestAdapter finds the best available LLM adapter. Priority: Claude CLI > Codex CLI > Anthropic API

type AnthropicAPIAdapter

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

AnthropicAPIAdapter uses the Anthropic API directly. Fallback when Claude CLI is not available.

func NewAnthropicAPIAdapter

func NewAnthropicAPIAdapter(config Config) (*AnthropicAPIAdapter, error)

NewAnthropicAPIAdapter creates an Anthropic API adapter.

func (*AnthropicAPIAdapter) Generate

func (a *AnthropicAPIAdapter) Generate(ctx context.Context, systemPrompt, userPrompt string) (*core.ParseResponse, error)

func (*AnthropicAPIAdapter) IsAvailable

func (a *AnthropicAPIAdapter) IsAvailable() bool

func (*AnthropicAPIAdapter) Name

func (a *AnthropicAPIAdapter) Name() string

type ClaudeCLIAdapter

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

ClaudeCLIAdapter uses the Claude Code CLI for generation. This is preferred because users already have it authenticated.

func NewClaudeCLIAdapter

func NewClaudeCLIAdapter(config Config) *ClaudeCLIAdapter

NewClaudeCLIAdapter creates a Claude CLI adapter.

func (*ClaudeCLIAdapter) Generate

func (a *ClaudeCLIAdapter) Generate(ctx context.Context, systemPrompt, userPrompt string) (*core.ParseResponse, error)

func (*ClaudeCLIAdapter) GenerateRaw added in v0.2.0

func (a *ClaudeCLIAdapter) GenerateRaw(ctx context.Context, systemPrompt, userPrompt string) (string, error)

GenerateRaw sends prompts to Claude and returns raw string output. Used for validation and other non-structured responses.

func (*ClaudeCLIAdapter) IsAvailable

func (a *ClaudeCLIAdapter) IsAvailable() bool

IsAvailable checks if the claude CLI is installed.

func (*ClaudeCLIAdapter) Name

func (a *ClaudeCLIAdapter) Name() string

type CodexCLIAdapter

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

CodexCLIAdapter uses the Codex CLI for generation.

func NewCodexCLIAdapter

func NewCodexCLIAdapter(config Config) *CodexCLIAdapter

NewCodexCLIAdapter creates a Codex CLI adapter.

func (*CodexCLIAdapter) Generate

func (a *CodexCLIAdapter) Generate(ctx context.Context, systemPrompt, userPrompt string) (*core.ParseResponse, error)

func (*CodexCLIAdapter) IsAvailable

func (a *CodexCLIAdapter) IsAvailable() bool

IsAvailable checks if the codex CLI is installed.

func (*CodexCLIAdapter) Name

func (a *CodexCLIAdapter) Name() string

type Config

type Config struct {
	// PreferCLI prefers CLI tools (claude, codex) over API when available.
	PreferCLI bool

	// Model specifies which model to use (optional, adapter chooses default).
	Model string

	// Per-stage model configuration for multi-stage parsing.
	// These override Model when set.
	EpicModel    string `yaml:"epic_model"`
	TaskModel    string `yaml:"task_model"`
	SubtaskModel string `yaml:"subtask_model"`

	// APIKey for direct API access (optional if CLI is used).
	APIKey string

	// MaxTokens limits response length.
	MaxTokens int
}

Config holds configuration for LLM adapters.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

func (Config) ModelForStage added in v0.4.0

func (c Config) ModelForStage(stage string) string

ModelForStage returns the model to use for a given stage. Falls back to the default Model if no stage-specific model is set.

type ModelInfo added in v0.4.0

type ModelInfo struct {
	ID          string // Model identifier (e.g., "claude-opus-4-5-20251101")
	Name        string // Human-readable name (e.g., "Claude Opus 4.5")
	Description string // Brief description
	Provider    string // Provider name (e.g., "anthropic", "openai")
}

ModelInfo describes an available model.

func AllModels added in v0.4.0

func AllModels() []ModelInfo

AllModels returns a flat list of all available models.

type MultiStageGenerator added in v0.2.0

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

MultiStageGenerator implements core.Generator for multi-stage parsing.

func NewMultiStageGenerator added in v0.2.0

func NewMultiStageGenerator(config Config) *MultiStageGenerator

NewMultiStageGenerator creates a generator for multi-stage parsing.

func (*MultiStageGenerator) GenerateEpics added in v0.2.0

func (g *MultiStageGenerator) GenerateEpics(ctx context.Context, prdContent string, config core.ParseConfig) (*core.EpicsResponse, error)

GenerateEpics implements Stage 1: PRD → Epics.

func (*MultiStageGenerator) GenerateSubtasks added in v0.2.0

func (g *MultiStageGenerator) GenerateSubtasks(ctx context.Context, task core.Task, epicContext string, project core.ProjectContext, config core.ParseConfig, prdContent string) ([]core.Subtask, error)

GenerateSubtasks implements Stage 3: Task → Subtasks.

func (*MultiStageGenerator) GenerateTasks added in v0.2.0

func (g *MultiStageGenerator) GenerateTasks(ctx context.Context, epic core.Epic, project core.ProjectContext, config core.ParseConfig, prdContent string) ([]core.Task, error)

GenerateTasks implements Stage 2: Epic → Tasks.

Jump to

Keyboard shortcuts

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