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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ With an image URL:

```python
prompt = "What is in this image?"
img_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/2023_06_08_Raccoon1.jpg/1599px-2023_06_08_Raccoon1.jpg"
img_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/2023_06_08_Raccoon1.jpg/440px-2023_06_08_Raccoon1.jpg"

response = client.responses.create(
model="gpt-5.2",
Expand Down
34 changes: 34 additions & 0 deletions src/openai/resources/beta/beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
ThreadsWithStreamingResponse,
AsyncThreadsWithStreamingResponse,
)
from ..vector_stores import (
VectorStores,
AsyncVectorStores,
VectorStoresWithRawResponse,
AsyncVectorStoresWithRawResponse,
VectorStoresWithStreamingResponse,
AsyncVectorStoresWithStreamingResponse,
)
from ...resources.chat import Chat, AsyncChat
from .realtime.realtime import (
Realtime,
Expand Down Expand Up @@ -60,6 +68,11 @@ def threads(self) -> Threads:
"""Build Assistants that can call models and use tools."""
return Threads(self._client)

@cached_property
def vector_stores(self) -> VectorStores:
"""Backwards-compatible access to Assistants v2 vector stores."""
return self._client.vector_stores

@cached_property
def with_raw_response(self) -> BetaWithRawResponse:
"""
Expand Down Expand Up @@ -103,6 +116,11 @@ def threads(self) -> AsyncThreads:
"""Build Assistants that can call models and use tools."""
return AsyncThreads(self._client)

@cached_property
def vector_stores(self) -> AsyncVectorStores:
"""Backwards-compatible access to Assistants v2 vector stores."""
return self._client.vector_stores

@cached_property
def with_raw_response(self) -> AsyncBetaWithRawResponse:
"""
Expand Down Expand Up @@ -141,6 +159,10 @@ def threads(self) -> ThreadsWithRawResponse:
"""Build Assistants that can call models and use tools."""
return ThreadsWithRawResponse(self._beta.threads)

@cached_property
def vector_stores(self) -> VectorStoresWithRawResponse:
return VectorStoresWithRawResponse(self._beta.vector_stores)


class AsyncBetaWithRawResponse:
def __init__(self, beta: AsyncBeta) -> None:
Expand All @@ -160,6 +182,10 @@ def threads(self) -> AsyncThreadsWithRawResponse:
"""Build Assistants that can call models and use tools."""
return AsyncThreadsWithRawResponse(self._beta.threads)

@cached_property
def vector_stores(self) -> AsyncVectorStoresWithRawResponse:
return AsyncVectorStoresWithRawResponse(self._beta.vector_stores)


class BetaWithStreamingResponse:
def __init__(self, beta: Beta) -> None:
Expand All @@ -179,6 +205,10 @@ def threads(self) -> ThreadsWithStreamingResponse:
"""Build Assistants that can call models and use tools."""
return ThreadsWithStreamingResponse(self._beta.threads)

@cached_property
def vector_stores(self) -> VectorStoresWithStreamingResponse:
return VectorStoresWithStreamingResponse(self._beta.vector_stores)


class AsyncBetaWithStreamingResponse:
def __init__(self, beta: AsyncBeta) -> None:
Expand All @@ -197,3 +227,7 @@ def assistants(self) -> AsyncAssistantsWithStreamingResponse:
def threads(self) -> AsyncThreadsWithStreamingResponse:
"""Build Assistants that can call models and use tools."""
return AsyncThreadsWithStreamingResponse(self._beta.threads)

@cached_property
def vector_stores(self) -> AsyncVectorStoresWithStreamingResponse:
return AsyncVectorStoresWithStreamingResponse(self._beta.vector_stores)
10 changes: 10 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ def test_copy(self, client: OpenAI) -> None:
assert copied.admin_api_key == "another My Admin API Key"
assert client.admin_api_key == "My Admin API Key"

def test_beta_vector_stores_alias(self, client: OpenAI) -> None:
assert client.beta.vector_stores is client.vector_stores
assert client.beta.with_raw_response.vector_stores._vector_stores is client.vector_stores
assert client.beta.with_streaming_response.vector_stores._vector_stores is client.vector_stores

def test_copy_default_options(self, client: OpenAI) -> None:
# options that have a default are overridden correctly
copied = client.copy(max_retries=7)
Expand Down Expand Up @@ -1420,6 +1425,11 @@ def test_copy(self, async_client: AsyncOpenAI) -> None:
assert copied.admin_api_key == "another My Admin API Key"
assert async_client.admin_api_key == "My Admin API Key"

def test_beta_vector_stores_alias(self, async_client: AsyncOpenAI) -> None:
assert async_client.beta.vector_stores is async_client.vector_stores
assert async_client.beta.with_raw_response.vector_stores._vector_stores is async_client.vector_stores
assert async_client.beta.with_streaming_response.vector_stores._vector_stores is async_client.vector_stores

def test_copy_default_options(self, async_client: AsyncOpenAI) -> None:
# options that have a default are overridden correctly
copied = async_client.copy(max_retries=7)
Expand Down