Documentation
¶
Overview ¶
Package generic provides a generic OpenAI-compatible backend for custom providers.
Index ¶
- type Adapter
- func (a *Adapter) Complete(ctx context.Context, creds []*models.Credential, ...) (*models.ChatCompletionResponse, error)
- func (a *Adapter) CompleteStream(ctx context.Context, creds []*models.Credential, ...) error
- func (a *Adapter) GetModelInfos(ctx context.Context, cred *models.Credential, providerConfig map[string]any) ([]models.ModelInfo, error)
- func (a *Adapter) NeedsRefresh(cred *models.Credential) bool
- func (a *Adapter) RefreshCredential(ctx context.Context, cred *models.Credential) (map[string]any, error)
- func (a *Adapter) SetLogger(l *slog.Logger)
- func (a *Adapter) SetUsageTracker(t UsageTracker)
- func (a *Adapter) TypeKey() string
- func (a *Adapter) ValidateCredentials(data map[string]any) error
- type Client
- func (c *Client) ChatCompletion(ctx context.Context, apiKey string, modelName string, ...) (*models.ChatCompletionResponse, error)
- func (c *Client) ChatCompletionStream(ctx context.Context, apiKey string, modelName string, ...) error
- func (c *Client) ListModels(ctx context.Context, apiKey string) ([]models.ModelInfo, error)
- type UsageTracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements the generic OpenAI-compatible backend for "custom" providers.
func (*Adapter) Complete ¶
func (a *Adapter) Complete( ctx context.Context, creds []*models.Credential, req *models.ChatCompletionRequest, providerConfig map[string]any, ) (*models.ChatCompletionResponse, error)
func (*Adapter) CompleteStream ¶
func (*Adapter) GetModelInfos ¶
func (*Adapter) NeedsRefresh ¶
func (a *Adapter) NeedsRefresh(cred *models.Credential) bool
func (*Adapter) RefreshCredential ¶
func (*Adapter) SetLogger ¶ added in v0.1.2
SetLogger wires the logger for pool failover lines. Unset falls back to slog.Default inside the pool.
func (*Adapter) SetUsageTracker ¶ added in v0.0.6
func (a *Adapter) SetUsageTracker(t UsageTracker)
SetUsageTracker wires per-credential usage accounting for pool calls. Unset (nil) disables accounting; attempts still run.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps HTTP requests to an OpenAI-compatible endpoint.
func (*Client) ChatCompletion ¶
func (c *Client) ChatCompletion( ctx context.Context, apiKey string, modelName string, req *models.ChatCompletionRequest, ) (*models.ChatCompletionResponse, error)
ChatCompletion sends a non-streaming chat completion request.
type UsageTracker ¶ added in v0.0.6
type UsageTracker = pool.UsageTracker
UsageTracker records per-credential outcomes. It is implemented by the credential pool service and injected via SetUsageTracker.