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:
@@ -32,3 +32,15 @@
|
||||
6. Streaming via pull-based `StreamReader.Next()`
|
||||
7. Middleware for logging, retry, timeout, usage tracking
|
||||
8. Ollama uses the native `/api/chat` API rather than the OpenAI-compat `/v1` endpoint. Native API supports `think: false` for thinking-capable models, has more reliable tool calling, and is approximately 15-20% lower latency. Both local and cloud share the same provider; only the apiKey/baseURL differ. `llm.Ollama()` targets `http://localhost:11434` with no Authorization header; `llm.OllamaCloud(key)` targets `https://ollama.com` with `Authorization: Bearer <key>`.
|
||||
|
||||
### DD#9 — Parse() function and extensible Registry (2026-05-23)
|
||||
**Context:** mort's ParseModelRequest resolves "provider/model" strings but is
|
||||
mort-specific. Multi-instance providers (foreman) need named targets.
|
||||
**Decision:** Add `llm.Parse(spec)` backed by an extensible `Registry`. Supports
|
||||
aliases, dynamic resolvers, and `LLM_X` env var DSNs for named targets.
|
||||
Provider/model syntax: `"openai/gpt-4o"`, aliases: `"fast"`, named targets:
|
||||
`"m5/qwen3:30b"` (reads `LLM_M5` env var). Registry is extensible via
|
||||
`RegisterProvider`, `RegisterAlias`, `RegisterResolver`.
|
||||
**Consequence:** Any go-llm consumer gets model-string parsing. mort migrates by
|
||||
registering its tier aliases as resolvers. Foreman instances are addressed via
|
||||
`LLM_X` DSN env vars without code changes.
|
||||
|
||||
Reference in New Issue
Block a user