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,39 @@
|
||||
package llm
|
||||
|
||||
// Part is one piece of message content: text, an image, or future media
|
||||
// kinds. The set of implementations is closed (sealed by the unexported
|
||||
// method) so providers can switch exhaustively over content kinds.
|
||||
//
|
||||
// Why: providers need a finite, known content vocabulary to serialize into
|
||||
// their wire formats; an open interface would silently drop unknown content.
|
||||
type Part interface {
|
||||
isPart()
|
||||
}
|
||||
|
||||
// TextPart is plain text content.
|
||||
type TextPart struct {
|
||||
Text string
|
||||
}
|
||||
|
||||
func (TextPart) isPart() {}
|
||||
|
||||
// ImagePart is image content carried as raw bytes plus a MIME type.
|
||||
//
|
||||
// Why bytes-only (no URL form): the media pipeline must be able to inspect,
|
||||
// downscale, and re-encode every image to fit the target's capabilities, and
|
||||
// that requires the bytes. Callers with a URL fetch it themselves; majordomo
|
||||
// does not download remote content on a caller's behalf.
|
||||
type ImagePart struct {
|
||||
// MIME is the image content type, e.g. "image/png" or "image/jpeg".
|
||||
MIME string
|
||||
// Data is the raw, unencoded image bytes (providers base64 as needed).
|
||||
Data []byte
|
||||
}
|
||||
|
||||
func (ImagePart) isPart() {}
|
||||
|
||||
// Text constructs a text content part.
|
||||
func Text(s string) Part { return TextPart{Text: s} }
|
||||
|
||||
// Image constructs an image content part from raw bytes.
|
||||
func Image(mime string, data []byte) Part { return ImagePart{MIME: mime, Data: data} }
|
||||
Reference in New Issue
Block a user