Skip to content

Commit

Permalink
v1.1.1 (openai#689)
Browse files Browse the repository at this point in the history
* feat(client): support passing httpx.Timeout to method timeout argument

* fix(api): retreival -> retrieval

* fix(docs): use correct branch name in github links

* v1.1.1
  • Loading branch information
RobertCraigie authored and megamanics committed Aug 14, 2024
1 parent c0823d8 commit f3354fb
Show file tree
Hide file tree
Showing 31 changed files with 192 additions and 152 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ completion = response.parse() # get the object that `chat.completions.create()`
print(completion)
```

These methods return an [`APIResponse`](https://github.com/openai/openai-python/tree/v1/src/openai/_response.py) object.
These methods return an [`APIResponse`](https://github.com/openai/openai-python/src/openai/_response.py) object.

### Configuring the HTTP client

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.1.0"
version = "1.1.1"
description = "Client library for the openai API"
readme = "README.md"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/openai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ def make_request_options(
extra_query: Query | None = None,
extra_body: Body | None = None,
idempotency_key: str | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
post_parser: PostParser | NotGiven = NOT_GIVEN,
) -> RequestOptions:
"""Create a dict of type RequestOptions without keys of NotGiven values."""
Expand Down
2 changes: 1 addition & 1 deletion src/openai/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
if not is_file_content(obj):
prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`"
raise RuntimeError(
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/openai/openai-python/tree/v1#file-uploads"
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/openai/openai-python#file-uploads"
) from None


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.

__title__ = "openai"
__version__ = "1.1.0"
__version__ = "1.1.1"
6 changes: 4 additions & 2 deletions src/openai/resources/audio/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import TYPE_CHECKING, Union
from typing_extensions import Literal

import httpx

from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import maybe_transform
from ..._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -38,7 +40,7 @@ def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> HttpxBinaryResponseContent:
"""
Generates audio from the input text.
Expand Down Expand Up @@ -105,7 +107,7 @@ async def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> HttpxBinaryResponseContent:
"""
Generates audio from the input text.
Expand Down
6 changes: 4 additions & 2 deletions src/openai/resources/audio/transcriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import TYPE_CHECKING, Union, Mapping, cast
from typing_extensions import Literal

import httpx

from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ..._utils import extract_files, maybe_transform, deepcopy_minimal
from ..._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -39,7 +41,7 @@ def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Transcription:
"""
Transcribes audio into the input language.
Expand Down Expand Up @@ -126,7 +128,7 @@ async def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Transcription:
"""
Transcribes audio into the input language.
Expand Down
6 changes: 4 additions & 2 deletions src/openai/resources/audio/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import TYPE_CHECKING, Union, Mapping, cast
from typing_extensions import Literal

import httpx

from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ..._utils import extract_files, maybe_transform, deepcopy_minimal
from ..._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -38,7 +40,7 @@ def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Translation:
"""
Translates audio into English.
Expand Down Expand Up @@ -118,7 +120,7 @@ async def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Translation:
"""
Translates audio into English.
Expand Down
22 changes: 12 additions & 10 deletions src/openai/resources/beta/assistants/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import TYPE_CHECKING, List, Optional
from typing_extensions import Literal

import httpx

from .files import Files, AsyncFiles, FilesWithRawResponse, AsyncFilesWithRawResponse
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform
Expand Down Expand Up @@ -50,7 +52,7 @@ def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Assistant:
"""
Create an assistant with a model and instructions.
Expand Down Expand Up @@ -119,7 +121,7 @@ def retrieve(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Assistant:
"""
Retrieves an assistant.
Expand Down Expand Up @@ -158,7 +160,7 @@ def update(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Assistant:
"""Modifies an assistant.
Expand Down Expand Up @@ -233,7 +235,7 @@ def list(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncCursorPage[Assistant]:
"""Returns a list of assistants.
Expand Down Expand Up @@ -295,7 +297,7 @@ def delete(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsssitantDeleted:
"""
Delete an assistant.
Expand Down Expand Up @@ -343,7 +345,7 @@ async def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Assistant:
"""
Create an assistant with a model and instructions.
Expand Down Expand Up @@ -412,7 +414,7 @@ async def retrieve(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Assistant:
"""
Retrieves an assistant.
Expand Down Expand Up @@ -451,7 +453,7 @@ async def update(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Assistant:
"""Modifies an assistant.
Expand Down Expand Up @@ -526,7 +528,7 @@ def list(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[Assistant, AsyncCursorPage[Assistant]]:
"""Returns a list of assistants.
Expand Down Expand Up @@ -588,7 +590,7 @@ async def delete(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsssitantDeleted:
"""
Delete an assistant.
Expand Down
18 changes: 10 additions & 8 deletions src/openai/resources/beta/assistants/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import TYPE_CHECKING
from typing_extensions import Literal

import httpx

from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._utils import maybe_transform
from ...._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -41,7 +43,7 @@ def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AssistantFile:
"""
Create an assistant file by attaching a
Expand Down Expand Up @@ -81,7 +83,7 @@ def retrieve(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AssistantFile:
"""
Retrieves an AssistantFile.
Expand Down Expand Up @@ -117,7 +119,7 @@ def list(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncCursorPage[AssistantFile]:
"""
Returns a list of assistant files.
Expand Down Expand Up @@ -179,7 +181,7 @@ def delete(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> FileDeleteResponse:
"""
Delete an assistant file.
Expand Down Expand Up @@ -220,7 +222,7 @@ async def create(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AssistantFile:
"""
Create an assistant file by attaching a
Expand Down Expand Up @@ -260,7 +262,7 @@ async def retrieve(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AssistantFile:
"""
Retrieves an AssistantFile.
Expand Down Expand Up @@ -296,7 +298,7 @@ def list(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[AssistantFile, AsyncCursorPage[AssistantFile]]:
"""
Returns a list of assistant files.
Expand Down Expand Up @@ -358,7 +360,7 @@ async def delete(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> FileDeleteResponse:
"""
Delete an assistant file.
Expand Down
10 changes: 6 additions & 4 deletions src/openai/resources/beta/threads/messages/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import TYPE_CHECKING
from typing_extensions import Literal

import httpx

from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ....._utils import maybe_transform
from ....._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -37,7 +39,7 @@ def retrieve(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> MessageFile:
"""
Retrieves a message file.
Expand Down Expand Up @@ -74,7 +76,7 @@ def list(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncCursorPage[MessageFile]:
"""Returns a list of message files.
Expand Down Expand Up @@ -146,7 +148,7 @@ async def retrieve(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> MessageFile:
"""
Retrieves a message file.
Expand Down Expand Up @@ -183,7 +185,7 @@ def list(
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | None | NotGiven = NOT_GIVEN,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[MessageFile, AsyncCursorPage[MessageFile]]:
"""Returns a list of message files.
Expand Down
Loading

0 comments on commit f3354fb

Please sign in to comment.