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) PollVideo(ctx context.Context, creds []*models.Credential, model models.ModelId, ...) (*models.VideoGenerationResponse, error)
- func (a *Adapter) RefreshCredential(ctx context.Context, cred *models.Credential) (map[string]any, error)
- func (a *Adapter) SetLogger(l *slog.Logger)
- func (a *Adapter) SubmitVideo(ctx context.Context, creds []*models.Credential, ...) (*models.VideoGenerationResponse, error)
- func (a *Adapter) TypeKey() string
- func (a *Adapter) ValidateCredentials(data map[string]any) error
- func (a *Adapter) VideoContent(ctx context.Context, creds []*models.Credential, model models.ModelId, ...) (*models.VideoContentResponse, 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)
- func (c *Client) ListVideoModels(ctx context.Context, apiKey string) ([]models.VideoModel, error)
- func (c *Client) PollVideo(ctx context.Context, apiKey, upstreamJobID string) (*models.VideoGenerationResponse, error)
- func (c *Client) SubmitVideo(ctx context.Context, apiKey, modelName string, ...) (*models.VideoGenerationResponse, error)
- func (c *Client) VideoContent(ctx context.Context, apiKey, upstreamJobID string, index int) (*models.VideoContentResponse, error)
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) PollVideo ¶ added in v0.3.8
func (a *Adapter) PollVideo( ctx context.Context, creds []*models.Credential, model models.ModelId, upstreamJobID string, providerConfig map[string]any, ) (*models.VideoGenerationResponse, error)
PollVideo routes one video status poll over the credential pool.
func (*Adapter) RefreshCredential ¶
func (*Adapter) SubmitVideo ¶ added in v0.3.8
func (a *Adapter) SubmitVideo( ctx context.Context, creds []*models.Credential, req *models.VideoGenerationRequest, providerConfig map[string]any, ) (*models.VideoGenerationResponse, error)
SubmitVideo routes one video generation submit over the credential pool.
func (*Adapter) ValidateCredentials ¶
func (*Adapter) VideoContent ¶ added in v0.3.8
func (a *Adapter) VideoContent( ctx context.Context, creds []*models.Credential, model models.ModelId, upstreamJobID string, index int, providerConfig map[string]any, ) (*models.VideoContentResponse, error)
VideoContent routes one video asset download over the credential pool.
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.
func (*Client) ChatCompletionStream ¶
func (c *Client) ChatCompletionStream( ctx context.Context, apiKey string, modelName string, req *models.ChatCompletionRequest, w io.Writer, ) error
ChatCompletionStream sends a streaming chat completion request.
func (*Client) ListModels ¶
ListModels fetches the available models from the provider. Tolerant of compat variances: 404 is not an error (routing still works), extra fields like object/limit are ignored.
func (*Client) ListVideoModels ¶ added in v0.3.8
ListVideoModels fetches the upstream video model catalog. A 404 is not an error: upstreams without a video catalog still route video jobs.
func (*Client) PollVideo ¶ added in v0.3.8
func (c *Client) PollVideo(ctx context.Context, apiKey, upstreamJobID string) (*models.VideoGenerationResponse, error)
PollVideo fetches one upstream video job status.
func (*Client) SubmitVideo ¶ added in v0.3.8
func (c *Client) SubmitVideo(ctx context.Context, apiKey, modelName string, req *models.VideoGenerationRequest) (*models.VideoGenerationResponse, error)
SubmitVideo posts one video generation request to the upstream.
func (*Client) VideoContent ¶ added in v0.3.8
func (c *Client) VideoContent(ctx context.Context, apiKey, upstreamJobID string, index int) (*models.VideoContentResponse, error)
VideoContent downloads one upstream video asset.