Documentation
¶
Overview ¶
Package generic provides a generic OpenAI-compatible backend for custom providers.
Index ¶
- type Adapter
- func (a *Adapter) Complete(ctx context.Context, cred *models.Credential, ...) (*models.ChatCompletionResponse, error)
- func (a *Adapter) CompleteStream(ctx context.Context, cred *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) 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)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct{}
Adapter implements the generic OpenAI-compatible backend for "custom" providers.
func (*Adapter) Complete ¶
func (a *Adapter) Complete( ctx context.Context, cred *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 ¶
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.
Click to show internal directories.
Click to hide internal directories.