4522310f5a
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>
33 lines
1.4 KiB
Go
33 lines
1.4 KiB
Go
package llm
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
// ErrNoToolsConfigured is returned when the model requests tool calls but no tools are available.
|
|
ErrNoToolsConfigured = errors.New("model requested tool calls but no tools configured")
|
|
|
|
// ErrToolNotFound is returned when a requested tool is not in the toolbox.
|
|
ErrToolNotFound = errors.New("tool not found")
|
|
|
|
// ErrNotConnected is returned when trying to use an MCP server that isn't connected.
|
|
ErrNotConnected = errors.New("MCP server not connected")
|
|
|
|
// ErrStreamClosed is returned when trying to read from a closed stream.
|
|
ErrStreamClosed = errors.New("stream closed")
|
|
|
|
// 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")
|
|
)
|