common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIp added in v0.5.0

func CheckIp(ctx context.Context, ipWhitelist, ipBlacklist []string) error

func GetCompletionTokens added in v0.5.0

func GetCompletionTokens(ctx context.Context, model, completion string) int

func GetCorpCode added in v0.3.0

func GetCorpCode(ctx context.Context, corpId string) string

func GetImageQuota added in v0.4.0

func GetImageQuota(model *model.Model, size string) (imageQuota mcommon.ImageQuota)

func GetMidjourneyQuota added in v0.4.0

func GetMidjourneyQuota(model *model.Model, request *ghttp.Request, path string) (mcommon.MidjourneyQuota, error)

func GetMultimodalAudioTokens added in v0.5.0

func GetMultimodalAudioTokens(ctx context.Context, model string, messages []sdkm.ChatCompletionMessage, reqModel *model.Model) (textTokens, audioTokens int)

func GetMultimodalTokens added in v0.4.0

func GetMultimodalTokens(ctx context.Context, model string, multiContent []interface{}, reqModel *model.Model) (textTokens, imageTokens int)

func GetPromptTokens added in v0.5.0

func GetPromptTokens(ctx context.Context, model string, messages []sdkm.ChatCompletionMessage) int

func HandleMessages added in v0.4.0

func HandleMessages(messages []sdkm.ChatCompletionMessage) []sdkm.ChatCompletionMessage

func IsAborted added in v0.3.0

func IsAborted(err error) bool

func IsMaxRetry added in v0.3.0

func IsMaxRetry(isEnableModelAgent bool, agentTotal, keyTotal, retry int) bool

func IsNeedRetry added in v0.3.0

func IsNeedRetry(err error) (isRetry bool, isDisabled bool)

func New

func New() service.ICommon

func NewClient added in v0.3.0

func NewClient(ctx context.Context, corp string, model *model.Model, key, baseURL, path string) (sdk.Client, error)

func NewEmbeddingClient added in v0.4.0

func NewEmbeddingClient(ctx context.Context, model *model.Model, key, baseURL, path string) (*sdk.EmbeddingClient, error)

func NewModerationClient added in v0.5.0

func NewModerationClient(ctx context.Context, model *model.Model, key, baseURL, path string) (*sdk.ModerationClient, error)

func NewRealtimeClient added in v0.5.0

func NewRealtimeClient(ctx context.Context, model *model.Model, key, baseURL, path string) (*sdk.RealtimeClient, error)

Types

type ApplicationDefaultCredentials added in v0.5.0

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 added in v0.5.0

type MAK struct {
	Corp               string
	Model              string
	Messages           []sdkm.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
}

func (*MAK) InitMAK added in v0.5.0

func (mak *MAK) InitMAK(ctx context.Context, retry ...int) (err error)

Jump to

Keyboard shortcuts

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