Skip to content

Commit 0f80728

Browse files
authored
Add customer endpoints (#126) (#87)
* Add customer endpoints * getting in other changes
1 parent 3269db8 commit 0f80728

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

openai/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Answer,
1010
Classification,
1111
Completion,
12+
Customer,
1213
Edit,
1314
Embedding,
1415
Engine,
@@ -43,6 +44,7 @@
4344
"Answer",
4445
"Classification",
4546
"Completion",
47+
"Customer",
4648
"Edit",
4749
"Embedding",
4850
"Engine",

openai/api_resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from openai.api_resources.answer import Answer # noqa: F401
22
from openai.api_resources.classification import Classification # noqa: F401
33
from openai.api_resources.completion import Completion # noqa: F401
4+
from openai.api_resources.customer import Customer # noqa: F401
45
from openai.api_resources.edit import Edit # noqa: F401
56
from openai.api_resources.embedding import Embedding # noqa: F401
67
from openai.api_resources.engine import Engine # noqa: F401

openai/api_resources/customer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from openai.openai_object import OpenAIObject
2+
3+
4+
class Customer(OpenAIObject):
5+
@classmethod
6+
def get_url(self, customer, endpoint):
7+
return f"/customer/{customer}/{endpoint}"
8+
9+
@classmethod
10+
def create(cls, customer, endpoint, **params):
11+
instance = cls()
12+
return instance.request("post", cls.get_url(customer, endpoint), params)

openai/tests/test_endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ def test_completions_multiple_prompts():
3333
def test_completions_model():
3434
result = openai.Completion.create(prompt="This was a test", n=5, model="ada")
3535
assert len(result.choices) == 5
36-
assert result.model.startswith("ada:")
36+
assert result.model.startswith("ada")

openai/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "0.17.0"
1+
VERSION = "0.18.0"

0 commit comments

Comments
 (0)