Skip to content

Commit 5f60aca

Browse files
authored
Rename DALL·E to Image (#134)
* Rename DALL·E to Image * bump version
1 parent d59672b commit 5f60aca

File tree

5 files changed

+25
-31
lines changed

5 files changed

+25
-31
lines changed

openai/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from typing import Optional
77

88
from openai.api_resources import (
9-
DALLE,
109
Answer,
1110
Classification,
1211
Completion,
@@ -18,6 +17,7 @@
1817
ErrorObject,
1918
File,
2019
FineTune,
20+
Image,
2121
Model,
2222
Moderation,
2323
Search,
@@ -51,7 +51,7 @@
5151
"Completion",
5252
"Customer",
5353
"Edit",
54-
"DALLE",
54+
"Image",
5555
"Deployment",
5656
"Embedding",
5757
"Engine",

openai/api_resources/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
from openai.api_resources.classification import Classification # noqa: F401
33
from openai.api_resources.completion import Completion # noqa: F401
44
from openai.api_resources.customer import Customer # noqa: F401
5-
from openai.api_resources.dalle import DALLE # noqa: F401
65
from openai.api_resources.deployment import Deployment # noqa: F401
76
from openai.api_resources.edit import Edit # noqa: F401
87
from openai.api_resources.embedding import Embedding # noqa: F401
98
from openai.api_resources.engine import Engine # noqa: F401
109
from openai.api_resources.error_object import ErrorObject # noqa: F401
1110
from openai.api_resources.file import File # noqa: F401
1211
from openai.api_resources.fine_tune import FineTune # noqa: F401
12+
from openai.api_resources.image import Image # noqa: F401
1313
from openai.api_resources.model import Model # noqa: F401
1414
from openai.api_resources.moderation import Moderation # noqa: F401
1515
from openai.api_resources.search import Search # noqa: F401

openai/api_resources/dalle.py renamed to openai/api_resources/image.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
from openai.api_resources.abstract import APIResource
77

88

9-
class DALLE(APIResource):
9+
class Image(APIResource):
1010
OBJECT_NAME = "images"
1111

1212
@classmethod
1313
def _get_url(cls, action):
1414
return cls.class_url() + f"/{action}"
1515

1616
@classmethod
17-
def generations(
17+
def create(
1818
cls,
1919
**params,
2020
):
2121
instance = cls()
2222
return instance.request("post", cls._get_url("generations"), params)
2323

2424
@classmethod
25-
def variations(
25+
def create_variation(
2626
cls,
2727
image,
2828
api_key=None,
@@ -55,7 +55,7 @@ def variations(
5555
)
5656

5757
@classmethod
58-
def edits(
58+
def create_edit(
5959
cls,
6060
image,
6161
mask,

openai/cli.py

+17-23
Original file line numberDiff line numberDiff line change
@@ -229,44 +229,41 @@ def list(cls, args):
229229
print(file)
230230

231231

232-
class DALLE:
232+
class Image:
233233
@classmethod
234-
def generations(cls, args):
235-
resp = openai.DALLE.generations(
234+
def create(cls, args):
235+
resp = openai.Image.create(
236236
prompt=args.prompt,
237-
model=args.model,
238237
size=args.size,
239-
num_images=args.num_images,
238+
n=args.num_images,
240239
response_format=args.response_format,
241240
)
242241
print(resp)
243242

244243
@classmethod
245-
def variations(cls, args):
244+
def create_variation(cls, args):
246245
with open(args.image, "rb") as file_reader:
247246
buffer_reader = BufferReader(file_reader.read(), desc="Upload progress")
248-
resp = openai.DALLE.variations(
247+
resp = openai.Image.create_variation(
249248
image=buffer_reader,
250-
model=args.model,
251249
size=args.size,
252-
num_images=args.num_images,
250+
n=args.num_images,
253251
response_format=args.response_format,
254252
)
255253
print(resp)
256254

257255
@classmethod
258-
def edits(cls, args):
256+
def create_edit(cls, args):
259257
with open(args.image, "rb") as file_reader:
260258
image_reader = BufferReader(file_reader.read(), desc="Upload progress")
261259
with open(args.mask, "rb") as file_reader:
262260
mask_reader = BufferReader(file_reader.read(), desc="Upload progress")
263-
resp = openai.DALLE.edits(
261+
resp = openai.Image.create_edit(
264262
image=image_reader,
265263
mask=mask_reader,
266264
prompt=args.prompt,
267-
model=args.model,
268265
size=args.size,
269-
num_images=args.num_images,
266+
n=args.num_images,
270267
response_format=args.response_format,
271268
)
272269
print(resp)
@@ -1026,19 +1023,17 @@ def help(args):
10261023
sub.add_argument("-i", "--id", required=True, help="The id of the fine-tune job")
10271024
sub.set_defaults(func=FineTune.cancel)
10281025

1029-
# DALLE
1030-
sub = subparsers.add_parser("dalle.generations")
1031-
sub.add_argument("-m", "--model", type=str, default="image-alpha-001")
1026+
# Image
1027+
sub = subparsers.add_parser("image.create")
10321028
sub.add_argument("-p", "--prompt", type=str, required=True)
10331029
sub.add_argument("-n", "--num-images", type=int, default=1)
10341030
sub.add_argument(
10351031
"-s", "--size", type=str, default="1024x1024", help="Size of the output image"
10361032
)
10371033
sub.add_argument("--response-format", type=str, default="url")
1038-
sub.set_defaults(func=DALLE.generations)
1034+
sub.set_defaults(func=Image.create)
10391035

1040-
sub = subparsers.add_parser("dalle.edits")
1041-
sub.add_argument("-m", "--model", type=str, default="image-alpha-001")
1036+
sub = subparsers.add_parser("image.create_edit")
10421037
sub.add_argument("-p", "--prompt", type=str, required=True)
10431038
sub.add_argument("-n", "--num-images", type=int, default=1)
10441039
sub.add_argument(
@@ -1059,10 +1054,9 @@ def help(args):
10591054
required=True,
10601055
help="Path to a mask image. It should be the same size as the image you're editing and a RGBA PNG image. The Alpha channel acts as the mask.",
10611056
)
1062-
sub.set_defaults(func=DALLE.edits)
1057+
sub.set_defaults(func=Image.create_edit)
10631058

1064-
sub = subparsers.add_parser("dalle.variations")
1065-
sub.add_argument("-m", "--model", type=str, default="image-alpha-001")
1059+
sub = subparsers.add_parser("image.create_variation")
10661060
sub.add_argument("-n", "--num-images", type=int, default=1)
10671061
sub.add_argument(
10681062
"-I",
@@ -1075,7 +1069,7 @@ def help(args):
10751069
"-s", "--size", type=str, default="1024x1024", help="Size of the output image"
10761070
)
10771071
sub.add_argument("--response-format", type=str, default="url")
1078-
sub.set_defaults(func=DALLE.variations)
1072+
sub.set_defaults(func=Image.create_variation)
10791073

10801074

10811075
def wandb_register(parser):

openai/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "0.24.0"
1+
VERSION = "0.25.0"

0 commit comments

Comments
 (0)