Commit 0f80728a

hallacy <hallacy@openai.com>
2022-04-09 01:54:02
Add customer endpoints (#126) (#87) tag: v0.18.0
* Add customer endpoints * getting in other changes
1 parent 3269db8
Changed files (5)
openai/api_resources/__init__.py
@@ -1,6 +1,7 @@
 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.edit import Edit  # noqa: F401
 from openai.api_resources.embedding import Embedding  # noqa: F401
 from openai.api_resources.engine import Engine  # noqa: F401
openai/api_resources/customer.py
@@ -0,0 +1,12 @@
+from openai.openai_object import OpenAIObject
+
+
+class Customer(OpenAIObject):
+    @classmethod
+    def get_url(self, customer, endpoint):
+        return f"/customer/{customer}/{endpoint}"
+
+    @classmethod
+    def create(cls, customer, endpoint, **params):
+        instance = cls()
+        return instance.request("post", cls.get_url(customer, endpoint), params)
openai/tests/test_endpoints.py
@@ -33,4 +33,4 @@ def test_completions_multiple_prompts():
 def test_completions_model():
     result = openai.Completion.create(prompt="This was a test", n=5, model="ada")
     assert len(result.choices) == 5
-    assert result.model.startswith("ada:")
+    assert result.model.startswith("ada")
openai/__init__.py
@@ -9,6 +9,7 @@ from openai.api_resources import (
     Answer,
     Classification,
     Completion,
+    Customer,
     Edit,
     Embedding,
     Engine,
@@ -43,6 +44,7 @@ __all__ = [
     "Answer",
     "Classification",
     "Completion",
+    "Customer",
     "Edit",
     "Embedding",
     "Engine",
openai/version.py
@@ -1,1 +1,1 @@
-VERSION = "0.17.0"
+VERSION = "0.18.0"