Documentation
¶
Overview ¶
Package llm provides local large language model clients. The Ollama client talks to a local Ollama server, so under the default policy no data leaves the machine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyResponse = errors.New("llm: empty response")
ErrEmptyResponse indicates the model returned no content.
var ErrModel = errors.New("llm: model error")
ErrModel indicates the Ollama server is unreachable or reported an error.
Functions ¶
This section is empty.
Types ¶
type Anthropic ¶ added in v0.1.17
type Anthropic struct {
// contains filtered or unexported fields
}
Anthropic is a minimal Claude Messages API client. It exists for the explicitly opted-in cloud path: the caller is responsible for checking the egress policy and redacting the payload before any call. The API key is never logged and travels only in the request header.
func NewAnthropic ¶ added in v0.1.17
func NewAnthropic(apiKey string, opts ...AnthropicOption) *Anthropic
NewAnthropic returns a Claude client. It panics on an empty key: the caller must have read it from the environment before constructing the client.
type AnthropicOption ¶ added in v0.1.17
type AnthropicOption func(*Anthropic)
AnthropicOption configures the client.
func WithAnthropicBaseURL ¶ added in v0.1.17
func WithAnthropicBaseURL(u string) AnthropicOption
WithAnthropicBaseURL overrides the API root, mainly for tests.
func WithAnthropicModel ¶ added in v0.1.17
func WithAnthropicModel(model string) AnthropicOption
WithAnthropicModel overrides the default model.
type Doer ¶
type Doer interface {
// Do performs the request and returns the response.
Do(req *http.Request) (*http.Response, error)
}
Doer performs an HTTP request. *http.Client satisfies it; tests inject a stub.
type Ollama ¶
type Ollama struct {
// contains filtered or unexported fields
}
Ollama calls a local Ollama chat model.
type OpenAI ¶ added in v0.1.17
type OpenAI struct {
// contains filtered or unexported fields
}
OpenAI is a minimal chat-completions client. The wire format is the de facto standard spoken by OpenAI and by local servers like LM Studio, llamafile, and vLLM, so one client covers them all via the base URL. It exists for the explicitly opted-in cloud path: the caller is responsible for checking the egress policy and redacting the payload before any call. The API key is never logged and travels only in the request header.
func NewOpenAI ¶ added in v0.1.17
func NewOpenAI(apiKey string, opts ...OpenAIOption) *OpenAI
NewOpenAI returns an OpenAI-compatible client. The key may be empty when the server does not require one, as local servers usually do not.
type OpenAIOption ¶ added in v0.1.17
type OpenAIOption func(*OpenAI)
OpenAIOption configures the client.
func WithOpenAIBaseURL ¶ added in v0.1.17
func WithOpenAIBaseURL(u string) OpenAIOption
WithOpenAIBaseURL points the client at a compatible server, such as a local LM Studio or vLLM instance.
func WithOpenAIModel ¶ added in v0.1.17
func WithOpenAIModel(model string) OpenAIOption
WithOpenAIModel overrides the default model.
type Option ¶
type Option func(*Ollama)
Option configures an Ollama client.
func WithEmbedModel ¶
WithEmbedModel overrides the embedding model.