Skip to content
Open
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
4 changes: 4 additions & 0 deletions portkey_ai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
AsyncChatKitThreads,
Calls,
AsyncCalls,
InputTokens,
AsyncInputTokens,
)

from portkey_ai.version import VERSION
Expand Down Expand Up @@ -329,4 +331,6 @@
"AsyncChatKitThreads",
"Calls",
"AsyncCalls",
"InputTokens",
"AsyncInputTokens",
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.3
Name: openai
Version: 2.2.0
Version: 2.7.1
Summary: The official Python library for the openai API
Project-URL: Homepage, https://github.com/openai/openai-python
Project-URL: Repository, https://github.com/openai/openai-python
Expand All @@ -25,14 +25,14 @@ Requires-Python: >=3.8
Requires-Dist: anyio<5,>=3.5.0
Requires-Dist: distro<2,>=1.7.0
Requires-Dist: httpx<1,>=0.23.0
Requires-Dist: jiter<1,>=0.4.0
Requires-Dist: jiter<1,>=0.10.0
Requires-Dist: pydantic<3,>=1.9.0
Requires-Dist: sniffio
Requires-Dist: tqdm>4
Requires-Dist: typing-extensions<5,>=4.11
Provides-Extra: aiohttp
Requires-Dist: aiohttp; extra == 'aiohttp'
Requires-Dist: httpx-aiohttp>=0.1.8; extra == 'aiohttp'
Requires-Dist: httpx-aiohttp>=0.1.9; extra == 'aiohttp'
Provides-Extra: datalib
Requires-Dist: numpy>=1; extra == 'datalib'
Requires-Dist: pandas-stubs>=1.1.0.11; extra == 'datalib'
Expand Down Expand Up @@ -290,7 +290,9 @@ async def main():
client = AsyncOpenAI()

async with client.realtime.connect(model="gpt-realtime") as connection:
await connection.session.update(session={'modalities': ['text']})
await connection.session.update(
session={"type": "realtime", "output_modalities": ["text"]}
)

await connection.conversation.item.create(
item={
Expand All @@ -302,10 +304,10 @@ async def main():
await connection.response.create()

async for event in connection:
if event.type == 'response.text.delta':
if event.type == "response.output_text.delta":
print(event.delta, flush=True, end="")

elif event.type == 'response.text.done':
elif event.type == "response.output_text.done":
print()

elif event.type == "response.done":
Expand Down

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions portkey_ai/_vendor/openai/_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ def __stream__(self) -> Iterator[_T]:

yield process_data(data=data, cast_to=cast_to, response=response)

# Ensure the entire stream is consumed
for _sse in iterator:
...
# As we might not fully consume the response stream, we need to close it explicitly
response.close()

def __enter__(self) -> Self:
return self
Expand Down Expand Up @@ -198,9 +197,8 @@ async def __stream__(self) -> AsyncIterator[_T]:

yield process_data(data=data, cast_to=cast_to, response=response)

# Ensure the entire stream is consumed
async for _sse in iterator:
...
# As we might not fully consume the response stream, we need to close it explicitly
await response.aclose()

async def __aenter__(self) -> Self:
return self
Expand Down
2 changes: 1 addition & 1 deletion portkey_ai/_vendor/openai/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]:
# Type safe methods for narrowing types with TypeVars.
# The default narrowing for isinstance(obj, dict) is dict[unknown, unknown],
# however this cause Pyright to rightfully report errors. As we know we don't
# care about the contained types we can safely use `object` in it's place.
# care about the contained types we can safely use `object` in its place.
#
# There are two separate functions defined, `is_*` and `is_*_t` for different use cases.
# `is_*` is for when you're dealing with an unknown input
Expand Down
2 changes: 1 addition & 1 deletion portkey_ai/_vendor/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__ = "2.2.0" # x-release-please-version
__version__ = "2.7.1" # x-release-please-version
284 changes: 241 additions & 43 deletions portkey_ai/_vendor/openai/resources/audio/transcriptions.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions portkey_ai/_vendor/openai/resources/audio/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def __init__(self, translations: AsyncTranslations) -> None:


def _get_response_format_type(
response_format: Literal["json", "text", "srt", "verbose_json", "vtt"] | Omit,
response_format: AudioResponseFormat | Omit,
) -> type[Translation | TranslationVerbose | str]:
if isinstance(response_format, Omit) or response_format is None: # pyright: ignore[reportUnnecessaryComparison]
return Translation
Expand All @@ -360,8 +360,8 @@ def _get_response_format_type(
return TranslationVerbose
elif response_format == "srt" or response_format == "text" or response_format == "vtt":
return str
elif TYPE_CHECKING: # type: ignore[unreachable]
elif TYPE_CHECKING and response_format != "diarized_json": # type: ignore[unreachable]
assert_never(response_format)
else:
log.warn("Unexpected audio response format: %s", response_format)
return Transcription
log.warning("Unexpected audio response format: %s", response_format)
return Translation
12 changes: 12 additions & 0 deletions portkey_ai/_vendor/openai/resources/beta/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ def create(
effort can result in faster responses and fewer tokens used on reasoning in a
response.

Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning
effort.

response_format: Specifies the format that the model must output. 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),
Expand Down Expand Up @@ -309,6 +312,9 @@ def update(
effort can result in faster responses and fewer tokens used on reasoning in a
response.

Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning
effort.

response_format: Specifies the format that the model must output. 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),
Expand Down Expand Up @@ -555,6 +561,9 @@ async def create(
effort can result in faster responses and fewer tokens used on reasoning in a
response.

Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning
effort.

response_format: Specifies the format that the model must output. 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),
Expand Down Expand Up @@ -762,6 +771,9 @@ async def update(
effort can result in faster responses and fewer tokens used on reasoning in a
response.

Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning
effort.

response_format: Specifies the format that the model must output. 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),
Expand Down
125 changes: 0 additions & 125 deletions portkey_ai/_vendor/openai/resources/beta/chatkit/chatkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

from __future__ import annotations

from typing import Any, Mapping, cast

import httpx

from .... import _legacy_response
from .threads import (
Threads,
AsyncThreads,
Expand All @@ -23,14 +18,8 @@
SessionsWithStreamingResponse,
AsyncSessionsWithStreamingResponse,
)
from ...._types import Body, Query, Headers, NotGiven, FileTypes, not_given
from ...._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ....types.beta import chatkit_upload_file_params
from ...._base_client import make_request_options
from ....types.beta.chatkit_upload_file_response import ChatKitUploadFileResponse

__all__ = ["ChatKit", "AsyncChatKit"]

Expand Down Expand Up @@ -63,55 +52,6 @@ def with_streaming_response(self) -> ChatKitWithStreamingResponse:
"""
return ChatKitWithStreamingResponse(self)

def upload_file(
self,
*,
file: FileTypes,
# 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ChatKitUploadFileResponse:
"""
Upload a ChatKit file

Args:
file: Binary file contents to store with the ChatKit session. Supports PDFs and PNG,
JPG, JPEG, GIF, or WEBP images.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {"OpenAI-Beta": "chatkit_beta=v1", **(extra_headers or {})}
body = deepcopy_minimal({"file": file})
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
if files:
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers["Content-Type"] = "multipart/form-data"
return cast(
ChatKitUploadFileResponse,
self._post(
"/chatkit/files",
body=maybe_transform(body, chatkit_upload_file_params.ChatKitUploadFileParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(
Any, ChatKitUploadFileResponse
), # Union types cannot be passed in as arguments in the type system
),
)


class AsyncChatKit(AsyncAPIResource):
@cached_property
Expand Down Expand Up @@ -141,64 +81,11 @@ def with_streaming_response(self) -> AsyncChatKitWithStreamingResponse:
"""
return AsyncChatKitWithStreamingResponse(self)

async def upload_file(
self,
*,
file: FileTypes,
# 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ChatKitUploadFileResponse:
"""
Upload a ChatKit file

Args:
file: Binary file contents to store with the ChatKit session. Supports PDFs and PNG,
JPG, JPEG, GIF, or WEBP images.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {"OpenAI-Beta": "chatkit_beta=v1", **(extra_headers or {})}
body = deepcopy_minimal({"file": file})
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
if files:
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers["Content-Type"] = "multipart/form-data"
return cast(
ChatKitUploadFileResponse,
await self._post(
"/chatkit/files",
body=await async_maybe_transform(body, chatkit_upload_file_params.ChatKitUploadFileParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(
Any, ChatKitUploadFileResponse
), # Union types cannot be passed in as arguments in the type system
),
)


class ChatKitWithRawResponse:
def __init__(self, chatkit: ChatKit) -> None:
self._chatkit = chatkit

self.upload_file = _legacy_response.to_raw_response_wrapper(
chatkit.upload_file,
)

@cached_property
def sessions(self) -> SessionsWithRawResponse:
return SessionsWithRawResponse(self._chatkit.sessions)
Expand All @@ -212,10 +99,6 @@ class AsyncChatKitWithRawResponse:
def __init__(self, chatkit: AsyncChatKit) -> None:
self._chatkit = chatkit

self.upload_file = _legacy_response.async_to_raw_response_wrapper(
chatkit.upload_file,
)

@cached_property
def sessions(self) -> AsyncSessionsWithRawResponse:
return AsyncSessionsWithRawResponse(self._chatkit.sessions)
Expand All @@ -229,10 +112,6 @@ class ChatKitWithStreamingResponse:
def __init__(self, chatkit: ChatKit) -> None:
self._chatkit = chatkit

self.upload_file = to_streamed_response_wrapper(
chatkit.upload_file,
)

@cached_property
def sessions(self) -> SessionsWithStreamingResponse:
return SessionsWithStreamingResponse(self._chatkit.sessions)
Expand All @@ -246,10 +125,6 @@ class AsyncChatKitWithStreamingResponse:
def __init__(self, chatkit: AsyncChatKit) -> None:
self._chatkit = chatkit

self.upload_file = async_to_streamed_response_wrapper(
chatkit.upload_file,
)

@cached_property
def sessions(self) -> AsyncSessionsWithStreamingResponse:
return AsyncSessionsWithStreamingResponse(self._chatkit.sessions)
Expand Down
Loading
Loading