llm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anthropic

type Anthropic struct {
	APIKey string
	Model  string
	Client *http.Client
}

func NewAnthropic

func NewAnthropic(apiKey, model string) *Anthropic

func (*Anthropic) Complete

func (a *Anthropic) Complete(ctx context.Context, req Request) (string, error)

func (*Anthropic) Name

func (a *Anthropic) Name() string

type Client

type Client interface {
	Complete(ctx context.Context, req Request) (string, error)
	Name() string
}

Client is one text-in/text-out LLM provider.

type Fallback

type Fallback struct {
	Clients []Client
}

Fallback tries clients in order, returning the first success. It's itself a Client, so callers can't tell a single provider from a chain. Every provider's error is aggregated so a total failure explains what each one said.

func NewFallback

func NewFallback(clients ...Client) *Fallback

func (*Fallback) Complete

func (f *Fallback) Complete(ctx context.Context, req Request) (string, error)

func (*Fallback) Name

func (f *Fallback) Name() string

type OpenAI

type OpenAI struct {
	APIKey string
	Model  string
	Client *http.Client
}

func NewOpenAI

func NewOpenAI(apiKey, model string) *OpenAI

func (*OpenAI) Complete

func (o *OpenAI) Complete(ctx context.Context, req Request) (string, error)

func (*OpenAI) Name

func (o *OpenAI) Name() string

type Request

type Request struct {
	System    string
	Prompt    string
	MaxTokens int
}

Request is a provider-neutral completion request. No vendor types.

Jump to

Keyboard shortcuts

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