11import { ReplicateError , ReplicateResponseError } from "./errors.js" ;
22import Prediction from "./Prediction.js" ;
33import ReplicateObject from "./ReplicateObject.js" ;
4- import { sleep } from "./utils.js" ;
4+ import { noop , sleep } from "./utils.js" ;
55
66export default class Model extends ReplicateObject {
77 static propertyMap = {
@@ -48,7 +48,7 @@ export default class Model extends ReplicateObject {
4848
4949 async predict (
5050 input ,
51- { onUpdate, onTemporaryError } = { } ,
51+ { onUpdate = noop , onTemporaryError = noop } = { } ,
5252 {
5353 defaultPollingInterval = 500 ,
5454 backoffFn = ( errorCount ) => Math . pow ( 2 , errorCount ) * 100 ,
@@ -60,7 +60,7 @@ export default class Model extends ReplicateObject {
6060
6161 let prediction = await this . createPrediction ( input ) ;
6262
63- onUpdate && onUpdate ( prediction ) ;
63+ onUpdate ( prediction ) ;
6464
6565 let pollingInterval = defaultPollingInterval ;
6666 let errorCount = 0 ;
@@ -72,7 +72,7 @@ export default class Model extends ReplicateObject {
7272 try {
7373 prediction = await this . client . prediction ( prediction . id ) . load ( ) ;
7474
75- onUpdate && onUpdate ( prediction ) ;
75+ onUpdate ( prediction ) ;
7676
7777 errorCount = 0 ; // Reset because we've had a non-error response.
7878 } catch ( err ) {
@@ -89,7 +89,7 @@ export default class Model extends ReplicateObject {
8989
9090 errorCount += 1 ;
9191
92- onTemporaryError && onTemporaryError ( err ) ;
92+ onTemporaryError ( err ) ;
9393
9494 pollingInterval = backoffFn ( errorCount ) ;
9595 }
0 commit comments