Skip to content

feat(api): add incomplete state #1420

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 1 commit into from
May 14, 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 .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-47007cc1aa5bc7b74107a99b377925978a0bd376ed67bdae724e80d5d0b63d57.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-363dd904e5d6e65b3a323fc88e6b502fb23a6aa319be219273e3ee47c7530993.yml
18 changes: 12 additions & 6 deletions src/openai/resources/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create(
self,
*,
completion_window: Literal["24h"],
endpoint: Literal["/v1/chat/completions", "/v1/embeddings"],
endpoint: Literal["/v1/chat/completions", "/v1/embeddings", "/v1/completions"],
input_file_id: str,
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -58,7 +58,9 @@ def create(
is supported.

endpoint: The endpoint to be used for all requests in the batch. Currently
`/v1/chat/completions` and `/v1/embeddings` are supported.
`/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported.
Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000
embedding inputs across all requests in the batch.

input_file_id: The ID of an uploaded file that contains requests for the new batch.

Expand All @@ -67,7 +69,8 @@ def create(

Your input file must be formatted as a
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
and must be uploaded with the purpose `batch`.
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.

metadata: Optional custom metadata for the batch.

Expand Down Expand Up @@ -228,7 +231,7 @@ async def create(
self,
*,
completion_window: Literal["24h"],
endpoint: Literal["/v1/chat/completions", "/v1/embeddings"],
endpoint: Literal["/v1/chat/completions", "/v1/embeddings", "/v1/completions"],
input_file_id: str,
metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -246,7 +249,9 @@ async def create(
is supported.

endpoint: The endpoint to be used for all requests in the batch. Currently
`/v1/chat/completions` and `/v1/embeddings` are supported.
`/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported.
Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000
embedding inputs across all requests in the batch.

input_file_id: The ID of an uploaded file that contains requests for the new batch.

Expand All @@ -255,7 +260,8 @@ async def create(

Your input file must be formatted as a
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
and must be uploaded with the purpose `batch`.
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.

metadata: Optional custom metadata for the batch.

Expand Down
20 changes: 12 additions & 8 deletions src/openai/resources/beta/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ def create(
name: The name of the assistant. The maximum length is 256 characters.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -254,8 +255,9 @@ def update(
name: The name of the assistant. The maximum length is 256 characters.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -497,8 +499,9 @@ async def create(
name: The name of the assistant. The maximum length is 256 characters.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -641,8 +644,9 @@ async def update(
name: The name of the assistant. The maximum length is 256 characters.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down
34 changes: 20 additions & 14 deletions src/openai/resources/beta/threads/runs/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ def create(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -314,8 +315,9 @@ def create(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -460,8 +462,9 @@ def create(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -1097,7 +1100,7 @@ def poll(
if is_given(poll_interval_ms):
extra_headers["X-Stainless-Custom-Poll-Interval"] = str(poll_interval_ms)

terminal_states = {"requires_action", "cancelled", "completed", "failed", "expired"}
terminal_states = {"requires_action", "cancelled", "completed", "failed", "expired", "incomplete"}
while True:
response = self.with_raw_response.retrieve(
thread_id=thread_id,
Expand Down Expand Up @@ -1718,8 +1721,9 @@ async def create(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -1868,8 +1872,9 @@ async def create(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -2014,8 +2019,9 @@ async def create(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -2653,7 +2659,7 @@ async def poll(
if is_given(poll_interval_ms):
extra_headers["X-Stainless-Custom-Poll-Interval"] = str(poll_interval_ms)

terminal_states = {"requires_action", "cancelled", "completed", "failed", "expired"}
terminal_states = {"requires_action", "cancelled", "completed", "failed", "expired", "incomplete"}
while True:
response = await self.with_raw_response.retrieve(
thread_id=thread_id,
Expand Down
30 changes: 18 additions & 12 deletions src/openai/resources/beta/threads/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ def create_and_run(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -490,8 +491,9 @@ def create_and_run(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -635,8 +637,9 @@ def create_and_run(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -1331,8 +1334,9 @@ async def create_and_run(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -1480,8 +1484,9 @@ async def create_and_run(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -1625,8 +1630,9 @@ async def create_and_run(
assistant will be used.

response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
[GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down
36 changes: 22 additions & 14 deletions src/openai/resources/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ def create(
) -> FileObject:
"""Upload a file that can be used across various endpoints.

The size of all the
files uploaded by one organization can be up to 100 GB.
Individual files can be
up to 512 MB, and the size of all files uploaded by one organization can be up
to 100 GB.

The size of individual files can be a maximum of 512 MB or 2 million tokens for
Assistants. See the
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) to
learn more about the types of files supported. The Fine-tuning API only supports
`.jsonl` files.
The Assistants API supports files up to 2 million tokens and of specific file
types. See the
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
details.

The Fine-tuning API only supports `.jsonl` files.

The Batch API only supports `.jsonl` files up to 100 MB in size.

Please [contact us](https://help.openai.com/) if you need to increase these
storage limits.
Expand Down Expand Up @@ -335,14 +339,18 @@ async def create(
) -> FileObject:
"""Upload a file that can be used across various endpoints.

The size of all the
files uploaded by one organization can be up to 100 GB.
Individual files can be
up to 512 MB, and the size of all files uploaded by one organization can be up
to 100 GB.

The Assistants API supports files up to 2 million tokens and of specific file
types. See the
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
details.

The Fine-tuning API only supports `.jsonl` files.

The size of individual files can be a maximum of 512 MB or 2 million tokens for
Assistants. See the
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) to
learn more about the types of files supported. The Fine-tuning API only supports
`.jsonl` files.
The Batch API only supports `.jsonl` files up to 100 MB in size.

Please [contact us](https://help.openai.com/) if you need to increase these
storage limits.
Expand Down
9 changes: 6 additions & 3 deletions src/openai/types/batch_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ class BatchCreateParams(TypedDict, total=False):
Currently only `24h` is supported.
"""

endpoint: Required[Literal["/v1/chat/completions", "/v1/embeddings"]]
endpoint: Required[Literal["/v1/chat/completions", "/v1/embeddings", "/v1/completions"]]
"""The endpoint to be used for all requests in the batch.

Currently `/v1/chat/completions` and `/v1/embeddings` are supported.
Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are
supported. Note that `/v1/embeddings` batches are also restricted to a maximum
of 50,000 embedding inputs across all requests in the batch.
"""

input_file_id: Required[str]
Expand All @@ -29,7 +31,8 @@ class BatchCreateParams(TypedDict, total=False):

Your input file must be formatted as a
[JSONL file](https://platform.openai.com/docs/api-reference/batch/requestInput),
and must be uploaded with the purpose `batch`.
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.
"""

metadata: Optional[Dict[str, str]]
Expand Down
6 changes: 3 additions & 3 deletions src/openai/types/beta/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class Assistant(BaseModel):
response_format: Optional[AssistantResponseFormatOption] = None
"""Specifies the format that the model must output.

Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Compatible with [GPT-4o](https://platform.openai.com/docs/models/gpt-4o),
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4),
and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down
Loading