File tree 4 files changed +36
-1
lines changed
4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 9
9
Answer ,
10
10
Classification ,
11
11
Completion ,
12
+ Edit ,
12
13
Embedding ,
13
14
Engine ,
14
15
ErrorObject ,
42
43
"Answer" ,
43
44
"Classification" ,
44
45
"Completion" ,
46
+ "Edit" ,
45
47
"Embedding" ,
46
48
"Engine" ,
47
49
"ErrorObject" ,
Original file line number Diff line number Diff line change 1
1
from openai .api_resources .answer import Answer # noqa: F401
2
2
from openai .api_resources .classification import Classification # noqa: F401
3
3
from openai .api_resources .completion import Completion # noqa: F401
4
+ from openai .api_resources .edit import Edit # noqa: F401
4
5
from openai .api_resources .embedding import Embedding # noqa: F401
5
6
from openai .api_resources .engine import Engine # noqa: F401
6
7
from 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