feat(v2): add Parse() function and extensible Registry for model string resolution
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user