feat: foundations — canonical types, Parse grammar, env DSNs, health, chains
Phase 1 of the majordomo build: - llm/ canonical contract (messages, parts, tools, capabilities, streaming, Model/Provider, error classification) - health/ clock-injected tracker (threshold bench, exponential capped cooldown, reset-on-success) - root Registry + Parse (verbatim model ids, inline recursive alias expansion with cycle detection, chain dedup), LLM_* env-DSN providers (go-llm parity: lazy fallback + eager LoadEnv), health-aware chain executor behind the Model interface - provider/fake scriptable test provider; hermetic test suite incl. the trailing-thinking chain and foreman:// env loading - ADRs 0001-0008, CLAUDE.md, README (honest matrix), CI workflow, docs/phase-1-design.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package llm
|
||||
|
||||
import "slices"
|
||||
|
||||
// Capabilities declares what a model (or provider) supports and the limits
|
||||
// it imposes. Providers declare defaults; individual models may override.
|
||||
// The media pipeline normalizes image inputs against these values before a
|
||||
// request is serialized.
|
||||
//
|
||||
// Zero-value semantics:
|
||||
// - MaxImagesPerReq == 0 means image input is NOT supported.
|
||||
// - MaxImageBytes / MaxImageDimension / ContextWindow == 0 mean
|
||||
// "no declared limit", not zero.
|
||||
// - AllowedImageMIME empty means any MIME type is acceptable
|
||||
// (only meaningful when images are supported at all).
|
||||
type Capabilities struct {
|
||||
// MaxImageBytes is the largest single image payload, in bytes.
|
||||
MaxImageBytes int
|
||||
// MaxImageDimension is the largest allowed width or height, in pixels.
|
||||
MaxImageDimension int
|
||||
// AllowedImageMIME lists acceptable image content types
|
||||
// (e.g. "image/jpeg", "image/png").
|
||||
AllowedImageMIME []string
|
||||
// MaxImagesPerReq is the most images one request may carry; 0 = images
|
||||
// unsupported.
|
||||
MaxImagesPerReq int
|
||||
|
||||
SupportsTools bool
|
||||
SupportsStructured bool
|
||||
SupportsStreaming bool
|
||||
|
||||
// ContextWindow is the model's context size in tokens, when known.
|
||||
ContextWindow int
|
||||
}
|
||||
|
||||
// SupportsImages reports whether the target accepts image input.
|
||||
func (c Capabilities) SupportsImages() bool { return c.MaxImagesPerReq > 0 }
|
||||
|
||||
// MIMEAllowed reports whether the given image MIME type is acceptable.
|
||||
func (c Capabilities) MIMEAllowed(mime string) bool {
|
||||
if len(c.AllowedImageMIME) == 0 {
|
||||
return true
|
||||
}
|
||||
return slices.Contains(c.AllowedImageMIME, mime)
|
||||
}
|
||||
Reference in New Issue
Block a user