Documentation
¶
Overview ¶
Package llm is the provider-agnostic LLM abstraction the writer agent calls into. In v0.2 the only working implementation is Noop - real providers (Anthropic, OpenAI, local models) will land in v0.3 behind this same interface, so nothing above this package needs to change.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Anthropic ¶ added in v0.7.0
Anthropic talks to Anthropic's Messages API.
func NewAnthropic ¶ added in v0.7.0
func NewAnthropic(s config.LLMSettings) *Anthropic
type Client ¶
type Client interface {
Name() string
Generate(ctx context.Context, req Request) (Response, error)
}
Client is the contract every provider implements. Generate must respect ctx cancellation; Name is used in logs so users can see which provider produced a given draft.
func New ¶
func New(s config.LLMSettings) (Client, string)
New constructs a Client from settings. Unknown providers - or known providers with incomplete configuration - fall back to Noop with a warning surfaced via the returned message. We never crash the CLI just because config.json names a provider we don't ship yet.
type Noop ¶
type Noop struct{}
Noop is a Client that returns an empty response, signalling "no LLM content - use your fallback". It exists so the writer agent's call site is identical whether or not a real provider is configured.
type OpenAICompatible ¶
type OpenAICompatible struct {
ProviderName string
BaseURL string
APIKey string
Model string
HTTP *http.Client
}
OpenAICompatible talks to any HTTP chat-completions endpoint that mirrors OpenAI's request/response shape (OpenAI proper, Together, vLLM, Ollama's OpenAI shim, etc.). The implementation is intentionally minimal: only model + messages + max_tokens go on the wire, and only the first choice is returned.
func NewOpenAICompatible ¶
func NewOpenAICompatible(s config.LLMSettings) *OpenAICompatible
NewOpenAICompatible constructs the client. No network call is made.
func NewOpenAICompatibleNamed ¶ added in v0.7.0
func NewOpenAICompatibleNamed(name string, s config.LLMSettings) *OpenAICompatible
NewOpenAICompatibleNamed constructs a chat-completions client with a user-facing provider name. Useful for providers that intentionally expose an OpenAI-compatible API but should be logged as "openai", "ollama", etc.
func (*OpenAICompatible) Generate ¶
Generate sends one chat-completions request and returns the first choice. It validates required config up front so the user sees a clear error before any network I/O happens.
func (*OpenAICompatible) Name ¶
func (c *OpenAICompatible) Name() string
type Request ¶
type Request struct {
System string
Prompt string
// MaxTokens is a hint - providers may clamp or ignore it.
MaxTokens int
}
Request is the minimal payload we send to a provider. We keep it small on purpose: agents that want richer behavior should compose extra context into Prompt rather than growing this struct.