Documentation
¶
Overview ¶
Package translation serves surfaces a provider lacks by translating through llm-translate. Every conversion reports its losses. An Adapter checks them against a core.LossPolicy and returns all of them, including the losses the policy allows.
Index ¶
- type Adapter
- func (a Adapter) Invoke(ctx context.Context, request core.Request) (core.Response, error)
- func (a Adapter) ListModels(ctx context.Context, credential *core.Credential) ([]core.ModelInfo, error)
- func (a Adapter) NativeSurfaces(model string) []core.ModelSurface
- func (a Adapter) Stream(ctx context.Context, request core.Request) (core.StreamIter, error)
- func (a Adapter) Surfaces(model string) []core.ModelSurface
- func (a Adapter) Unwrap() core.Provider
- type ChatTranscriptionAdapter
- func (a ChatTranscriptionAdapter) Invoke(ctx context.Context, request core.Request) (core.Response, error)
- func (a ChatTranscriptionAdapter) ListModels(ctx context.Context, credential *core.Credential) ([]core.ModelInfo, error)
- func (a ChatTranscriptionAdapter) NativeSurfaces(model string) []core.ModelSurface
- func (a ChatTranscriptionAdapter) Stream(ctx context.Context, request core.Request) (core.StreamIter, error)
- func (a ChatTranscriptionAdapter) Surfaces(model string) []core.ModelSurface
- func (a ChatTranscriptionAdapter) Unwrap() core.Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
Provider core.Provider
Policy core.LossPolicy
}
Adapter wraps a provider and serves, besides its native surfaces, every surface llm-translate can convert to one of them:
- Messages over a Chat Completions provider, streaming included;
- Chat Completions over a Responses provider;
- Responses over a Chat Completions provider.
Losses the provider itself reports are merged into the same report. Request losses are checked before the provider is called, so a rejected translation never reaches it. Response losses of a stream are reported through core.LossReporter, not enforced, because their frames are already delivered.
func (Adapter) Invoke ¶
Invoke serves request natively when the provider can, and otherwise by translation.
func (Adapter) ListModels ¶
func (a Adapter) ListModels(ctx context.Context, credential *core.Credential) ([]core.ModelInfo, error)
ListModels delegates to the wrapped provider.
func (Adapter) NativeSurfaces ¶
func (a Adapter) NativeSurfaces(model string) []core.ModelSurface
NativeSurfaces reports the wrapped provider's native surfaces: translated surfaces are, by definition, not native.
func (Adapter) Stream ¶
Stream serves request natively when the provider can, and otherwise by translation on routes that stream. The returned stream implements core.LossReporter.
type ChatTranscriptionAdapter ¶ added in v1.2.0
type ChatTranscriptionAdapter struct {
Provider core.Provider
Enabled func(model string) bool
Instruction string
}
ChatTranscriptionAdapter serves the OpenAI audio_transcriptions surface by sending input_audio to a provider's native Chat Completions surface.
Enabled is mandatory and is evaluated for every model. A provider-level opt-in returns true for every model; a model-level opt-in names exact rows. No model-name inference is performed.
func (ChatTranscriptionAdapter) ListModels ¶ added in v1.2.0
func (a ChatTranscriptionAdapter) ListModels(ctx context.Context, credential *core.Credential) ([]core.ModelInfo, error)
ListModels adds the translated transcription surface only to exact rows the caller opted in. Other catalog rows remain unchanged.
func (ChatTranscriptionAdapter) NativeSurfaces ¶ added in v1.2.0
func (a ChatTranscriptionAdapter) NativeSurfaces(model string) []core.ModelSurface
func (ChatTranscriptionAdapter) Stream ¶ added in v1.2.0
func (a ChatTranscriptionAdapter) Stream(ctx context.Context, request core.Request) (core.StreamIter, error)
func (ChatTranscriptionAdapter) Surfaces ¶ added in v1.2.0
func (a ChatTranscriptionAdapter) Surfaces(model string) []core.ModelSurface
Surfaces reports translated transcription only for explicitly enabled models, after the wrapped provider's native surfaces.
func (ChatTranscriptionAdapter) Unwrap ¶ added in v1.2.0
func (a ChatTranscriptionAdapter) Unwrap() core.Provider