MCPcopy Create free account
hub / github.com/QuantumNous/new-api / LoadToolPricesFromJSONString

Function LoadToolPricesFromJSONString

setting/operation_setting/tools.go:137–145  ·  view source on GitHub ↗

LoadToolPricesFromJSONString replaces the complete operator price map. Invalid legacy entries are ignored individually so valid sibling overrides survive, while missing built-in keys continue to use hardcoded fallbacks.

(value string)

Source from the content-addressed store, hash-verified

135// Invalid legacy entries are ignored individually so valid sibling overrides
136// survive, while missing built-in keys continue to use hardcoded fallbacks.
137func LoadToolPricesFromJSONString(value string) {
138 prices, err := decodeToolPricesJSON(value, true)
139 if err != nil {
140 common.SysError("加载工具价格失败,将使用硬编码兜底: " + err.Error())
141 prices = make(map[string]float64)
142 }
143 toolPriceSetting.Prices = prices
144 RebuildToolPriceIndex()
145}
146
147// RebuildToolPriceIndex rebuilds the lookup index from the current config.
148// Called on init and after config updates. Not on the billing hot path.

Calls 4

SysErrorFunction · 0.92
decodeToolPricesJSONFunction · 0.85
RebuildToolPriceIndexFunction · 0.85
ErrorMethod · 0.45