generic

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package generic provides a generic OpenAI-compatible backend for custom providers.

Index

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,
	credentials []*models.Credential,
	request *models.ChatCompletionRequest,
	providerConfig map[string]any,
) (*models.ChatCompletionResponse, error)

func (*Adapter) CompleteStream

func (a *Adapter) CompleteStream(
	ctx context.Context,
	credentials []*models.Credential,
	request *models.ChatCompletionRequest,
	writer io.Writer,
	providerConfig map[string]any,
) error

func (*Adapter) GetModelInfos

func (a *Adapter) GetModelInfos(
	ctx context.Context,
	credential *models.Credential,
	providerConfig map[string]any,
) ([]models.ModelInfo, error)

func (*Adapter) NeedsRefresh

func (a *Adapter) NeedsRefresh(credential *models.Credential) bool

func (*Adapter) PollVideo added in v0.3.8

func (a *Adapter) PollVideo(
	ctx context.Context,
	credentials []*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 (a *Adapter) RefreshCredential(ctx context.Context, credential *models.Credential) (map[string]any, error)

func (*Adapter) SetLogger added in v0.1.2

func (a *Adapter) SetLogger(l *slog.Logger)

SetLogger wires the logger for backend lines.

func (*Adapter) SubmitVideo added in v0.3.8

func (a *Adapter) SubmitVideo(
	ctx context.Context,
	credentials []*models.Credential,
	request *models.VideoGenerationRequest,
	providerConfig map[string]any,
) (*models.VideoGenerationResponse, error)

SubmitVideo routes one video generation submit over the credential pool.

func (*Adapter) TypeKey

func (a *Adapter) TypeKey() string

func (*Adapter) ValidateCredentials

func (a *Adapter) ValidateCredentials(data map[string]any) error

func (*Adapter) VideoContent added in v0.3.8

func (a *Adapter) VideoContent(
	ctx context.Context,
	credentials []*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,
	request *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,
	request *models.ChatCompletionRequest,
	writer io.Writer,
) error

ChatCompletionStream sends a streaming chat completion request.

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context, apiKey string) ([]models.ModelInfo, error)

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

func (c *Client) ListVideoModels(ctx context.Context, apiKey string) ([]models.VideoModel, error)

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) SetLogger added in v0.4.0

func (c *Client) SetLogger(logger *slog.Logger)

SetLogger installs structured client logging.

func (*Client) SubmitVideo added in v0.3.8

func (c *Client) SubmitVideo(ctx context.Context, apiKey, modelName string, request *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.

Jump to

Keyboard shortcuts

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