llm

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTemplateNameRequired = &PromptError{Msg: "template name is required"}
	ErrPromptRequired       = &PromptError{Msg: "user prompt is required"}
	ErrCannotRemoveBuiltin  = &PromptError{Msg: "cannot remove built-in template"}
)

Custom error types

Functions

func DefaultTemplatesDir

func DefaultTemplatesDir() string

DefaultTemplatesDir returns the default templates directory

Types

type Config

type Config struct {
	Provider   Provider
	Model      string
	BaseURL    string
	Timeout    time.Duration
	MaxRetries int
}

Config holds summarizer configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration

type PromptError

type PromptError struct {
	Msg string
}

PromptError represents a prompt template error

func (*PromptError) Error

func (e *PromptError) Error() string

type PromptTemplate

type PromptTemplate struct {
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	SystemPrompt string            `json:"system_prompt"`
	UserPrompt   string            `json:"user_prompt"`
	Intent       string            `json:"intent"`    // debug, review, test, build, general
	Variables    map[string]string `json:"variables"` // Custom variables for template
	MaxTokens    int               `json:"max_tokens"`
	Temperature  float64           `json:"temperature"`
}

PromptTemplate represents a custom prompt template for LLM summarization

func CreateCustomTemplate

func CreateCustomTemplate(name, description, systemPrompt, userPrompt, intent string) PromptTemplate

CreateCustomTemplate creates a new custom template from scratch

type PromptTemplateManager

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

PromptTemplateManager manages custom prompt templates

func NewPromptTemplateManager

func NewPromptTemplateManager(templatesDir string) *PromptTemplateManager

NewPromptTemplateManager creates a new template manager

func (*PromptTemplateManager) AddTemplate

func (m *PromptTemplateManager) AddTemplate(template PromptTemplate) error

AddTemplate adds or updates a custom template

func (*PromptTemplateManager) BuildPrompt

func (m *PromptTemplateManager) BuildPrompt(template PromptTemplate, content string, variables map[string]string) string

BuildPrompt creates a complete prompt from a template

func (*PromptTemplateManager) GetTemplate

func (m *PromptTemplateManager) GetTemplate(name string) (PromptTemplate, bool)

GetTemplate retrieves a template by name

func (*PromptTemplateManager) GetTemplateForIntent

func (m *PromptTemplateManager) GetTemplateForIntent(intent string) PromptTemplate

GetTemplateForIntent retrieves a template matching an intent

func (*PromptTemplateManager) ListTemplates

func (m *PromptTemplateManager) ListTemplates() []PromptTemplate

ListTemplates returns all available template names

func (*PromptTemplateManager) RemoveTemplate

func (m *PromptTemplateManager) RemoveTemplate(name string) error

RemoveTemplate removes a custom template

type Provider

type Provider string

Provider represents an LLM provider type

const (
	ProviderOllama   Provider = "ollama"
	ProviderLMStudio Provider = "lmstudio"
	ProviderOpenAI   Provider = "openai"
	ProviderNone     Provider = "none"
)

type Summarizer

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

Summarizer provides LLM-powered summarization capabilities. Supports multiple backends: Ollama, LM Studio, and other OpenAI-compatible APIs.

func NewSummarizer

func NewSummarizer(cfg Config) *Summarizer

NewSummarizer creates a new LLM summarizer

func NewSummarizerFromEnv

func NewSummarizerFromEnv() *Summarizer

NewSummarizerFromEnv creates a summarizer from environment variables

func (*Summarizer) GetModel

func (s *Summarizer) GetModel() string

GetModel returns the current model name

func (*Summarizer) GetProvider

func (s *Summarizer) GetProvider() Provider

GetProvider returns the current provider

func (*Summarizer) IsAvailable

func (s *Summarizer) IsAvailable() bool

IsAvailable returns true if an LLM provider is available

func (*Summarizer) ListModels

func (s *Summarizer) ListModels() ([]string, error)

ListModels returns available models for the provider

func (*Summarizer) StreamSummary

func (s *Summarizer) StreamSummary(req SummaryRequest, callback func(string)) (*SummaryResponse, error)

StreamSummary generates a summary with streaming output

func (*Summarizer) Summarize

func (s *Summarizer) Summarize(req SummaryRequest) (*SummaryResponse, error)

Summarize generates a summary of the content

type SummaryRequest

type SummaryRequest struct {
	Content   string
	MaxTokens int
	Intent    string // "debug", "review", "search", etc.
}

SummaryRequest represents a summarization request

type SummaryResponse

type SummaryResponse struct {
	Summary     string
	TokensUsed  int
	ModelUsed   string
	FromCache   bool
	Compression float64 // Ratio of original to compressed
}

SummaryResponse represents a summarization result

Jump to

Keyboard shortcuts

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