base

package
v0.5.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceInterface

type BalanceInterface interface {
	Balance() (float64, error)
}

余额接口

type BalanceResponse

type BalanceResponse struct {
	Object         string  `json:"object"`
	TotalGranted   float64 `json:"total_granted"`
	TotalUsed      float64 `json:"total_used"`
	TotalRemaining float64 `json:"total_remaining"`
	TotalAvailable float64 `json:"total_available"`
}

type BaseHandler

type BaseHandler struct {
	Usage *types.Usage
}

type BaseProvider

type BaseProvider struct {
	OriginalModel   string
	Usage           *types.Usage
	Config          ProviderConfig
	Context         *gin.Context
	Channel         *model.Channel
	Requester       *requester.HTTPRequester
	OtherArg        string
	SupportResponse bool
}

func (*BaseProvider) CommonRequestHeaders

func (p *BaseProvider) CommonRequestHeaders(headers map[string]string)

获取请求头

func (*BaseProvider) CustomParameterHandler

func (p *BaseProvider) CustomParameterHandler() (map[string]interface{}, error)

CustomParameterHandler processes extra parameters from the channel and returns them as a map

func (*BaseProvider) GetAPIUri

func (p *BaseProvider) GetAPIUri(relayMode int) string

func (*BaseProvider) GetBaseURL

func (p *BaseProvider) GetBaseURL() string

获取基础URL

func (*BaseProvider) GetChannel

func (p *BaseProvider) GetChannel() *model.Channel

func (*BaseProvider) GetFullRequestURL

func (p *BaseProvider) GetFullRequestURL(requestURL string, _ string) string

获取完整请求URL

func (*BaseProvider) GetOriginalModel

func (p *BaseProvider) GetOriginalModel() string

func (*BaseProvider) GetOtherArg

func (p *BaseProvider) GetOtherArg() string

func (*BaseProvider) GetRawBody

func (p *BaseProvider) GetRawBody() ([]byte, bool)

func (*BaseProvider) GetRequester

func (p *BaseProvider) GetRequester() *requester.HTTPRequester

func (*BaseProvider) GetSupportedAPIUri

func (p *BaseProvider) GetSupportedAPIUri(relayMode int) (url string, err *types.OpenAIErrorWithStatusCode)

func (*BaseProvider) GetSupportedResponse

func (p *BaseProvider) GetSupportedResponse() bool

func (*BaseProvider) GetUsage

func (p *BaseProvider) GetUsage() *types.Usage

func (*BaseProvider) ModelMappingHandler

func (p *BaseProvider) ModelMappingHandler(modelName string) (string, error)

func (*BaseProvider) SetContext

func (p *BaseProvider) SetContext(c *gin.Context)

func (*BaseProvider) SetOriginalModel

func (p *BaseProvider) SetOriginalModel(ModelName string)

func (*BaseProvider) SetOtherArg

func (p *BaseProvider) SetOtherArg(otherArg string)

func (*BaseProvider) SetUsage

func (p *BaseProvider) SetUsage(usage *types.Usage)

type ChatInterface

聊天接口

type CompletionInterface

type CompletionInterface interface {
	ProviderInterface
	CreateCompletion(request *types.CompletionRequest) (*types.CompletionResponse, *types.OpenAIErrorWithStatusCode)
	CreateCompletionStream(request *types.CompletionRequest) (requester.StreamReaderInterface[string], *types.OpenAIErrorWithStatusCode)
}

完成接口

type EmbeddingsInterface

type EmbeddingsInterface interface {
	ProviderInterface
	CreateEmbeddings(request *types.EmbeddingRequest) (*types.EmbeddingResponse, *types.OpenAIErrorWithStatusCode)
}

嵌入接口

type ImageEditsInterface

type ImageEditsInterface interface {
	ProviderInterface
	CreateImageEdits(request *types.ImageEditRequest) (*types.ImageResponse, *types.OpenAIErrorWithStatusCode)
}

图片编辑接口

type ImageGenerationsInterface

type ImageGenerationsInterface interface {
	ProviderInterface
	CreateImageGenerations(request *types.ImageRequest) (*types.ImageResponse, *types.OpenAIErrorWithStatusCode)
}

图片生成接口

type ImageVariationsInterface

type ImageVariationsInterface interface {
	ProviderInterface
	CreateImageVariations(request *types.ImageEditRequest) (*types.ImageResponse, *types.OpenAIErrorWithStatusCode)
}

type ModelListInterface

type ModelListInterface interface {
	ProviderInterface
	GetModelList() ([]string, error)
}

type ModerationInterface

type ModerationInterface interface {
	ProviderInterface
	CreateModeration(request *types.ModerationRequest) (*types.ModerationResponse, *types.OpenAIErrorWithStatusCode)
}

审查接口

type ProviderConfig

type ProviderConfig struct {
	BaseURL             string
	Completions         string
	ChatCompletions     string
	Embeddings          string
	AudioSpeech         string
	Moderation          string
	AudioTranscriptions string
	AudioTranslations   string
	ImagesGenerations   string
	ImagesEdit          string
	ImagesVariations    string
	Videos              string
	ModelList           string
	Rerank              string
	ChatRealtime        string
	Responses           string
}

func (*ProviderConfig) SetAPIUri

func (pc *ProviderConfig) SetAPIUri(customMapping map[string]interface{})

type ProviderInterface

type ProviderInterface interface {
	// 获取基础URL
	// GetBaseURL() string
	// 获取完整请求URL
	// GetFullRequestURL(requestURL string, modelName string) string
	// 获取请求头
	GetRequestHeaders() map[string]string
	// 获取用量
	GetUsage() *types.Usage
	// 设置用量
	SetUsage(usage *types.Usage)
	// 设置Context
	SetContext(c *gin.Context)
	// 设置原始模型
	SetOriginalModel(ModelName string)
	// 获取原始模型
	GetOriginalModel() string

	// SupportAPI(relayMode int) bool
	GetChannel() *model.Channel
	ModelMappingHandler(modelName string) (string, error)
	GetRequester() *requester.HTTPRequester
	SetOtherArg(otherArg string)
	GetOtherArg() string
	CustomParameterHandler() (map[string]interface{}, error)
	GetSupportedResponse() bool
}

基础接口

type RealtimeInterface

type RealtimeInterface interface {
	ProviderInterface
	CreateChatRealtime(modelName string) (*websocket.Conn, requester.MessageHandler, *types.OpenAIErrorWithStatusCode)
}

type RerankInterface

type RerankInterface interface {
	ProviderInterface
	CreateRerank(request *types.RerankRequest) (*types.RerankResponse, *types.OpenAIErrorWithStatusCode)
}

Rerank接口

type SpeechInterface

type SpeechInterface interface {
	ProviderInterface
	CreateSpeech(request *types.SpeechAudioRequest) (*http.Response, *types.OpenAIErrorWithStatusCode)
}

文字转语音接口

type TranscriptionsInterface

type TranscriptionsInterface interface {
	ProviderInterface
	CreateTranscriptions(request *types.AudioRequest) (*types.AudioResponseWrapper, *types.OpenAIErrorWithStatusCode)
}

语音转文字接口

type TranslationInterface

type TranslationInterface interface {
	ProviderInterface
	CreateTranslation(request *types.AudioRequest) (*types.AudioResponseWrapper, *types.OpenAIErrorWithStatusCode)
}

语音翻译接口

type VideoInterface

type VideoInterface interface {
	ProviderInterface
	CreateVideo(request *types.VideoRequest) (*types.VideoTaskObject, *types.OpenAIErrorWithStatusCode)
	GetVideo(taskID string) (*types.VideoTaskObject, *types.OpenAIErrorWithStatusCode)
	GetVideoContent(taskID string) (*http.Response, *types.OpenAIErrorWithStatusCode)
}

Jump to

Keyboard shortcuts

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