adapters

package
v0.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package adapters names the wire protocol the relay speaks to an upstream.

One Name corresponds to one `app/api/<name>` package (Relay-side glue) and one `pkg/api/<name>` package (pure, vendorable shape parsers). Hosts can serve models that speak different adapters — e.g. AWS Bedrock hosts Claude (Anthropic) and Llama (OpenAI-shape). The dispatch key therefore lives on the per-Model HostBinding, not on the Host itself.

Capabilities (streaming, vision, function-calling, etc.) live on Model.Spec.Capabilities; an adapter's job is wire format, not feature negotiation. A future "adapter framework" may bundle capability expectations per adapter Name, but today the two concerns are separate.

Index

Constants

View Source
const DefaultBinding = OpenAI

DefaultBinding is the adapter assumed when a HostBinding omits one.

Variables

This section is empty.

Functions

This section is empty.

Types

type Name

type Name string

Name is the wire-protocol name.

const (
	// OpenAI: the OpenAI Chat Completions and Models shape. Also used for
	// Ollama, Together, Groq, Fireworks, Azure OpenAI, and any vendor
	// fronting an OpenAI-compatible endpoint.
	OpenAI Name = "openai"

	// Anthropic: the Anthropic Messages shape. Also used for Anthropic via
	// AWS Bedrock (Claude on Bedrock keeps the Anthropic shape) and via
	// GCP Vertex.
	Anthropic Name = "anthropic"

	// Gemini: the Google Gemini native shape (POST /v1beta/models/{model}:
	// generateContent). Unique among registered shapes: the upstream model
	// name and the sync/stream choice live in the URL path, not the request
	// body, so the Spec resolves its upstream path per request via
	// UpstreamPathFn. Also used for Gemini via GCP Vertex.
	Gemini Name = "gemini"

	// OpenAIResponses is the OpenAI Responses API shape (POST /v1/responses).
	// Distinct from OpenAI (Chat Completions) because the upstream path differs.
	// Phase 1: byte-passthrough only; no cross-shape translation.
	OpenAIResponses Name = "openai_responses"

	// OpenAIEmbeddings is the OpenAI Embeddings API shape (POST /v1/embeddings).
	// Distinct from OpenAI (Chat Completions) because the upstream path differs.
	// Supported by any OpenAI-compatible host (Voyage, Together, Fireworks,
	// Cohere compat, etc.). Phase 1: byte-passthrough only.
	OpenAIEmbeddings Name = "openai_embeddings"

	// Canonical is relay's own wire shape (pkg/relay/v1), served at /v1/*.
	// It is an inbound-only shape: callers POST canonical and relay routes,
	// translates canonical→upstream-vendor, and returns canonical. There is
	// no canonical upstream, so it never appears as a HostBinding.Adapter.
	Canonical Name = "canonical"
)

func All

func All() []Name

All returns every supported Name. Stable order: useful for tests and CLI flag help text. Order does not imply preference.

func UpstreamBindingNames

func UpstreamBindingNames() []Name

UpstreamBindingNames returns every Name valid as a HostBinding.Adapter, in stable order. The single source of truth behind UpstreamBinding.

func (Name) UpstreamBinding

func (n Name) UpstreamBinding() bool

UpstreamBinding reports whether n may appear as a HostBinding.Adapter — i.e. it names an upstream wire shape relay can dispatch a request to. The inbound-only shapes are excluded: Canonical has no upstream, and OpenAIResponses/OpenAIEmbeddings are inbound request variants dispatched via their own specs (their bindings carry the base OpenAI adapter). This is the authoritative allow-set for HostBinding.Adapter; the catalog validator and model.Validate both gate on it, and the composition root's registry assertion guarantees each one has a registered spec.

func (Name) Valid

func (n Name) Valid() bool

Valid reports whether n is one of the supported adapter names.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL