Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion server/ai_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,24 +502,28 @@ func handleAIRequest(ctx context.Context, w http.ResponseWriter, r *http.Request
respondWithError(w, "insufficient capacity", http.StatusServiceUnavailable)
return
}

// Known limitation:
// This call will set a fixed price for all requests in a session identified by a manifestID.
// Since all requests for a capability + modelID are treated as "session" with a single manifestID, all
// requests for a capability + modelID will get the same fixed price for as long as the orch is running
if err := orch.ProcessPayment(ctx, payment, manifestID); err != nil {
respondWithError(w, err.Error(), http.StatusBadRequest)
releaseCapacity <- true
return
}

if payment.GetExpectedPrice().GetPricePerUnit() > 0 && !orch.SufficientBalance(sender, manifestID) {
respondWithError(w, "Insufficient balance", http.StatusBadRequest)
//release capacity, payment issue is not orchestrator's fault
releaseCapacity <- true
return
}

err = orch.CreateStorageForRequest(requestID)
if err != nil {
respondWithError(w, "Could not create storage to receive results", http.StatusInternalServerError)
//do not release capacity, this is an unrecoverable error
return
}
// Note: At the moment, we do not return a new OrchestratorInfo with updated ticket params + price with
// extended expiry because the response format does not include such a field. As a result, the broadcaster
Expand All @@ -535,6 +539,7 @@ func handleAIRequest(ctx context.Context, w http.ResponseWriter, r *http.Request
monitor.AIProcessingError(err.Error(), pipeline, modelID, sender.Hex())
}
respondWithError(w, err.Error(), http.StatusInternalServerError)
releaseCapacity <- true
return
}

Expand Down
Loading