Documentation
¶
Index ¶
- func AfterHandler(ctx context.Context, mak *MAK, after *mcommon.AfterHandler)
- func BeforeHandler(ctx context.Context, before *mcommon.BeforeHandler)
- func Billing(ctx context.Context, mak *MAK, billingData *common.BillingData, ...) (spend common.Spend)
- func CheckIp(ctx context.Context, ipWhitelist, ipBlacklist []string) error
- func ConvChatCompletionsToResponsesRequest(ctx context.Context, body []byte) smodel.OpenAIResponsesReq
- func ConvQuota(quota int, n ...int) float64
- func ConvResponsesStreamToChatCompletionsResponse(ctx context.Context, res smodel.OpenAIResponsesStreamRes) smodel.ChatCompletionResponse
- func ConvResponsesToChatCompletionsRequest(request *ghttp.Request, isChatCompletions bool) smodel.ChatCompletionRequest
- func ConvResponsesToChatCompletionsResponse(ctx context.Context, res smodel.OpenAIResponsesRes) smodel.ChatCompletionResponse
- func GetProviderCode(ctx context.Context, providerId string) string
- func HandleMessages(messages []smodel.ChatCompletionMessage) []smodel.ChatCompletionMessage
- func IsAborted(err error) bool
- func IsMaxRetry(isEnableModelAgent bool, agentTotal, keyTotal, retry int) bool
- func IsNeedRetry(err error) (isRetry bool, isDisabled bool)
- func New() service.ICommon
- func NewAdapter(ctx context.Context, mak *MAK, isLong bool) (adapter sdk.Adapter)
- func NewAdapterOfficial(ctx context.Context, mak *MAK, isLong bool) (adapter sdk.AdapterOfficial)
- func NewAdapterOpenAI(ctx context.Context, mak *MAK, isLong bool) *openai.OpenAI
- func NewConverter(ctx context.Context, provider string) sdk.Converter
- func NewModerationClient(ctx context.Context, model *model.Model, key, baseUrl, path string) *sdk.ModerationClient
- func NewRealtimeClient(ctx context.Context, model *model.Model, key, baseUrl, path string) *sdk.RealtimeClient
- func RecordSpend(ctx context.Context, spend common.Spend, mak *MAK) error
- func TokensFromMessages(ctx context.Context, model string, messages []smodel.ChatCompletionMessage) int
- func TokensFromString(ctx context.Context, model, text string) int
- type ApplicationDefaultCredentials
- type MAK
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterHandler ¶
func AfterHandler(ctx context.Context, mak *MAK, after *mcommon.AfterHandler)
后置处理器
func Billing ¶
func Billing(ctx context.Context, mak *MAK, billingData *common.BillingData, billingItems ...string) (spend common.Spend)
计算花费
func ConvChatCompletionsToResponsesRequest ¶
func ConvChatCompletionsToResponsesRequest(ctx context.Context, body []byte) smodel.OpenAIResponsesReq
func ConvResponsesStreamToChatCompletionsResponse ¶
func ConvResponsesStreamToChatCompletionsResponse(ctx context.Context, res smodel.OpenAIResponsesStreamRes) smodel.ChatCompletionResponse
func ConvResponsesToChatCompletionsRequest ¶
func ConvResponsesToChatCompletionsRequest(request *ghttp.Request, isChatCompletions bool) smodel.ChatCompletionRequest
func ConvResponsesToChatCompletionsResponse ¶
func ConvResponsesToChatCompletionsResponse(ctx context.Context, res smodel.OpenAIResponsesRes) smodel.ChatCompletionResponse
func HandleMessages ¶
func HandleMessages(messages []smodel.ChatCompletionMessage) []smodel.ChatCompletionMessage
func IsMaxRetry ¶
func IsNeedRetry ¶
func NewAdapterOfficial ¶
func NewAdapterOpenAI ¶
func NewConverter ¶
func NewModerationClient ¶
func NewRealtimeClient ¶
func TokensFromMessages ¶
Types ¶
type ApplicationDefaultCredentials ¶
type ApplicationDefaultCredentials struct {
Type string `json:"type"`
ProjectId string `json:"project_id"`
PrivateKeyId string `json:"private_key_id"`
PrivateKey string `json:"private_key"`
ClientEmail string `json:"client_email"`
ClientId string `json:"client_id"`
AuthUri string `json:"auth_uri"`
TokenUri string `json:"token_uri"`
AuthProviderX509CertUrl string `json:"auth_provider_x509_cert_url"`
ClientX509CertUrl string `json:"client_x509_cert_url"`
UniverseDomain string `json:"universe_domain"`
}
type MAK ¶
type MAK struct {
Provider string
Model string
Messages []smodel.ChatCompletionMessage
ReqModel *model.Model
RealModel *model.Model
ModelAgent *model.ModelAgent
Key *model.Key
FallbackModelAgent *model.ModelAgent
FallbackModel *model.Model
AgentTotal int
KeyTotal int
RealKey string
BaseUrl string
Path string
User *model.User
App *model.App
AppKey *model.AppKey
Group *model.Group
}
Click to show internal directories.
Click to hide internal directories.