Documentation
¶
Index ¶
- Constants
- type ClaudeConfig
- type ClaudeLLM
- func (c *ClaudeLLM) Generate(ctx context.Context, prompt string, opts GenerateOptions) (*GenerateResponse, error)
- func (c *ClaudeLLM) GenerateWithSystem(ctx context.Context, systemPrompt, userPrompt string, opts GenerateOptions) (*GenerateResponse, error)
- func (c *ClaudeLLM) ModelName() string
- func (c *ClaudeLLM) Name() string
- type Config
- type GenerateOptions
- type GenerateResponse
- type LLMService
- type OllamaConfig
- type OllamaLLM
- func (o *OllamaLLM) Generate(ctx context.Context, prompt string, opts GenerateOptions) (*GenerateResponse, error)
- func (o *OllamaLLM) GenerateWithSystem(ctx context.Context, systemPrompt, userPrompt string, opts GenerateOptions) (*GenerateResponse, error)
- func (o *OllamaLLM) ModelName() string
- func (o *OllamaLLM) Name() string
- type OpenAIConfig
- type OpenAILLM
- func (o *OpenAILLM) Generate(ctx context.Context, prompt string, opts GenerateOptions) (*GenerateResponse, error)
- func (o *OpenAILLM) GenerateWithSystem(ctx context.Context, systemPrompt, userPrompt string, opts GenerateOptions) (*GenerateResponse, error)
- func (o *OpenAILLM) ModelName() string
- func (o *OpenAILLM) Name() string
- type Provider
Constants ¶
const ( ClaudeSonnet4 = "claude-sonnet-4-20250514" Claude35Haiku = "claude-3-5-haiku-20241022" Claude35Sonnet = "claude-3-5-sonnet-20241022" ClaudeDefaultURL = "https://api.anthropic.com" ClaudeAPIVersion = "2023-06-01" )
Claude model constants
const ( Llama32 = "llama3.2" Llama31 = "llama3.1" CodeLlama = "codellama" Mistral = "mistral" DeepSeekR1 = "deepseek-r1" Qwen25Coder = "qwen2.5-coder" )
Common Ollama LLM models
const ( GPT4o = "gpt-4o" GPT4oMini = "gpt-4o-mini" GPT4Turbo = "gpt-4-turbo" OpenAIDefaultURL = "https://api.openai.com" )
OpenAI model constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClaudeConfig ¶
type ClaudeConfig struct {
APIKey string // Anthropic API key
Model string // e.g., "claude-sonnet-4-20250514", "claude-3-5-haiku-20241022"
BaseURL string // Optional custom base URL
}
ClaudeConfig holds configuration for Claude LLM
type ClaudeLLM ¶
type ClaudeLLM struct {
// contains filtered or unexported fields
}
ClaudeLLM implements LLMService using Anthropic's Claude API
func NewClaudeLLM ¶
func NewClaudeLLM(config ClaudeConfig, logger *zap.Logger) (*ClaudeLLM, error)
NewClaudeLLM creates a new Claude LLM client
func (*ClaudeLLM) Generate ¶
func (c *ClaudeLLM) Generate(ctx context.Context, prompt string, opts GenerateOptions) (*GenerateResponse, error)
Generate generates a response from Claude
func (*ClaudeLLM) GenerateWithSystem ¶
func (c *ClaudeLLM) GenerateWithSystem(ctx context.Context, systemPrompt, userPrompt string, opts GenerateOptions) (*GenerateResponse, error)
GenerateWithSystem generates a response with a system prompt
type Config ¶
type Config struct {
Provider Provider `yaml:"provider"`
Model string `yaml:"model"`
MaxTokens int `yaml:"max_tokens"`
Temperature float64 `yaml:"temperature"`
// Ollama-specific
OllamaURL string `yaml:"ollama_url"`
// Claude-specific
ClaudeAPIKey string `yaml:"claude_api_key"`
// OpenAI-specific
OpenAIAPIKey string `yaml:"openai_api_key"`
OpenAIBaseURL string `yaml:"openai_base_url"` // For API-compatible services
}
Config holds configuration for LLM providers
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a default configuration using Ollama
type GenerateOptions ¶
type GenerateOptions struct {
MaxTokens int // Maximum tokens to generate
Temperature float64 // Temperature for sampling (0.0-1.0)
Model string // Optional model override
TopP float64 // Top-p sampling
TopK int // Top-k sampling
}
GenerateOptions contains options for LLM generation
func DefaultGenerateOptions ¶
func DefaultGenerateOptions() GenerateOptions
DefaultGenerateOptions returns sensible defaults for code summarization
type GenerateResponse ¶
type GenerateResponse struct {
Content string // Generated text
Model string // Model used
PromptTokens int // Tokens in prompt
OutputTokens int // Tokens in response
TotalTokens int // Total tokens used
}
GenerateResponse contains the LLM response
type LLMService ¶
type LLMService interface {
// Generate generates a response from the LLM given a prompt
Generate(ctx context.Context, prompt string, opts GenerateOptions) (*GenerateResponse, error)
// GenerateWithSystem generates a response with a system prompt
GenerateWithSystem(ctx context.Context, systemPrompt, userPrompt string, opts GenerateOptions) (*GenerateResponse, error)
// Name returns the provider name
Name() string
// ModelName returns the model being used
ModelName() string
}
LLMService defines the interface for LLM providers
func NewLLMService ¶
func NewLLMService(config Config, logger *zap.Logger) (LLMService, error)
NewLLMService creates an LLM service based on the provided configuration
func NewLLMServiceFromProvider ¶
func NewLLMServiceFromProvider(provider string, logger *zap.Logger) (LLMService, error)
NewLLMServiceFromProvider creates an LLM service from just a provider string This is a convenience function for simpler configuration
type OllamaConfig ¶
type OllamaConfig struct {
APIURL string // e.g., "http://localhost:11434"
Model string // e.g., "llama3.2", "codellama", "mistral"
}
OllamaConfig holds configuration for Ollama LLM
type OllamaLLM ¶
type OllamaLLM struct {
// contains filtered or unexported fields
}
OllamaLLM implements LLMService using Ollama
func NewOllamaLLM ¶
func NewOllamaLLM(config OllamaConfig, logger *zap.Logger) (*OllamaLLM, error)
NewOllamaLLM creates a new Ollama LLM client
func (*OllamaLLM) Generate ¶
func (o *OllamaLLM) Generate(ctx context.Context, prompt string, opts GenerateOptions) (*GenerateResponse, error)
Generate generates a response from the LLM
func (*OllamaLLM) GenerateWithSystem ¶
func (o *OllamaLLM) GenerateWithSystem(ctx context.Context, systemPrompt, userPrompt string, opts GenerateOptions) (*GenerateResponse, error)
GenerateWithSystem generates a response with a system prompt
type OpenAIConfig ¶
type OpenAIConfig struct {
APIKey string // OpenAI API key
Model string // e.g., "gpt-4o", "gpt-4o-mini"
BaseURL string // Optional custom base URL (for compatible APIs)
}
OpenAIConfig holds configuration for OpenAI LLM
type OpenAILLM ¶
type OpenAILLM struct {
// contains filtered or unexported fields
}
OpenAILLM implements LLMService using OpenAI's API
func NewOpenAILLM ¶
func NewOpenAILLM(config OpenAIConfig, logger *zap.Logger) (*OpenAILLM, error)
NewOpenAILLM creates a new OpenAI LLM client
func (*OpenAILLM) Generate ¶
func (o *OpenAILLM) Generate(ctx context.Context, prompt string, opts GenerateOptions) (*GenerateResponse, error)
Generate generates a response from OpenAI
func (*OpenAILLM) GenerateWithSystem ¶
func (o *OpenAILLM) GenerateWithSystem(ctx context.Context, systemPrompt, userPrompt string, opts GenerateOptions) (*GenerateResponse, error)
GenerateWithSystem generates a response with a system prompt