Help us shape the future of Go! Take the 2026 Go Developer Survey

provider

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: EUPL-1.2 Imports: 13 Imported by: 0

Documentation

Overview

Package provider talks to LLM backends over HTTP.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAuth means the provider rejected the credentials (401, 403).
	ErrAuth = errors.New("authentification refusée par le fournisseur")
	// ErrContextLength means the prompt exceeds the model context window.
	ErrContextLength = errors.New("contexte trop long pour le modèle")
	// ErrIncomplete means the stream ended without a completion marker.
	ErrIncomplete = errors.New("flux interrompu avant la fin de la réponse")
	// ErrUnavailable means the provider stayed unreachable after retries.
	ErrUnavailable = errors.New("fournisseur indisponible")
)

Functions

This section is empty.

Types

type OpenAICompat

type OpenAICompat struct {
	// contains filtered or unexported fields
}

OpenAICompat implements Provider for OpenAI-compatible chat completions.

func NewOpenAICompat

func NewOpenAICompat(info llm.ProviderInfo, apiKey string, opts ...Option) *OpenAICompat

NewOpenAICompat builds a provider for info.BaseURL.

func (*OpenAICompat) Info

func (o *OpenAICompat) Info() llm.ProviderInfo

Info returns the provider description.

func (*OpenAICompat) Stream

func (o *OpenAICompat) Stream(ctx context.Context, req llm.Request) (<-chan llm.Chunk, error)

Stream starts a streamed completion.

type Option

type Option func(*OpenAICompat)

Option configures an OpenAICompat provider.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets the HTTP client.

func WithSleep

func WithSleep(f func(context.Context, time.Duration) error) Option

WithSleep overrides the wait function used between retries. It must return ctx.Err() as soon as ctx is cancelled.

type Provider

type Provider interface {
	Info() llm.ProviderInfo
	Stream(ctx context.Context, req llm.Request) (<-chan llm.Chunk, error)
}

Provider streams completions from an LLM backend.

Jump to

Keyboard shortcuts

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