Commit 20d97ef0
Changed files (5)
src
openai
resources
tests
api_resources
src/openai/resources/chat/completions.py
@@ -46,6 +46,8 @@ class Completions(SyncAPIResource):
model: Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
@@ -152,7 +154,8 @@ class Completions(SyncAPIResource):
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
response_format: An object specifying the format that the model must output. Compatible with
- `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
+ [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
+ `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
@@ -232,6 +235,8 @@ class Completions(SyncAPIResource):
model: Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
@@ -345,7 +350,8 @@ class Completions(SyncAPIResource):
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
response_format: An object specifying the format that the model must output. Compatible with
- `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
+ [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
+ `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
@@ -418,6 +424,8 @@ class Completions(SyncAPIResource):
model: Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
@@ -531,7 +539,8 @@ class Completions(SyncAPIResource):
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
response_format: An object specifying the format that the model must output. Compatible with
- `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
+ [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
+ `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
@@ -604,6 +613,8 @@ class Completions(SyncAPIResource):
model: Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
@@ -698,6 +709,8 @@ class AsyncCompletions(AsyncAPIResource):
model: Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
@@ -804,7 +817,8 @@ class AsyncCompletions(AsyncAPIResource):
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
response_format: An object specifying the format that the model must output. Compatible with
- `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
+ [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
+ `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
@@ -884,6 +898,8 @@ class AsyncCompletions(AsyncAPIResource):
model: Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
@@ -997,7 +1013,8 @@ class AsyncCompletions(AsyncAPIResource):
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
response_format: An object specifying the format that the model must output. Compatible with
- `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
+ [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
+ `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
@@ -1070,6 +1087,8 @@ class AsyncCompletions(AsyncAPIResource):
model: Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
@@ -1183,7 +1202,8 @@ class AsyncCompletions(AsyncAPIResource):
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
response_format: An object specifying the format that the model must output. Compatible with
- `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
+ [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
+ `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
@@ -1256,6 +1276,8 @@ class AsyncCompletions(AsyncAPIResource):
model: Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
src/openai/resources/embeddings.py
@@ -36,7 +36,8 @@ class Embeddings(SyncAPIResource):
self,
*,
input: Union[str, List[str], List[int], List[List[int]]],
- model: Union[str, Literal["text-embedding-ada-002"]],
+ model: Union[str, Literal["text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large"]],
+ dimensions: int | NotGiven = NOT_GIVEN,
encoding_format: Literal["float", "base64"] | NotGiven = NOT_GIVEN,
user: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -64,6 +65,9 @@ class Embeddings(SyncAPIResource):
[Model overview](https://platform.openai.com/docs/models/overview) for
descriptions of them.
+ dimensions: The number of dimensions the resulting output embeddings should have. Only
+ supported in `text-embedding-3` and later models.
+
encoding_format: The format to return the embeddings in. Can be either `float` or
[`base64`](https://pypi.org/project/pybase64/).
@@ -83,6 +87,7 @@ class Embeddings(SyncAPIResource):
"input": input,
"model": model,
"user": user,
+ "dimensions": dimensions,
"encoding_format": encoding_format,
}
if not is_given(encoding_format) and has_numpy():
@@ -132,7 +137,8 @@ class AsyncEmbeddings(AsyncAPIResource):
self,
*,
input: Union[str, List[str], List[int], List[List[int]]],
- model: Union[str, Literal["text-embedding-ada-002"]],
+ model: Union[str, Literal["text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large"]],
+ dimensions: int | NotGiven = NOT_GIVEN,
encoding_format: Literal["float", "base64"] | NotGiven = NOT_GIVEN,
user: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -160,6 +166,9 @@ class AsyncEmbeddings(AsyncAPIResource):
[Model overview](https://platform.openai.com/docs/models/overview) for
descriptions of them.
+ dimensions: The number of dimensions the resulting output embeddings should have. Only
+ supported in `text-embedding-3` and later models.
+
encoding_format: The format to return the embeddings in. Can be either `float` or
[`base64`](https://pypi.org/project/pybase64/).
@@ -179,6 +188,7 @@ class AsyncEmbeddings(AsyncAPIResource):
"input": input,
"model": model,
"user": user,
+ "dimensions": dimensions,
"encoding_format": encoding_format,
}
if not is_given(encoding_format) and has_numpy():
src/openai/types/chat/completion_create_params.py
@@ -32,6 +32,8 @@ class CompletionCreateParamsBase(TypedDict, total=False):
Union[
str,
Literal[
+ "gpt-4-0125-preview",
+ "gpt-4-turbo-preview",
"gpt-4-1106-preview",
"gpt-4-vision-preview",
"gpt-4",
@@ -133,7 +135,9 @@ class CompletionCreateParamsBase(TypedDict, total=False):
response_format: ResponseFormat
"""An object specifying the format that the model must output.
- Compatible with `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
+ Compatible with
+ [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
+ `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
src/openai/types/embedding_create_params.py
@@ -20,7 +20,7 @@ class EmbeddingCreateParams(TypedDict, total=False):
for counting tokens.
"""
- model: Required[Union[str, Literal["text-embedding-ada-002"]]]
+ model: Required[Union[str, Literal["text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large"]]]
"""ID of the model to use.
You can use the
@@ -30,6 +30,12 @@ class EmbeddingCreateParams(TypedDict, total=False):
descriptions of them.
"""
+ dimensions: int
+ """The number of dimensions the resulting output embeddings should have.
+
+ Only supported in `text-embedding-3` and later models.
+ """
+
encoding_format: Literal["float", "base64"]
"""The format to return the embeddings in.
tests/api_resources/test_embeddings.py
@@ -21,7 +21,7 @@ class TestEmbeddings:
def test_method_create(self, client: OpenAI) -> None:
embedding = client.embeddings.create(
input="The quick brown fox jumped over the lazy dog",
- model="text-embedding-ada-002",
+ model="text-embedding-3-small",
)
assert_matches_type(CreateEmbeddingResponse, embedding, path=["response"])
@@ -29,7 +29,8 @@ class TestEmbeddings:
def test_method_create_with_all_params(self, client: OpenAI) -> None:
embedding = client.embeddings.create(
input="The quick brown fox jumped over the lazy dog",
- model="text-embedding-ada-002",
+ model="text-embedding-3-small",
+ dimensions=1,
encoding_format="float",
user="user-1234",
)
@@ -39,7 +40,7 @@ class TestEmbeddings:
def test_raw_response_create(self, client: OpenAI) -> None:
response = client.embeddings.with_raw_response.create(
input="The quick brown fox jumped over the lazy dog",
- model="text-embedding-ada-002",
+ model="text-embedding-3-small",
)
assert response.is_closed is True
@@ -51,7 +52,7 @@ class TestEmbeddings:
def test_streaming_response_create(self, client: OpenAI) -> None:
with client.embeddings.with_streaming_response.create(
input="The quick brown fox jumped over the lazy dog",
- model="text-embedding-ada-002",
+ model="text-embedding-3-small",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -69,7 +70,7 @@ class TestAsyncEmbeddings:
async def test_method_create(self, async_client: AsyncOpenAI) -> None:
embedding = await async_client.embeddings.create(
input="The quick brown fox jumped over the lazy dog",
- model="text-embedding-ada-002",
+ model="text-embedding-3-small",
)
assert_matches_type(CreateEmbeddingResponse, embedding, path=["response"])
@@ -77,7 +78,8 @@ class TestAsyncEmbeddings:
async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
embedding = await async_client.embeddings.create(
input="The quick brown fox jumped over the lazy dog",
- model="text-embedding-ada-002",
+ model="text-embedding-3-small",
+ dimensions=1,
encoding_format="float",
user="user-1234",
)
@@ -87,7 +89,7 @@ class TestAsyncEmbeddings:
async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None:
response = await async_client.embeddings.with_raw_response.create(
input="The quick brown fox jumped over the lazy dog",
- model="text-embedding-ada-002",
+ model="text-embedding-3-small",
)
assert response.is_closed is True
@@ -99,7 +101,7 @@ class TestAsyncEmbeddings:
async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None:
async with async_client.embeddings.with_streaming_response.create(
input="The quick brown fox jumped over the lazy dog",
- model="text-embedding-ada-002",
+ model="text-embedding-3-small",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"