Documentation
¶
Overview ¶
Package llm provides LLM integration for the Guardian CLI tool. It supports multiple LLM providers (DeepSeek, OpenAI, Claude, Custom) and handles API communication, prompt management, and interactive configuration.
Index ¶
- Constants
- Variables
- func GetCheckPrompt(override string) string
- func GetProposePrompt(override string) string
- func IsCloudProvider(provider string) bool
- func RunConfigure(r io.Reader, w io.Writer) (*config.LLMConfig, error)
- func ValidProviders() []string
- type CheckAnalysis
- type Client
- type ProposalDraft
- type Violation
Constants ¶
const ( ProviderDeepSeek = "deepseek" ProviderOpenAI = "openai" ProviderClaude = "claude" ProviderCustom = "custom" )
Provider constants identify supported LLM providers.
const DefaultCheckSystemPrompt = `` /* 549-byte string literal not displayed */
DefaultCheckSystemPrompt is the built-in system prompt used by guardian check to analyze git diffs against team rules and provide violation explanations.
const DefaultProposeSystemPrompt = `` /* 280-byte string literal not displayed */
DefaultProposeSystemPrompt is the built-in system prompt used by guardian propose to generate draft proposal text for rule changes.
Variables ¶
var DefaultModels = map[string]string{ ProviderDeepSeek: "deepseek-chat", ProviderOpenAI: "gpt-4o", ProviderClaude: "claude-sonnet-4-5-20250929", }
DefaultModels maps known providers to default model names.
var ProviderEndpoints = map[string]string{ ProviderDeepSeek: "https://api.deepseek.com/v1", ProviderOpenAI: "https://api.openai.com/v1", ProviderClaude: "https://api.anthropic.com/v1", }
ProviderEndpoints maps known providers to their API endpoints.
Functions ¶
func GetCheckPrompt ¶
GetCheckPrompt returns the check system prompt. If override is non-empty, it is used instead of the built-in default prompt.
func GetProposePrompt ¶
GetProposePrompt returns the propose system prompt. If override is non-empty, it is used instead of the built-in default prompt.
func IsCloudProvider ¶
IsCloudProvider returns true for non-local providers that send data to external APIs (deepseek, openai, claude).
func RunConfigure ¶
RunConfigure runs the interactive LLM configuration flow. It reads from r and writes prompts/output to w. Returns the updated LLMConfig based on user selections.
func ValidProviders ¶
func ValidProviders() []string
ValidProviders returns the list of all valid provider names.
Types ¶
type CheckAnalysis ¶
CheckAnalysis represents the LLM response for a check analysis.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the LLM client that communicates with a configured provider.
func NewClient ¶
NewClient creates a new LLM client from constitution config. It reads the API key from the GUARDIAN_LLM_API_KEY environment variable. Returns an error if the API key is not set.
func (*Client) AnalyzeCheck ¶
func (c *Client) AnalyzeCheck(diffContent string, rules []config.Rule, violations []Violation) (*CheckAnalysis, error)
AnalyzeCheck sends diff content and violations to the LLM for analysis. It returns explanations keyed by rule ID.
func (*Client) DraftProposal ¶
DraftProposal generates a proposal draft using the LLM.