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:
@@ -17,4 +17,16 @@ var (
|
||||
|
||||
// ErrNoStructuredOutput is returned when the model did not return a structured output tool call.
|
||||
ErrNoStructuredOutput = errors.New("model did not return structured output")
|
||||
|
||||
// ErrAliasLoop is returned when alias resolution exceeds the maximum depth (10),
|
||||
// indicating a cycle such as "a" → "b" → "a".
|
||||
ErrAliasLoop = errors.New("alias resolution loop detected (depth > 10)")
|
||||
|
||||
// ErrUnknownProvider is returned when a spec references a provider name that
|
||||
// is not registered and has no corresponding LLM_X environment variable.
|
||||
ErrUnknownProvider = errors.New("unknown provider")
|
||||
|
||||
// ErrInvalidDSN is returned when a DSN string (from an LLM_X env var) cannot
|
||||
// be parsed. Expected format: scheme://[token@]host[/path].
|
||||
ErrInvalidDSN = errors.New("invalid DSN")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user