Documentation
¶
Index ¶
- type BalanceInterface
- type BalanceResponse
- type BaseHandler
- type BaseProvider
- func (p *BaseProvider) CommonRequestHeaders(headers map[string]string)
- func (p *BaseProvider) CustomParameterHandler() (map[string]interface{}, error)
- func (p *BaseProvider) GetAPIUri(relayMode int) string
- func (p *BaseProvider) GetBaseURL() string
- func (p *BaseProvider) GetChannel() *model.Channel
- func (p *BaseProvider) GetFullRequestURL(requestURL string, _ string) string
- func (p *BaseProvider) GetOriginalModel() string
- func (p *BaseProvider) GetOtherArg() string
- func (p *BaseProvider) GetRawBody() ([]byte, bool)
- func (p *BaseProvider) GetRequester() *requester.HTTPRequester
- func (p *BaseProvider) GetSupportedAPIUri(relayMode int) (url string, err *types.OpenAIErrorWithStatusCode)
- func (p *BaseProvider) GetSupportedResponse() bool
- func (p *BaseProvider) GetUsage() *types.Usage
- func (p *BaseProvider) ModelMappingHandler(modelName string) (string, error)
- func (p *BaseProvider) SetContext(c *gin.Context)
- func (p *BaseProvider) SetOriginalModel(ModelName string)
- func (p *BaseProvider) SetOtherArg(otherArg string)
- func (p *BaseProvider) SetUsage(usage *types.Usage)
- type ChatInterface
- type CompletionInterface
- type EmbeddingsInterface
- type ImageEditsInterface
- type ImageGenerationsInterface
- type ImageVariationsInterface
- type ModelListInterface
- type ModerationInterface
- type ProviderConfig
- type ProviderInterface
- type RealtimeInterface
- type Requestable
- type RerankInterface
- type ResponsesInterface
- type SpeechInterface
- type TranscriptionsInterface
- type TranslationInterface
- type VideoInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BalanceResponse ¶
type BaseHandler ¶
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) 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 ChatInterface interface {
ProviderInterface
CreateChatCompletion(request *types.ChatCompletionRequest) (*types.ChatCompletionResponse, *types.OpenAIErrorWithStatusCode)
CreateChatCompletionStream(request *types.ChatCompletionRequest) (requester.StreamReaderInterface[string], *types.OpenAIErrorWithStatusCode)
}
聊天接口
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 Requestable ¶
type Requestable interface {
types.CompletionRequest | types.ChatCompletionRequest | types.EmbeddingRequest | types.ModerationRequest | types.SpeechAudioRequest | types.AudioRequest | types.ImageRequest | types.ImageEditRequest | types.VideoRequest
}
type RerankInterface ¶
type RerankInterface interface {
ProviderInterface
CreateRerank(request *types.RerankRequest) (*types.RerankResponse, *types.OpenAIErrorWithStatusCode)
}
Rerank接口
type ResponsesInterface ¶
type ResponsesInterface interface {
ProviderInterface
CreateResponses(request *types.OpenAIResponsesRequest) (*types.OpenAIResponsesResponses, *types.OpenAIErrorWithStatusCode)
CreateResponsesStream(request *types.OpenAIResponsesRequest) (requester.StreamReaderInterface[string], *types.OpenAIErrorWithStatusCode)
}
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)
}
Click to show internal directories.
Click to hide internal directories.