ratio_setting

package
v0.10.8-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USD2RMB = 7.3 // 暂定 1 USD = 7.3 RMB
	USD     = 500 // $0.002 = 1 -> $1 = 500
	RMB     = USD / USD2RMB
)

from songquanpeng/one-api

View Source
const CompactModelSuffix = "-openai-compact"
View Source
const CompactWildcardModelKey = "*" + CompactModelSuffix

Variables

View Source
var (
	CompletionRatio      map[string]float64 = nil
	CompletionRatioMutex                    = sync.RWMutex{}
)
View Source
var (
	GroupGroupRatio = map[string]map[string]float64{
		"vip": {
			"edit_this": 0.9,
		},
	}
)

Functions

func AudioCompletionRatio2JSONString

func AudioCompletionRatio2JSONString() string

func AudioRatio2JSONString

func AudioRatio2JSONString() string

func CacheRatio2JSONString

func CacheRatio2JSONString() string

CacheRatio2JSONString converts the cache ratio map to a JSON string

func CheckGroupRatio

func CheckGroupRatio(jsonStr string) error

func CompletionRatio2JSONString

func CompletionRatio2JSONString() string

func ContainsAudioCompletionRatio

func ContainsAudioCompletionRatio(name string) bool

func ContainsAudioRatio

func ContainsAudioRatio(name string) bool

func ContainsGroupRatio

func ContainsGroupRatio(name string) bool

func DefaultModelRatio2JSONString

func DefaultModelRatio2JSONString() string

func FormatMatchingModelName

func FormatMatchingModelName(name string) string

转换模型名,减少渠道必须配置各种带参数模型

func GetAudioCompletionRatio

func GetAudioCompletionRatio(name string) float64

func GetAudioRatio

func GetAudioRatio(name string) float64

func GetCacheRatio

func GetCacheRatio(name string) (float64, bool)

GetCacheRatio returns the cache ratio for a model

func GetCacheRatioCopy

func GetCacheRatioCopy() map[string]float64

func GetCacheRatioMap

func GetCacheRatioMap() map[string]float64

GetCacheRatioMap returns the cache ratio map

func GetCompletionRatio

func GetCompletionRatio(name string) float64

func GetCompletionRatioCopy

func GetCompletionRatioCopy() map[string]float64

func GetCompletionRatioMap

func GetCompletionRatioMap() map[string]float64

func GetCreateCacheRatio

func GetCreateCacheRatio(name string) (float64, bool)

func GetDefaultAudioCompletionRatioMap

func GetDefaultAudioCompletionRatioMap() map[string]float64

func GetDefaultAudioRatioMap

func GetDefaultAudioRatioMap() map[string]float64

func GetDefaultImageRatioMap

func GetDefaultImageRatioMap() map[string]float64

func GetDefaultModelPriceMap

func GetDefaultModelPriceMap() map[string]float64

func GetDefaultModelRatioMap

func GetDefaultModelRatioMap() map[string]float64

func GetExposedData

func GetExposedData() gin.H

func GetGroupGroupRatio

func GetGroupGroupRatio(userGroup, usingGroup string) (float64, bool)

func GetGroupRatio

func GetGroupRatio(name string) float64

func GetGroupRatioCopy

func GetGroupRatioCopy() map[string]float64

func GetImageRatio

func GetImageRatio(name string) (float64, bool)

func GetModelPrice

func GetModelPrice(name string, printErr bool) (float64, bool)

GetModelPrice 返回模型的价格,如果模型不存在则返回-1,false

func GetModelPriceCopy

func GetModelPriceCopy() map[string]float64

func GetModelPriceMap

func GetModelPriceMap() map[string]float64

func GetModelRatio

func GetModelRatio(name string) (float64, bool, string)

func GetModelRatioCopy

func GetModelRatioCopy() map[string]float64

func GetModelRatioOrPrice

func GetModelRatioOrPrice(model string) (float64, bool, bool)

result: 倍率or价格, usePrice, exist

func GroupGroupRatio2JSONString

func GroupGroupRatio2JSONString() string

func GroupRatio2JSONString

func GroupRatio2JSONString() string

func ImageRatio2JSONString

func ImageRatio2JSONString() string

func InitRatioSettings

func InitRatioSettings()

InitRatioSettings initializes all model related settings maps

func InvalidateExposedDataCache

func InvalidateExposedDataCache()

func IsExposeRatioEnabled

func IsExposeRatioEnabled() bool

func ModelPrice2JSONString

func ModelPrice2JSONString() string

func ModelRatio2JSONString

func ModelRatio2JSONString() string

func SetExposeRatioEnabled

func SetExposeRatioEnabled(enabled bool)

func UpdateAudioCompletionRatioByJSONString

func UpdateAudioCompletionRatioByJSONString(jsonStr string) error

func UpdateAudioRatioByJSONString

func UpdateAudioRatioByJSONString(jsonStr string) error

func UpdateCacheRatioByJSONString

func UpdateCacheRatioByJSONString(jsonStr string) error

UpdateCacheRatioByJSONString updates the cache ratio map from a JSON string

func UpdateCompletionRatioByJSONString

func UpdateCompletionRatioByJSONString(jsonStr string) error

func UpdateGroupGroupRatioByJSONString

func UpdateGroupGroupRatioByJSONString(jsonStr string) error

func UpdateGroupRatioByJSONString

func UpdateGroupRatioByJSONString(jsonStr string) error

func UpdateImageRatioByJSONString

func UpdateImageRatioByJSONString(jsonStr string) error

func UpdateModelPriceByJSONString

func UpdateModelPriceByJSONString(jsonStr string) error

func UpdateModelRatioByJSONString

func UpdateModelRatioByJSONString(jsonStr string) error

func WithCompactModelSuffix

func WithCompactModelSuffix(modelName string) string

Types

type GroupRatioSetting

type GroupRatioSetting struct {
	GroupRatio              map[string]float64                      `json:"group_ratio"`
	GroupGroupRatio         map[string]map[string]float64           `json:"group_group_ratio"`
	GroupSpecialUsableGroup *types.RWMap[string, map[string]string] `json:"group_special_usable_group"`
}

func GetGroupRatioSetting

func GetGroupRatioSetting() *GroupRatioSetting

Jump to

Keyboard shortcuts

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