Documentation
¶
Index ¶
- func CheckInsecureAPIKey(rawURL, apiKey string) error
- func IsConnectionError(err error) bool
- type Backend
- type Config
- type Custom
- func (c *Custom) Complete(ctx context.Context, req *Request) (*Response, error)
- func (c *Custom) Health(ctx context.Context) error
- func (c *Custom) ListModels(ctx context.Context) ([]string, error)
- func (c *Custom) Name() string
- func (c *Custom) Stream(ctx context.Context, req *Request, ...) (*Response, error)
- func (c *Custom) URL() string
- type LMStudio
- func (l *LMStudio) Complete(ctx context.Context, req *Request) (*Response, error)
- func (l *LMStudio) Health(ctx context.Context) error
- func (l *LMStudio) ListModels(ctx context.Context) ([]string, error)
- func (l *LMStudio) Name() string
- func (l *LMStudio) Stream(ctx context.Context, req *Request, ...) (*Response, error)
- func (l *LMStudio) URL() string
- type LlamaCpp
- func (l *LlamaCpp) Complete(ctx context.Context, req *Request) (*Response, error)
- func (l *LlamaCpp) Health(ctx context.Context) error
- func (l *LlamaCpp) ListModels(ctx context.Context) ([]string, error)
- func (l *LlamaCpp) Name() string
- func (l *LlamaCpp) Stream(ctx context.Context, req *Request, ...) (*Response, error)
- func (l *LlamaCpp) URL() string
- type Ollama
- func (o *Ollama) Complete(ctx context.Context, req *Request) (*Response, error)
- func (o *Ollama) Health(ctx context.Context) error
- func (o *Ollama) ListModels(ctx context.Context) ([]string, error)
- func (o *Ollama) Name() string
- func (o *Ollama) Stream(ctx context.Context, req *Request, ...) (*Response, error)
- func (o *Ollama) URL() string
- type Request
- type Response
- type VLLM
- func (v *VLLM) Complete(ctx context.Context, req *Request) (*Response, error)
- func (v *VLLM) Health(ctx context.Context) error
- func (v *VLLM) ListModels(ctx context.Context) ([]string, error)
- func (v *VLLM) Name() string
- func (v *VLLM) Stream(ctx context.Context, req *Request, ...) (*Response, error)
- func (v *VLLM) URL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckInsecureAPIKey ¶
CheckInsecureAPIKey returns an error if an API key is being sent over plain HTTP to a non-localhost host.
func IsConnectionError ¶ added in v0.4.1
IsConnectionError returns true if the error indicates the model server is unreachable (connection refused, timeout, no route, etc.).
Types ¶
type Backend ¶
type Backend interface {
// Name returns the backend type name
Name() string
// URL returns the backend endpoint URL
URL() string
// Complete sends a prompt and returns the full completion
Complete(ctx context.Context, req *Request) (*Response, error)
// Stream sends a prompt and streams tokens via the callback
Stream(ctx context.Context, req *Request, callback func(token string, done bool) error) (*Response, error)
// Health checks if the backend is available
Health(ctx context.Context) error
// ListModels returns the models available on the backend.
// Returns nil, nil if the backend does not support listing.
ListModels(ctx context.Context) ([]string, error)
}
Backend defines the interface for LLM inference backends
type Config ¶
type Config struct {
Type string // "ollama", "llamacpp", "vllm", "lmstudio", "custom"
URL string
Model string
APIKey string // for custom backends that need auth
}
Config holds backend configuration
type Custom ¶
type Custom struct {
// contains filtered or unexported fields
}
Custom implements the Backend interface for any HTTP endpoint that accepts a simple JSON request and returns a JSON response.
Expected request format:
{
"prompt": "...",
"max_tokens": 512,
"temperature": 0.7
}
Expected response format:
{
"text": "...",
"prompt_tokens": 10,
"completion_tokens": 100
}
func (*Custom) ListModels ¶ added in v0.4.5
ListModels is not supported for custom backends.
type LMStudio ¶ added in v0.4.12
type LMStudio struct {
// contains filtered or unexported fields
}
LMStudio implements the Backend interface for LM Studio (OpenAI-compatible API)
func NewLMStudio ¶ added in v0.4.12
NewLMStudio creates a new LM Studio backend
func (*LMStudio) Complete ¶ added in v0.4.12
Complete sends a prompt and returns the full completion
func (*LMStudio) ListModels ¶ added in v0.4.12
ListModels returns all models available in LM Studio.
type LlamaCpp ¶
type LlamaCpp struct {
// contains filtered or unexported fields
}
LlamaCpp implements the Backend interface for llama.cpp server
func NewLlamaCpp ¶
NewLlamaCpp creates a new llama.cpp backend
func (*LlamaCpp) ListModels ¶ added in v0.4.5
ListModels is not supported for llama.cpp (single-model server).
type Ollama ¶
type Ollama struct {
// contains filtered or unexported fields
}
Ollama implements the Backend interface for Ollama
func (*Ollama) ListModels ¶ added in v0.4.5
ListModels returns all models available in Ollama.
type VLLM ¶
type VLLM struct {
// contains filtered or unexported fields
}
VLLM implements the Backend interface for vLLM (OpenAI-compatible API)
func (*VLLM) ListModels ¶ added in v0.4.5
ListModels returns all models available in vLLM.