Skip to content

release: 1.31.0 #1462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.30.5"
".": "1.31.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 64
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-363dd904e5d6e65b3a323fc88e6b502fb23a6aa319be219273e3ee47c7530993.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-0577fd0d08da6b867b002a5accd45f7116ef91c4940b41cf45dc479938c77163.yml
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 1.31.0 (2024-06-03)

Full Changelog: [v1.30.5...v1.31.0](https://github.com/openai/openai-python/compare/v1.30.5...v1.31.0)

### Features

* **api:** updates ([#1461](https://github.com/openai/openai-python/issues/1461)) ([0d7cc5e](https://github.com/openai/openai-python/commit/0d7cc5e48c565fe10ee6e8ca4d050175eb543bcb))


### Chores

* fix lint ([1886dd4](https://github.com/openai/openai-python/commit/1886dd4c98d7a7b3a679bff739cb38badf5ae96c))

## 1.30.5 (2024-05-29)

Full Changelog: [v1.30.4...v1.30.5](https://github.com/openai/openai-python/compare/v1.30.4...v1.30.5)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openai"
version = "1.30.5"
version = "1.31.0"
description = "The official Python library for the openai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/openai/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "openai"
__version__ = "1.30.5" # x-release-please-version
__version__ = "1.31.0" # x-release-please-version
2 changes: 1 addition & 1 deletion src/openai/lib/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ async def _get_azure_ad_token(self) -> str | None:
raise ValueError(
f"Expected `azure_ad_token_provider` argument to return a string but it returned {token}",
)
return token
return str(token)

return None

Expand Down
2 changes: 2 additions & 0 deletions src/openai/lib/streaming/_assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ def _emit_sse_event(self, event: AssistantStreamEvent) -> None:
or event.event == "thread.run.expired"
or event.event == "thread.run.failed"
or event.event == "thread.run.requires_action"
or event.event == "thread.run.incomplete"
):
self.__current_run = event.data
if self._current_tool_call:
Expand Down Expand Up @@ -711,6 +712,7 @@ async def _emit_sse_event(self, event: AssistantStreamEvent) -> None:
or event.event == "thread.run.expired"
or event.event == "thread.run.failed"
or event.event == "thread.run.requires_action"
or event.event == "thread.run.incomplete"
):
self.__current_run = event.data
if self._current_tool_call:
Expand Down
18 changes: 12 additions & 6 deletions src/openai/resources/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create(
for how to upload a file.

Your input file must be formatted as a
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
[JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
and must be uploaded with the purpose `batch`. The file can contain up to 50,000
requests, and can be up to 100 MB in size.

Expand Down Expand Up @@ -195,8 +195,11 @@ def cancel(
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Batch:
"""
Cancels an in-progress batch.
"""Cancels an in-progress batch.

The batch will be in status `cancelling` for up to
10 minutes, before changing to `cancelled`, where it will have partial results
(if any) available in the output file.

Args:
extra_headers: Send extra headers
Expand Down Expand Up @@ -259,7 +262,7 @@ async def create(
for how to upload a file.

Your input file must be formatted as a
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
[JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
and must be uploaded with the purpose `batch`. The file can contain up to 50,000
requests, and can be up to 100 MB in size.

Expand Down Expand Up @@ -386,8 +389,11 @@ async def cancel(
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Batch:
"""
Cancels an in-progress batch.
"""Cancels an in-progress batch.

The batch will be in status `cancelling` for up to
10 minutes, before changing to `cancelled`, where it will have partial results
(if any) available in the output file.

Args:
extra_headers: Send extra headers
Expand Down
24 changes: 22 additions & 2 deletions src/openai/resources/beta/vector_stores/file_batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def create(
vector_store_id: str,
*,
file_ids: List[str],
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -62,6 +63,9 @@ def create(
the vector store should use. Useful for tools like `file_search` that can access
files.

chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
strategy.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -75,7 +79,13 @@ def create(
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
return self._post(
f"/vector_stores/{vector_store_id}/file_batches",
body=maybe_transform({"file_ids": file_ids}, file_batch_create_params.FileBatchCreateParams),
body=maybe_transform(
{
"file_ids": file_ids,
"chunking_strategy": chunking_strategy,
},
file_batch_create_params.FileBatchCreateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -351,6 +361,7 @@ async def create(
vector_store_id: str,
*,
file_ids: List[str],
chunking_strategy: file_batch_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -366,6 +377,9 @@ async def create(
the vector store should use. Useful for tools like `file_search` that can access
files.

chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
strategy.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -379,7 +393,13 @@ async def create(
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
return await self._post(
f"/vector_stores/{vector_store_id}/file_batches",
body=await async_maybe_transform({"file_ids": file_ids}, file_batch_create_params.FileBatchCreateParams),
body=await async_maybe_transform(
{
"file_ids": file_ids,
"chunking_strategy": chunking_strategy,
},
file_batch_create_params.FileBatchCreateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down
24 changes: 22 additions & 2 deletions src/openai/resources/beta/vector_stores/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def create(
vector_store_id: str,
*,
file_id: str,
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -60,6 +61,9 @@ def create(
vector store should use. Useful for tools like `file_search` that can access
files.

chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
strategy.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -73,7 +77,13 @@ def create(
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
return self._post(
f"/vector_stores/{vector_store_id}/files",
body=maybe_transform({"file_id": file_id}, file_create_params.FileCreateParams),
body=maybe_transform(
{
"file_id": file_id,
"chunking_strategy": chunking_strategy,
},
file_create_params.FileCreateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -330,6 +340,7 @@ async def create(
vector_store_id: str,
*,
file_id: str,
chunking_strategy: file_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -347,6 +358,9 @@ async def create(
vector store should use. Useful for tools like `file_search` that can access
files.

chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
strategy.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -360,7 +374,13 @@ async def create(
extra_headers = {"OpenAI-Beta": "assistants=v2", **(extra_headers or {})}
return await self._post(
f"/vector_stores/{vector_store_id}/files",
body=await async_maybe_transform({"file_id": file_id}, file_create_params.FileCreateParams),
body=await async_maybe_transform(
{
"file_id": file_id,
"chunking_strategy": chunking_strategy,
},
file_create_params.FileCreateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down
10 changes: 10 additions & 0 deletions src/openai/resources/beta/vector_stores/vector_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def with_streaming_response(self) -> VectorStoresWithStreamingResponse:
def create(
self,
*,
chunking_strategy: vector_store_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
expires_after: vector_store_create_params.ExpiresAfter | NotGiven = NOT_GIVEN,
file_ids: List[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
Expand All @@ -79,6 +80,9 @@ def create(
Create a vector store.

Args:
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
strategy. Only applicable if `file_ids` is non-empty.

expires_after: The expiration policy for a vector store.

file_ids: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
Expand All @@ -105,6 +109,7 @@ def create(
"/vector_stores",
body=maybe_transform(
{
"chunking_strategy": chunking_strategy,
"expires_after": expires_after,
"file_ids": file_ids,
"metadata": metadata,
Expand Down Expand Up @@ -326,6 +331,7 @@ def with_streaming_response(self) -> AsyncVectorStoresWithStreamingResponse:
async def create(
self,
*,
chunking_strategy: vector_store_create_params.ChunkingStrategy | NotGiven = NOT_GIVEN,
expires_after: vector_store_create_params.ExpiresAfter | NotGiven = NOT_GIVEN,
file_ids: List[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
Expand All @@ -341,6 +347,9 @@ async def create(
Create a vector store.

Args:
chunking_strategy: The chunking strategy used to chunk the file(s). If not set, will use the `auto`
strategy. Only applicable if `file_ids` is non-empty.

expires_after: The expiration policy for a vector store.

file_ids: A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
Expand All @@ -367,6 +376,7 @@ async def create(
"/vector_stores",
body=await async_maybe_transform(
{
"chunking_strategy": chunking_strategy,
"expires_after": expires_after,
"file_ids": file_ids,
"metadata": metadata,
Expand Down
24 changes: 18 additions & 6 deletions src/openai/resources/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create(
self,
*,
file: FileTypes,
purpose: Literal["assistants", "batch", "fine-tune"],
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -71,9 +71,15 @@ def create(
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
details.

The Fine-tuning API only supports `.jsonl` files.
The Fine-tuning API only supports `.jsonl` files. The input also has certain
required formats for fine-tuning
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
models.

The Batch API only supports `.jsonl` files up to 100 MB in size.
The Batch API only supports `.jsonl` files up to 100 MB in size. The input also
has a specific required
[format](https://platform.openai.com/docs/api-reference/batch/request-input).

Please [contact us](https://help.openai.com/) if you need to increase these
storage limits.
Expand Down Expand Up @@ -329,7 +335,7 @@ async def create(
self,
*,
file: FileTypes,
purpose: Literal["assistants", "batch", "fine-tune"],
purpose: Literal["assistants", "batch", "fine-tune", "vision"],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -348,9 +354,15 @@ async def create(
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
details.

The Fine-tuning API only supports `.jsonl` files.
The Fine-tuning API only supports `.jsonl` files. The input also has certain
required formats for fine-tuning
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
models.

The Batch API only supports `.jsonl` files up to 100 MB in size.
The Batch API only supports `.jsonl` files up to 100 MB in size. The input also
has a specific required
[format](https://platform.openai.com/docs/api-reference/batch/request-input).

Please [contact us](https://help.openai.com/) if you need to increase these
storage limits.
Expand Down
10 changes: 10 additions & 0 deletions src/openai/resources/fine_tuning/jobs/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def create(
Your dataset must be formatted as a JSONL file. Additionally, you must upload
your file with the purpose `fine-tune`.

The contents of the file should differ depending on if the model uses the
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
format.

See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
for more details.

Expand Down Expand Up @@ -362,6 +367,11 @@ async def create(
Your dataset must be formatted as a JSONL file. Additionally, you must upload
your file with the purpose `fine-tune`.

The contents of the file should differ depending on if the model uses the
[chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
[completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
format.

See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
for more details.

Expand Down
2 changes: 1 addition & 1 deletion src/openai/types/batch_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BatchCreateParams(TypedDict, total=False):
for how to upload a file.

Your input file must be formatted as a
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
[JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
and must be uploaded with the purpose `batch`. The file can contain up to 50,000
requests, and can be up to 100 MB in size.
"""
Expand Down
Loading