types

package
v0.2.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromJsonString

func LoadFromJsonString[K comparable, V any](m *RWMap[K, V], jsonStr string) error

func LoadFromJsonStringWithCallback

func LoadFromJsonStringWithCallback[K comparable, V any](m *RWMap[K, V], jsonStr string, onSuccess func()) error

Types

type GroupRatioInfo

type GroupRatioInfo struct {
	GroupRatio        float64
	GroupSpecialRatio float64
	HasSpecialRatio   bool
}

type PriceData

type PriceData struct {
	FreeModel            bool
	ModelPrice           float64
	ModelRatio           float64
	CompletionRatio      float64
	CacheRatio           float64
	CacheCreationRatio   float64
	CacheCreation5mRatio float64
	CacheCreation1hRatio float64
	ImageRatio           float64
	AudioRatio           float64
	AudioCompletionRatio float64

	UsePrice          bool
	Quota             int // 按次计费的最终额度(MJ / Task)
	QuotaToPreConsume int // 按量计费的预消耗额度
	GroupRatioInfo    GroupRatioInfo
	// contains filtered or unexported fields
}

func (*PriceData) AddOtherRatio

func (p *PriceData) AddOtherRatio(key string, ratio float64)

func (*PriceData) ApplyOtherRatiosToDecimal

func (p *PriceData) ApplyOtherRatiosToDecimal(value decimal.Decimal) decimal.Decimal

func (*PriceData) ApplyOtherRatiosToFloat

func (p *PriceData) ApplyOtherRatiosToFloat(value float64) float64

func (*PriceData) CapturePreConsumeTokens

func (p *PriceData) CapturePreConsumeTokens(tokens int) error

CapturePreConsumeTokens freezes the non-tiered estimate and its initial group. Retries can reprice that estimate without reading live token defaults or model prices, including when the first group's ratio was zero.

func (*PriceData) CaptureQuotaUnit

func (p *PriceData) CaptureQuotaUnit(unit float64) error

CaptureQuotaUnit seals the currency conversion for this request. The field is private so invalid/untrusted PriceData cannot assign a snapshot directly.

func (*PriceData) CaptureToolPrices

func (p *PriceData) CaptureToolPrices(prices map[string]float64) error

func (*PriceData) HasOtherRatio

func (p *PriceData) HasOtherRatio(key string) bool

func (*PriceData) OtherRatioMultiplier

func (p *PriceData) OtherRatioMultiplier() float64

func (*PriceData) OtherRatios

func (p *PriceData) OtherRatios() map[string]float64

func (*PriceData) QuotedPreConsumeTokens

func (p *PriceData) QuotedPreConsumeTokens() (tokens int, groupRatio float64, captured bool)

func (*PriceData) QuotedQuotaUnit

func (p *PriceData) QuotedQuotaUnit(legacyUnit float64) float64

QuotedQuotaUnit preserves old internal callers without a captured unit; quote helpers always capture one before returning a request PriceData.

func (*PriceData) QuotedToolPrice

func (p *PriceData) QuotedToolPrice(name string) (float64, bool)

The bool reports whether the entire price generation was captured, not whether this tool exists. Absent tools in a captured generation cost zero.

func (*PriceData) RemoveOtherRatiosFromFloat

func (p *PriceData) RemoveOtherRatiosFromFloat(value float64) float64

func (*PriceData) ReplaceOtherRatios

func (p *PriceData) ReplaceOtherRatios(ratios map[string]float64) bool

func (*PriceData) ToSetting

func (p *PriceData) ToSetting() string

type RWMap

type RWMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewRWMap

func NewRWMap[K comparable, V any]() *RWMap[K, V]

func (*RWMap[K, V]) AddAll

func (m *RWMap[K, V]) AddAll(other map[K]V)

func (*RWMap[K, V]) Clear

func (m *RWMap[K, V]) Clear()

func (*RWMap[K, V]) Get

func (m *RWMap[K, V]) Get(key K) (V, bool)

func (*RWMap[K, V]) Len

func (m *RWMap[K, V]) Len() int

func (*RWMap[K, V]) MarshalJSON

func (m *RWMap[K, V]) MarshalJSON() ([]byte, error)

func (*RWMap[K, V]) MarshalJSONString

func (m *RWMap[K, V]) MarshalJSONString() string

func (*RWMap[K, V]) ReadAll

func (m *RWMap[K, V]) ReadAll() map[K]V

func (*RWMap[K, V]) Set

func (m *RWMap[K, V]) Set(key K, value V)

func (*RWMap[K, V]) UnmarshalJSON

func (m *RWMap[K, V]) UnmarshalJSON(b []byte) error

type RealtimeUsageCheckpoint

type RealtimeUsageCheckpoint struct {
	Responses   int `json:"responses"`
	Quota       int `json:"quota"`
	Input       int `json:"input_tokens"`
	Output      int `json:"output_tokens"`
	Total       int `json:"total_tokens"`
	InputText   int `json:"input_text_tokens"`
	InputAudio  int `json:"input_audio_tokens"`
	InputImage  int `json:"input_image_tokens"`
	OutputText  int `json:"output_text_tokens"`
	OutputAudio int `json:"output_audio_tokens"`
	OutputImage int `json:"output_image_tokens"`
}

RealtimeUsageCheckpoint stores bounded confirmed totals, not response bodies or history. Cache and reasoning are already included in their parent counts.

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T comparable]() *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(item T)

func (*Set[T]) Contains

func (s *Set[T]) Contains(item T) bool

func (*Set[T]) Items

func (s *Set[T]) Items() []T

func (*Set[T]) Len

func (s *Set[T]) Len() int

func (*Set[T]) Remove

func (s *Set[T]) Remove(item T)

Jump to

Keyboard shortcuts

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