88from replicate .prediction import (
99 Prediction ,
1010 _create_prediction_body ,
11- _create_prediction_headers ,
11+ _create_prediction_request_params ,
1212 _json_to_prediction ,
1313)
1414from replicate .resource import Namespace , Resource
@@ -421,21 +421,25 @@ def create(
421421 Create a new prediction with the deployment.
422422 """
423423
424+ wait = params .pop ("wait" , None )
424425 file_encoding_strategy = params .pop ("file_encoding_strategy" , None )
426+
425427 if input is not None :
426428 input = encode_json (
427429 input ,
428430 client = self ._client ,
429431 file_encoding_strategy = file_encoding_strategy ,
430432 )
431- headers = _create_prediction_headers (wait = params .pop ("wait" , None ))
432- body = _create_prediction_body (version = None , input = input , ** params )
433433
434+ body = _create_prediction_body (version = None , input = input , ** params )
435+ extras = _create_prediction_request_params (
436+ wait = wait ,
437+ )
434438 resp = self ._client ._request (
435439 "POST" ,
436440 f"/v1/deployments/{ self ._deployment .owner } /{ self ._deployment .name } /predictions" ,
437441 json = body ,
438- headers = headers ,
442+ ** extras ,
439443 )
440444
441445 return _json_to_prediction (self ._client , resp .json ())
@@ -449,21 +453,24 @@ async def async_create(
449453 Create a new prediction with the deployment.
450454 """
451455
456+ wait = params .pop ("wait" , None )
452457 file_encoding_strategy = params .pop ("file_encoding_strategy" , None )
453458 if input is not None :
454459 input = await async_encode_json (
455460 input ,
456461 client = self ._client ,
457462 file_encoding_strategy = file_encoding_strategy ,
458463 )
459- headers = _create_prediction_headers (wait = params .pop ("wait" , None ))
460- body = _create_prediction_body (version = None , input = input , ** params )
461464
465+ body = _create_prediction_body (version = None , input = input , ** params )
466+ extras = _create_prediction_request_params (
467+ wait = wait ,
468+ )
462469 resp = await self ._client ._async_request (
463470 "POST" ,
464471 f"/v1/deployments/{ self ._deployment .owner } /{ self ._deployment .name } /predictions" ,
465472 json = body ,
466- headers = headers ,
473+ ** extras ,
467474 )
468475
469476 return _json_to_prediction (self ._client , resp .json ())
@@ -484,24 +491,20 @@ def create(
484491 Create a new prediction with the deployment.
485492 """
486493
487- url = _create_prediction_url_from_deployment (deployment )
488-
494+ wait = params .pop ("wait" , None )
489495 file_encoding_strategy = params .pop ("file_encoding_strategy" , None )
496+
497+ url = _create_prediction_url_from_deployment (deployment )
490498 if input is not None :
491499 input = encode_json (
492500 input ,
493501 client = self ._client ,
494502 file_encoding_strategy = file_encoding_strategy ,
495503 )
496- headers = _create_prediction_headers (wait = params .pop ("wait" , None ))
497- body = _create_prediction_body (version = None , input = input , ** params )
498504
499- resp = self ._client ._request (
500- "POST" ,
501- url ,
502- json = body ,
503- headers = headers ,
504- )
505+ body = _create_prediction_body (version = None , input = input , ** params )
506+ extras = _create_prediction_request_params (wait = wait )
507+ resp = self ._client ._request ("POST" , url , json = body , ** extras )
505508
506509 return _json_to_prediction (self ._client , resp .json ())
507510
@@ -515,25 +518,20 @@ async def async_create(
515518 Create a new prediction with the deployment.
516519 """
517520
518- url = _create_prediction_url_from_deployment (deployment )
519-
521+ wait = params .pop ("wait" , None )
520522 file_encoding_strategy = params .pop ("file_encoding_strategy" , None )
523+
524+ url = _create_prediction_url_from_deployment (deployment )
521525 if input is not None :
522526 input = await async_encode_json (
523527 input ,
524528 client = self ._client ,
525529 file_encoding_strategy = file_encoding_strategy ,
526530 )
527531
528- headers = _create_prediction_headers (wait = params .pop ("wait" , None ))
529532 body = _create_prediction_body (version = None , input = input , ** params )
530-
531- resp = await self ._client ._async_request (
532- "POST" ,
533- url ,
534- json = body ,
535- headers = headers ,
536- )
533+ extras = _create_prediction_request_params (wait = wait )
534+ resp = await self ._client ._async_request ("POST" , url , json = body , ** extras )
537535
538536 return _json_to_prediction (self ._client , resp .json ())
539537
0 commit comments