virtual

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package virtual implements the virtual-model provider backend: a virtual model routes each request to its models in list order (fall-through) and fails only when every model failed.

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 provider.GoAdapter interface for virtual models.

func New added in v0.1.2

func New(completer provider.Completer, virtualService *virtual.GormService, logger *slog.Logger) *Adapter

New constructs an Adapter with all dependencies. The router dependency enters as the narrow provider.Completer port, so construction order is explicit and no setter injection is needed.

func (*Adapter) Complete

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

func (*Adapter) GetModelInfos

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

func (*Adapter) NeedsRefresh

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

func (*Adapter) RefreshCredential

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

func (*Adapter) SubmitVideo added in v0.3.8

SubmitVideo fans one video generation submit out over the member queue (healthy members first, exhausted members last). The first success wins and its router-side job row (keyed by the winning member model) is returned as-is: later polls authorize against that member model and route to it directly. Otherwise the last error is returned as-is.

func (*Adapter) TypeKey

func (a *Adapter) TypeKey() string

func (*Adapter) ValidateCredentials

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

Jump to

Keyboard shortcuts

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