relay

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AvailableModel

func AvailableModel(c *gin.Context)

func ChatRealtime

func ChatRealtime(c *gin.Context)

func CountGeminiTokenMessages

func CountGeminiTokenMessages(request *gemini.GeminiChatRequest, preCostType int) (int, error)

func CountTokenMessages

func CountTokenMessages(request *claude.ClaudeRequest, preCostType int) (int, error)

func FilterOpenAIErr

func FilterOpenAIErr(c *gin.Context, err *types.OpenAIErrorWithStatusCode) (errWithStatusCode types.OpenAIErrorWithStatusCode)

func GetAvailableModels

func GetAvailableModels(groupName string) map[string]*AvailableModelResponse

func GetModelOwnedBy

func GetModelOwnedBy(c *gin.Context)

func GetProvider

func GetProvider(c *gin.Context, modelName string) (provider providersBase.ProviderInterface, newModelName string, fail error)

func ListClaudeModelsByToken

func ListClaudeModelsByToken(c *gin.Context)

func ListModelsByToken

func ListModelsByToken(c *gin.Context)

func ListModelsForAdmin

func ListModelsForAdmin(c *gin.Context)

func NewRelayChat

func NewRelayChat(c *gin.Context) *relayChat

func NewRelayClaudeOnly

func NewRelayClaudeOnly(c *gin.Context) *relayClaudeOnly

func NewRelayCompletions

func NewRelayCompletions(c *gin.Context) *relayCompletions

func NewRelayEmbeddings

func NewRelayEmbeddings(c *gin.Context) *relayEmbeddings

func NewRelayGeminiOnly

func NewRelayGeminiOnly(c *gin.Context) *relayGeminiOnly

func NewRelayImageEdits

func NewRelayImageEdits(c *gin.Context) *relayImageEdits

func NewRelayImageGenerations

func NewRelayImageGenerations(c *gin.Context) *relayImageGenerations

func NewRelayImageVariations

func NewRelayImageVariations(c *gin.Context) *relayImageVariations

func NewRelayModerations

func NewRelayModerations(c *gin.Context) *relayModerations

func NewRelayRerank

func NewRelayRerank(c *gin.Context) *relayRerank

func NewRelayResponses

func NewRelayResponses(c *gin.Context) *relayResponses

func NewRelaySpeech

func NewRelaySpeech(c *gin.Context) *relaySpeech

func NewRelayTranscriptions

func NewRelayTranscriptions(c *gin.Context) *relayTranscriptions

func NewRelayTranslations

func NewRelayTranslations(c *gin.Context) *relayTranslations

func Path2RecraftAIModel

func Path2RecraftAIModel(path string) string

func Relay

func Relay(c *gin.Context)

func RelayHandler

func RelayHandler(relay RelayBaseInterface) (err *types.OpenAIErrorWithStatusCode, done bool)

func RelayOnly

func RelayOnly(c *gin.Context)

func RelayRecraftAI

func RelayRecraftAI(c *gin.Context)

func RelayRerank

func RelayRerank(c *gin.Context)

func RetrieveModel

func RetrieveModel(c *gin.Context)

Types

type AvailableModelResponse

type AvailableModelResponse struct {
	Groups  []string     `json:"groups"`
	OwnedBy string       `json:"owned_by"`
	Price   *model.Price `json:"price"`
}

type GroupManager

type GroupManager struct {
	// contains filtered or unexported fields
}

GroupManager 统一管理分组逻辑

func NewGroupManager

func NewGroupManager(c *gin.Context) *GroupManager

NewGroupManager 创建分组管理器

func (*GroupManager) TryWithGroups

func (gm *GroupManager) TryWithGroups(modelName string, filters []model.ChannelsFilterFunc, operation func(group string) (*model.Channel, error)) (*model.Channel, error)

TryWithGroups 尝试使用主分组和备用分组

type ModelPrice

type ModelPrice struct {
	Type   string  `json:"type"`
	Input  float64 `json:"input"`
	Output float64 `json:"output"`
}

type OpenAIModels

type OpenAIModels struct {
	Id      string  `json:"id"`
	Object  string  `json:"object"`
	Created int     `json:"created"`
	OwnedBy *string `json:"owned_by"`
}

https://platform.openai.com/docs/api-reference/models/list

type RelayBaseInterface

type RelayBaseInterface interface {
	IsStream() bool
	// HandleError(err *types.OpenAIErrorWithStatusCode)
	GetFirstResponseTime() time.Time

	HandleJsonError(err *types.OpenAIErrorWithStatusCode)
	HandleStreamError(err *types.OpenAIErrorWithStatusCode)
	SetHeartbeat(isStream bool) *relay_util.Heartbeat
	// contains filtered or unexported methods
}

func Path2Relay

func Path2Relay(c *gin.Context, path string) RelayBaseInterface

type RelayModeChatRealtime

type RelayModeChatRealtime struct {
	// contains filtered or unexported fields
}

func (*RelayModeChatRealtime) GetError

func (r *RelayModeChatRealtime) GetError(err *types.OpenAIErrorWithStatusCode) (int, any)

func (*RelayModeChatRealtime) GetFirstResponseTime

func (r *RelayModeChatRealtime) GetFirstResponseTime() time.Time

func (*RelayModeChatRealtime) HandleJsonError

func (r *RelayModeChatRealtime) HandleJsonError(err *types.OpenAIErrorWithStatusCode)

func (*RelayModeChatRealtime) HandleStreamError

func (r *RelayModeChatRealtime) HandleStreamError(err *types.OpenAIErrorWithStatusCode)

func (*RelayModeChatRealtime) IsStream

func (r *RelayModeChatRealtime) IsStream() bool

func (*RelayModeChatRealtime) SetFirstResponseTime

func (r *RelayModeChatRealtime) SetFirstResponseTime(firstResponseTime time.Time)

func (*RelayModeChatRealtime) SetHeartbeat

func (r *RelayModeChatRealtime) SetHeartbeat(isStream bool) *relay_util.Heartbeat

type StreamEndHandler

type StreamEndHandler func() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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