Commit 5f60acac

Michelle Pokrass <michelle@openai.com>
2022-11-03 03:45:32
Rename DALL·E to Image (#134) tag: v0.25.0
* Rename DALL·E to Image * bump version
1 parent d59672b
Changed files (5)
openai/api_resources/__init__.py
@@ -2,7 +2,6 @@ from openai.api_resources.answer import Answer  # noqa: F401
 from openai.api_resources.classification import Classification  # noqa: F401
 from openai.api_resources.completion import Completion  # noqa: F401
 from openai.api_resources.customer import Customer  # noqa: F401
-from openai.api_resources.dalle import DALLE  # noqa: F401
 from openai.api_resources.deployment import Deployment  # noqa: F401
 from openai.api_resources.edit import Edit  # noqa: F401
 from openai.api_resources.embedding import Embedding  # noqa: F401
@@ -10,6 +9,7 @@ from openai.api_resources.engine import Engine  # noqa: F401
 from openai.api_resources.error_object import ErrorObject  # noqa: F401
 from openai.api_resources.file import File  # noqa: F401
 from openai.api_resources.fine_tune import FineTune  # noqa: F401
+from openai.api_resources.image import Image  # noqa: F401
 from openai.api_resources.model import Model  # noqa: F401
 from openai.api_resources.moderation import Moderation  # noqa: F401
 from openai.api_resources.search import Search  # noqa: F401
openai/api_resources/dalle.py → openai/api_resources/image.py
@@ -6,7 +6,7 @@ from openai import api_requestor, util
 from openai.api_resources.abstract import APIResource
 
 
-class DALLE(APIResource):
+class Image(APIResource):
     OBJECT_NAME = "images"
 
     @classmethod
@@ -14,7 +14,7 @@ class DALLE(APIResource):
         return cls.class_url() + f"/{action}"
 
     @classmethod
-    def generations(
+    def create(
         cls,
         **params,
     ):
@@ -22,7 +22,7 @@ class DALLE(APIResource):
         return instance.request("post", cls._get_url("generations"), params)
 
     @classmethod
-    def variations(
+    def create_variation(
         cls,
         image,
         api_key=None,
@@ -55,7 +55,7 @@ class DALLE(APIResource):
         )
 
     @classmethod
-    def edits(
+    def create_edit(
         cls,
         image,
         mask,
openai/__init__.py
@@ -6,7 +6,6 @@ import os
 from typing import Optional
 
 from openai.api_resources import (
-    DALLE,
     Answer,
     Classification,
     Completion,
@@ -18,6 +17,7 @@ from openai.api_resources import (
     ErrorObject,
     File,
     FineTune,
+    Image,
     Model,
     Moderation,
     Search,
@@ -51,7 +51,7 @@ __all__ = [
     "Completion",
     "Customer",
     "Edit",
-    "DALLE",
+    "Image",
     "Deployment",
     "Embedding",
     "Engine",
openai/cli.py
@@ -229,44 +229,41 @@ class File:
         print(file)
 
 
-class DALLE:
+class Image:
     @classmethod
-    def generations(cls, args):
-        resp = openai.DALLE.generations(
+    def create(cls, args):
+        resp = openai.Image.create(
             prompt=args.prompt,
-            model=args.model,
             size=args.size,
-            num_images=args.num_images,
+            n=args.num_images,
             response_format=args.response_format,
         )
         print(resp)
 
     @classmethod
-    def variations(cls, args):
+    def create_variation(cls, args):
         with open(args.image, "rb") as file_reader:
             buffer_reader = BufferReader(file_reader.read(), desc="Upload progress")
-        resp = openai.DALLE.variations(
+        resp = openai.Image.create_variation(
             image=buffer_reader,
-            model=args.model,
             size=args.size,
-            num_images=args.num_images,
+            n=args.num_images,
             response_format=args.response_format,
         )
         print(resp)
 
     @classmethod
-    def edits(cls, args):
+    def create_edit(cls, args):
         with open(args.image, "rb") as file_reader:
             image_reader = BufferReader(file_reader.read(), desc="Upload progress")
         with open(args.mask, "rb") as file_reader:
             mask_reader = BufferReader(file_reader.read(), desc="Upload progress")
-        resp = openai.DALLE.edits(
+        resp = openai.Image.create_edit(
             image=image_reader,
             mask=mask_reader,
             prompt=args.prompt,
-            model=args.model,
             size=args.size,
-            num_images=args.num_images,
+            n=args.num_images,
             response_format=args.response_format,
         )
         print(resp)
@@ -1026,19 +1023,17 @@ Mutually exclusive with `top_p`.""",
     sub.add_argument("-i", "--id", required=True, help="The id of the fine-tune job")
     sub.set_defaults(func=FineTune.cancel)
 
-    # DALLE
-    sub = subparsers.add_parser("dalle.generations")
-    sub.add_argument("-m", "--model", type=str, default="image-alpha-001")
+    # Image
+    sub = subparsers.add_parser("image.create")
     sub.add_argument("-p", "--prompt", type=str, required=True)
     sub.add_argument("-n", "--num-images", type=int, default=1)
     sub.add_argument(
         "-s", "--size", type=str, default="1024x1024", help="Size of the output image"
     )
     sub.add_argument("--response-format", type=str, default="url")
-    sub.set_defaults(func=DALLE.generations)
+    sub.set_defaults(func=Image.create)
 
-    sub = subparsers.add_parser("dalle.edits")
-    sub.add_argument("-m", "--model", type=str, default="image-alpha-001")
+    sub = subparsers.add_parser("image.create_edit")
     sub.add_argument("-p", "--prompt", type=str, required=True)
     sub.add_argument("-n", "--num-images", type=int, default=1)
     sub.add_argument(
@@ -1059,10 +1054,9 @@ Mutually exclusive with `top_p`.""",
         required=True,
         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.",
     )
-    sub.set_defaults(func=DALLE.edits)
+    sub.set_defaults(func=Image.create_edit)
 
-    sub = subparsers.add_parser("dalle.variations")
-    sub.add_argument("-m", "--model", type=str, default="image-alpha-001")
+    sub = subparsers.add_parser("image.create_variation")
     sub.add_argument("-n", "--num-images", type=int, default=1)
     sub.add_argument(
         "-I",
@@ -1075,7 +1069,7 @@ Mutually exclusive with `top_p`.""",
         "-s", "--size", type=str, default="1024x1024", help="Size of the output image"
     )
     sub.add_argument("--response-format", type=str, default="url")
-    sub.set_defaults(func=DALLE.variations)
+    sub.set_defaults(func=Image.create_variation)
 
 
 def wandb_register(parser):
openai/version.py
@@ -1,1 +1,1 @@
-VERSION = "0.24.0"
+VERSION = "0.25.0"