MCPcopy
hub / github.com/QuantumNous/new-api / buildModelsDevCandidate

Function buildModelsDevCandidate

controller/ratio_sync.go:845–879  ·  view source on GitHub ↗
(provider string, cost modelsDevCost)

Source from the content-addressed store, hash-verified

843}
844
845func buildModelsDevCandidate(provider string, cost modelsDevCost) (modelsDevCandidate, bool) {
846 if cost.Input == nil {
847 return modelsDevCandidate{}, false
848 }
849
850 input := *cost.Input
851 if !isValidNonNegativeCost(input) {
852 return modelsDevCandidate{}, false
853 }
854
855 var output *float64
856 if cost.Output != nil {
857 if !isValidNonNegativeCost(*cost.Output) {
858 return modelsDevCandidate{}, false
859 }
860 output = cloneFloatPtr(cost.Output)
861 }
862
863 // input=0/output>0 cannot be transformed into local ratio.
864 if input == 0 && output != nil && *output > 0 {
865 return modelsDevCandidate{}, false
866 }
867
868 var cacheRead *float64
869 if cost.CacheRead != nil && isValidNonNegativeCost(*cost.CacheRead) {
870 cacheRead = cloneFloatPtr(cost.CacheRead)
871 }
872
873 return modelsDevCandidate{
874 Provider: provider,
875 Input: input,
876 Output: output,
877 CacheRead: cacheRead,
878 }, true
879}
880
881func shouldReplaceModelsDevCandidate(current, next modelsDevCandidate) bool {
882 currentNonZero := current.Input > 0

Callers 1

Calls 2

isValidNonNegativeCostFunction · 0.85
cloneFloatPtrFunction · 0.85

Tested by

no test coverage detected