Skip to content

Commit

Permalink
fix(ai): fix runtime error in aiWorker when pricePerUnit is unset (#3059
Browse files Browse the repository at this point in the history
)

* Fix nil baseprice when pricePerUnit is unused in aiWorker

* fix: fix priceInfo 'nil' error on discovery

This commit ensures that when the `transcodePrice` is not set by the AI
orchestrator no `nil` error is thrown when a Gateway requests the
orchestrators OrchInfo.

* fix(ai): fix incorrect transcodePrice condition

This commit fixes the check that is performed to check if transcodePrice
is set.

---------

Co-authored-by: Rick Staa <[email protected]>
  • Loading branch information
eliteprox and rickstaa authored May 20, 2024
1 parent 2b8478d commit 03b64fb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,13 @@ func (orch *orchestrator) priceInfo(sender ethcommon.Address, manifestID Manifes
transcodePrice = orch.node.GetBasePrice("default")
}

var basePrice *big.Rat
basePrice := big.NewRat(0, 1)
if caps == nil {
basePrice = transcodePrice
if transcodePrice != nil {
basePrice = transcodePrice
}
} else {
// The base price is the sum of the prices of individual capability + model ID pairs
basePrice = big.NewRat(0, 1)
for cap := range caps.Capacities {
// If the capability does not have constraints (and thus any model constraints) skip it
// because we only price a capability together with a model ID right now
Expand All @@ -359,7 +360,7 @@ func (orch *orchestrator) priceInfo(sender ethcommon.Address, manifestID Manifes

// If no priced capabilities were signaled by the broadcaster assume that they are requesting
// transcoding and set the base price to the transcode price
if basePrice.Cmp(big.NewRat(0, 1)) == 0 {
if transcodePrice != nil && basePrice.Cmp(big.NewRat(0, 1)) == 0 {
basePrice = transcodePrice
}
}
Expand Down

0 comments on commit 03b64fb

Please sign in to comment.