feat(llamaswap): add llama-swap provider + canonical imagegen interface
Add provider/llamaswap, a tailored provider for llama-swap (the model-swapping
proxy over llama.cpp / stable-diffusion.cpp). Its chat path delegates to
provider/openai at {base}/v1 — no duplicated wire client (ADR-0007) — with
legacy max_tokens, a Bearer no-key placeholder for keyless local instances, and
a timeout-free client so cold model swaps rely on context deadlines. The
"tailored" surface is concrete management methods (ListModels / Running /
Unload) that don't belong on the canonical llm.Provider interface. The
llama-swap:// DSN scheme builds an http base URL (local-first); a no-URL
built-in errors clearly on use, mirroring foreman.
Add imagegen, a new canonical text-to-image interface separate from llm
(Request/Result/Model/Provider; Image = llm.ImagePart so generated images feed
straight back into chat). First backend is llama-swap via OpenAI
/v1/images/generations (b64_json, bytes-only). Re-exported from the root. v1 is
txt2img only.
Hermetic httptest coverage for chat delegation, management endpoints, image
decode, and scheme wiring. ADR-0015 + ADR-0016, README support matrix +
image-gen section, CLAUDE.md package map, and progress.md updated in the same
commit.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,6 +26,7 @@ import (
|
||||
"encoding/json"
|
||||
"sync"
|
||||
|
||||
"gitea.stevedudenhoeffer.com/steve/majordomo/imagegen"
|
||||
"gitea.stevedudenhoeffer.com/steve/majordomo/llm"
|
||||
)
|
||||
|
||||
@@ -56,6 +57,18 @@ type (
|
||||
ErrorClass = llm.ErrorClass
|
||||
)
|
||||
|
||||
// Re-exported canonical image-generation types. See the imagegen package for
|
||||
// documentation. Image generation is a separate contract from llm (no chat
|
||||
// messages, tools, or streaming); the first backend is provider/llamaswap.
|
||||
type (
|
||||
ImageModel = imagegen.Model
|
||||
ImageProvider = imagegen.Provider
|
||||
ImageRequest = imagegen.Request
|
||||
ImageResult = imagegen.Result
|
||||
ImageOption = imagegen.Option
|
||||
ImageModelOption = imagegen.ModelOption
|
||||
)
|
||||
|
||||
// Re-exported role and finish-reason constants.
|
||||
const (
|
||||
RoleSystem = llm.RoleSystem
|
||||
@@ -106,6 +119,10 @@ func WithPromptCaching() Option { return llm.WithPro
|
||||
// calls made through this package.
|
||||
func WithModelCapabilities(caps Capabilities) ModelOption { return llm.WithCapabilities(caps) }
|
||||
|
||||
// Re-exported image-generation request options (see the imagegen package).
|
||||
func WithImageCount(n int) ImageOption { return imagegen.WithN(n) }
|
||||
func WithImageSize(s string) ImageOption { return imagegen.WithSize(s) }
|
||||
|
||||
// Classify re-exports llm.Classify.
|
||||
func Classify(err error) ErrorClass { return llm.Classify(err) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user