File tree Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Expand file tree Collapse file tree 4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 99 Answer ,
1010 Classification ,
1111 Completion ,
12+ Edit ,
1213 Embedding ,
1314 Engine ,
1415 ErrorObject ,
4243 "Answer" ,
4344 "Classification" ,
4445 "Completion" ,
46+ "Edit" ,
4547 "Embedding" ,
4648 "Engine" ,
4749 "ErrorObject" ,
Original file line number Diff line number Diff line change 11from openai .api_resources .answer import Answer # noqa: F401
22from openai .api_resources .classification import Classification # noqa: F401
33from openai .api_resources .completion import Completion # noqa: F401
4+ from openai .api_resources .edit import Edit # noqa: F401
45from openai .api_resources .embedding import Embedding # noqa: F401
56from openai .api_resources .engine import Engine # noqa: F401
67from openai .api_resources .error_object import ErrorObject # noqa: F401
Original file line number Diff line number Diff line change 1+ import time
2+
3+ from openai import util
4+ from openai .api_resources .abstract .engine_api_resource import EngineAPIResource
5+ from openai .error import InvalidRequestError , TryAgain
6+
7+
8+ class Edit (EngineAPIResource ):
9+ engine_required = False
10+ OBJECT_NAME = "edit"
11+
12+ @classmethod
13+ def create (cls , * args , ** kwargs ):
14+ """
15+ Creates a new edit for the provided input, instruction, and parameters.
16+ """
17+ start = time .time ()
18+ timeout = kwargs .pop ("timeout" , None )
19+ if kwargs .get ("model" , None ) is None and kwargs .get ("engine" , None ) is None :
20+ raise InvalidRequestError (
21+ "Must provide an 'engine' or 'model' parameter to create an Edit." ,
22+ param = "engine" ,
23+ )
24+
25+ while True :
26+ try :
27+ return super ().create (* args , ** kwargs )
28+ except TryAgain as e :
29+ if timeout is not None and time .time () > start + timeout :
30+ raise
31+
32+ util .log_info ("Waiting for model to warm up" , error = e )
Original file line number Diff line number Diff line change 1- VERSION = "0.15 .0"
1+ VERSION = "0.16 .0"
You can’t perform that action at this time.
0 commit comments