provider

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package provider documents the AFI gateway ChatProvider contract for multi-model extensibility.

Built-in adapters live in github.com/curefatih/afi/internal/dataplane and register into a Registry used by the gateway pipeline. Out-of-tree adapters implement ChatProvider in this package (or a module that imports it), then register at process startup via dataplane.Registry.RegisterSDK — see github.com/curefatih/afi/extensions/echo for a working example.

ChatProvider speaks typed chat IR (sdk/chatir).

Process-isolated gRPC providers are supported via github.com/curefatih/afi/internal/adapters/grpcprovider and proto/afi/extension/v1 (see extensions/grpcecho). WASM is for lifecycle hooks (docs/development/hooks/wasm.md), not ChatProvider adapters. See docs/development/providers.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	Chat      bool `json:"chat"`
	Stream    bool `json:"stream"`
	TTS       bool `json:"tts"`
	STT       bool `json:"stt"`
	Embedding bool `json:"embedding"`
}

Capabilities describes what an adapter supports on the gateway surface.

type ChatProvider

type ChatProvider interface {
	Type() string
	Capabilities() Capabilities
	ChatIR(ctx context.Context, cfg ProviderConfig, targetModel string, req chatir.Request) (chatir.Result, error)
}

ChatProvider is the in-process adapter contract for out-of-tree extensions.

Example wiring (gateway bootstrap):

reg := dataplane.DefaultRegistry()
reg.RegisterSDK(echo.New())
pipeline := dataplane.NewPipelineWithRegistry(holder, reg, log)

type ExampleAdapter

type ExampleAdapter struct{}

ExampleAdapter is a documentation stub showing the shape of a custom adapter. Prefer the working extensions/echo package for a real registration example.

func (ExampleAdapter) Capabilities

func (ExampleAdapter) Capabilities() Capabilities

func (ExampleAdapter) ChatIR

func (ExampleAdapter) ChatIR(ctx context.Context, cfg ProviderConfig, targetModel string, req chatir.Request) (chatir.Result, error)

func (ExampleAdapter) Type

func (ExampleAdapter) Type() string

type ProviderConfig

type ProviderConfig struct {
	ID           string
	Type         string
	BaseURL      string
	APIKeyEnv    string
	Name         string
	Capabilities Capabilities
}

ProviderConfig is the snapshot view passed into ChatIR (IDs, base URL, key env). Mirrors internal/snapshot.Provider fields needed by adapters.

func ConfigFromFields

func ConfigFromFields(id, typ, name, baseURL, apiKeyEnv string, caps Capabilities) ProviderConfig

ConfigFromFields builds a ProviderConfig from discrete snapshot-like fields.

Jump to

Keyboard shortcuts

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