feat(v2): add Parse() function and extensible Registry for model string resolution
CI / Root Module (pull_request) Failing after 3s
CI / Lint (pull_request) Failing after 3s
CI / V2 Module (pull_request) Successful in 1m25s

Introduces llm.Parse(spec) backed by an extensible Registry that resolves
model strings like "openai/gpt-4o", aliases like "fast", and named targets
like "m5/qwen3:30b" (via LLM_M5 env var DSNs) into ready-to-use *Model
objects. Extension points: RegisterProvider, RegisterAlias, RegisterResolver.
Adds Foreman constructor and sentinel errors ErrAliasLoop, ErrUnknownProvider,
ErrInvalidDSN.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-23 22:58:14 -04:00
parent 5d4c4f91af
commit 4522310f5a
6 changed files with 1084 additions and 11 deletions
+16
View File
@@ -119,6 +119,22 @@ func Ollama(opts ...ClientOption) *Client {
return NewClient(ollamaProvider.New("", cfg.baseURL))
}
// Foreman creates a client targeting a foreman daemon (a private, authenticated
// Ollama endpoint with queuing and observability). The token is sent as a Bearer
// token; pass "" for unauthenticated (network-trusted) deployments. Use
// WithBaseURL to set the foreman host URL.
//
// Example:
//
// model := llm.Foreman("my-token", llm.WithBaseURL("https://foreman.local")).Model("qwen3:30b")
func Foreman(token string, opts ...ClientOption) *Client {
cfg := &clientConfig{}
for _, opt := range opts {
opt(cfg)
}
return NewClient(ollamaProvider.New(token, cfg.baseURL))
}
// OllamaCloud creates a client targeting Ollama Cloud (https://ollama.com).
// The apiKey is required and is sent as `Authorization: Bearer <key>`. Use
// WithBaseURL to point at a private Ollama deployment that requires auth.