Skip to content

docs(examples): use named params more #1543

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
Jul 11, 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
16 changes: 8 additions & 8 deletions tests/api_resources/audio/test_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestSpeech:
def test_method_create(self, client: OpenAI, respx_mock: MockRouter) -> None:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
speech = client.audio.speech.create(
input="string",
input="input",
model="string",
voice="alloy",
)
Expand All @@ -38,7 +38,7 @@ def test_method_create(self, client: OpenAI, respx_mock: MockRouter) -> None:
def test_method_create_with_all_params(self, client: OpenAI, respx_mock: MockRouter) -> None:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
speech = client.audio.speech.create(
input="string",
input="input",
model="string",
voice="alloy",
response_format="mp3",
Expand All @@ -53,7 +53,7 @@ def test_raw_response_create(self, client: OpenAI, respx_mock: MockRouter) -> No
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))

response = client.audio.speech.with_raw_response.create(
input="string",
input="input",
model="string",
voice="alloy",
)
Expand All @@ -68,7 +68,7 @@ def test_raw_response_create(self, client: OpenAI, respx_mock: MockRouter) -> No
def test_streaming_response_create(self, client: OpenAI, respx_mock: MockRouter) -> None:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
with client.audio.speech.with_streaming_response.create(
input="string",
input="input",
model="string",
voice="alloy",
) as response:
Expand All @@ -89,7 +89,7 @@ class TestAsyncSpeech:
async def test_method_create(self, async_client: AsyncOpenAI, respx_mock: MockRouter) -> None:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
speech = await async_client.audio.speech.create(
input="string",
input="input",
model="string",
voice="alloy",
)
Expand All @@ -101,7 +101,7 @@ async def test_method_create(self, async_client: AsyncOpenAI, respx_mock: MockRo
async def test_method_create_with_all_params(self, async_client: AsyncOpenAI, respx_mock: MockRouter) -> None:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
speech = await async_client.audio.speech.create(
input="string",
input="input",
model="string",
voice="alloy",
response_format="mp3",
Expand All @@ -116,7 +116,7 @@ async def test_raw_response_create(self, async_client: AsyncOpenAI, respx_mock:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))

response = await async_client.audio.speech.with_raw_response.create(
input="string",
input="input",
model="string",
voice="alloy",
)
Expand All @@ -131,7 +131,7 @@ async def test_raw_response_create(self, async_client: AsyncOpenAI, respx_mock:
async def test_streaming_response_create(self, async_client: AsyncOpenAI, respx_mock: MockRouter) -> None:
respx_mock.post("/audio/speech").mock(return_value=httpx.Response(200, json={"foo": "bar"}))
async with async_client.audio.speech.with_streaming_response.create(
input="string",
input="input",
model="string",
voice="alloy",
) as response:
Expand Down
8 changes: 4 additions & 4 deletions tests/api_resources/audio/test_transcriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None:
transcription = client.audio.transcriptions.create(
file=b"raw file contents",
model="whisper-1",
language="string",
prompt="string",
language="language",
prompt="prompt",
response_format="json",
temperature=0,
timestamp_granularities=["word", "segment"],
Expand Down Expand Up @@ -81,8 +81,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) ->
transcription = await async_client.audio.transcriptions.create(
file=b"raw file contents",
model="whisper-1",
language="string",
prompt="string",
language="language",
prompt="prompt",
response_format="json",
temperature=0,
timestamp_granularities=["word", "segment"],
Expand Down
8 changes: 4 additions & 4 deletions tests/api_resources/audio/test_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def test_method_create_with_all_params(self, client: OpenAI) -> None:
translation = client.audio.translations.create(
file=b"raw file contents",
model="whisper-1",
prompt="string",
response_format="string",
prompt="prompt",
response_format="response_format",
temperature=0,
)
assert_matches_type(Translation, translation, path=["response"])
Expand Down Expand Up @@ -79,8 +79,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) ->
translation = await async_client.audio.translations.create(
file=b"raw file contents",
model="whisper-1",
prompt="string",
response_format="string",
prompt="prompt",
response_format="response_format",
temperature=0,
)
assert_matches_type(Translation, translation, path=["response"])
Expand Down
80 changes: 40 additions & 40 deletions tests/api_resources/beta/test_assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def test_method_create(self, client: OpenAI) -> None:
def test_method_create_with_all_params(self, client: OpenAI) -> None:
assistant = client.beta.assistants.create(
model="gpt-4-turbo",
description="string",
instructions="string",
description="description",
instructions="instructions",
metadata={},
name="string",
name="name",
response_format="none",
temperature=1,
tool_resources={
Expand Down Expand Up @@ -83,14 +83,14 @@ def test_streaming_response_create(self, client: OpenAI) -> None:
@parametrize
def test_method_retrieve(self, client: OpenAI) -> None:
assistant = client.beta.assistants.retrieve(
"string",
"assistant_id",
)
assert_matches_type(Assistant, assistant, path=["response"])

@parametrize
def test_raw_response_retrieve(self, client: OpenAI) -> None:
response = client.beta.assistants.with_raw_response.retrieve(
"string",
"assistant_id",
)

assert response.is_closed is True
Expand All @@ -101,7 +101,7 @@ def test_raw_response_retrieve(self, client: OpenAI) -> None:
@parametrize
def test_streaming_response_retrieve(self, client: OpenAI) -> None:
with client.beta.assistants.with_streaming_response.retrieve(
"string",
"assistant_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -121,19 +121,19 @@ def test_path_params_retrieve(self, client: OpenAI) -> None:
@parametrize
def test_method_update(self, client: OpenAI) -> None:
assistant = client.beta.assistants.update(
"string",
assistant_id="assistant_id",
)
assert_matches_type(Assistant, assistant, path=["response"])

@parametrize
def test_method_update_with_all_params(self, client: OpenAI) -> None:
assistant = client.beta.assistants.update(
"string",
description="string",
instructions="string",
assistant_id="assistant_id",
description="description",
instructions="instructions",
metadata={},
model="string",
name="string",
model="model",
name="name",
response_format="none",
temperature=1,
tool_resources={
Expand All @@ -148,7 +148,7 @@ def test_method_update_with_all_params(self, client: OpenAI) -> None:
@parametrize
def test_raw_response_update(self, client: OpenAI) -> None:
response = client.beta.assistants.with_raw_response.update(
"string",
assistant_id="assistant_id",
)

assert response.is_closed is True
Expand All @@ -159,7 +159,7 @@ def test_raw_response_update(self, client: OpenAI) -> None:
@parametrize
def test_streaming_response_update(self, client: OpenAI) -> None:
with client.beta.assistants.with_streaming_response.update(
"string",
assistant_id="assistant_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -173,7 +173,7 @@ def test_streaming_response_update(self, client: OpenAI) -> None:
def test_path_params_update(self, client: OpenAI) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"):
client.beta.assistants.with_raw_response.update(
"",
assistant_id="",
)

@parametrize
Expand All @@ -184,8 +184,8 @@ def test_method_list(self, client: OpenAI) -> None:
@parametrize
def test_method_list_with_all_params(self, client: OpenAI) -> None:
assistant = client.beta.assistants.list(
after="string",
before="string",
after="after",
before="before",
limit=0,
order="asc",
)
Expand Down Expand Up @@ -214,14 +214,14 @@ def test_streaming_response_list(self, client: OpenAI) -> None:
@parametrize
def test_method_delete(self, client: OpenAI) -> None:
assistant = client.beta.assistants.delete(
"string",
"assistant_id",
)
assert_matches_type(AssistantDeleted, assistant, path=["response"])

@parametrize
def test_raw_response_delete(self, client: OpenAI) -> None:
response = client.beta.assistants.with_raw_response.delete(
"string",
"assistant_id",
)

assert response.is_closed is True
Expand All @@ -232,7 +232,7 @@ def test_raw_response_delete(self, client: OpenAI) -> None:
@parametrize
def test_streaming_response_delete(self, client: OpenAI) -> None:
with client.beta.assistants.with_streaming_response.delete(
"string",
"assistant_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down Expand Up @@ -264,10 +264,10 @@ async def test_method_create(self, async_client: AsyncOpenAI) -> None:
async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None:
assistant = await async_client.beta.assistants.create(
model="gpt-4-turbo",
description="string",
instructions="string",
description="description",
instructions="instructions",
metadata={},
name="string",
name="name",
response_format="none",
temperature=1,
tool_resources={
Expand Down Expand Up @@ -315,14 +315,14 @@ async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> Non
@parametrize
async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None:
assistant = await async_client.beta.assistants.retrieve(
"string",
"assistant_id",
)
assert_matches_type(Assistant, assistant, path=["response"])

@parametrize
async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
response = await async_client.beta.assistants.with_raw_response.retrieve(
"string",
"assistant_id",
)

assert response.is_closed is True
Expand All @@ -333,7 +333,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None:
@parametrize
async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None:
async with async_client.beta.assistants.with_streaming_response.retrieve(
"string",
"assistant_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -353,19 +353,19 @@ async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None:
@parametrize
async def test_method_update(self, async_client: AsyncOpenAI) -> None:
assistant = await async_client.beta.assistants.update(
"string",
assistant_id="assistant_id",
)
assert_matches_type(Assistant, assistant, path=["response"])

@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None:
assistant = await async_client.beta.assistants.update(
"string",
description="string",
instructions="string",
assistant_id="assistant_id",
description="description",
instructions="instructions",
metadata={},
model="string",
name="string",
model="model",
name="name",
response_format="none",
temperature=1,
tool_resources={
Expand All @@ -380,7 +380,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) ->
@parametrize
async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
response = await async_client.beta.assistants.with_raw_response.update(
"string",
assistant_id="assistant_id",
)

assert response.is_closed is True
Expand All @@ -391,7 +391,7 @@ async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None:
@parametrize
async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None:
async with async_client.beta.assistants.with_streaming_response.update(
"string",
assistant_id="assistant_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -405,7 +405,7 @@ async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> Non
async def test_path_params_update(self, async_client: AsyncOpenAI) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `assistant_id` but received ''"):
await async_client.beta.assistants.with_raw_response.update(
"",
assistant_id="",
)

@parametrize
Expand All @@ -416,8 +416,8 @@ async def test_method_list(self, async_client: AsyncOpenAI) -> None:
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None:
assistant = await async_client.beta.assistants.list(
after="string",
before="string",
after="after",
before="before",
limit=0,
order="asc",
)
Expand Down Expand Up @@ -446,14 +446,14 @@ async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None:
@parametrize
async def test_method_delete(self, async_client: AsyncOpenAI) -> None:
assistant = await async_client.beta.assistants.delete(
"string",
"assistant_id",
)
assert_matches_type(AssistantDeleted, assistant, path=["response"])

@parametrize
async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None:
response = await async_client.beta.assistants.with_raw_response.delete(
"string",
"assistant_id",
)

assert response.is_closed is True
Expand All @@ -464,7 +464,7 @@ async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None:
@parametrize
async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None:
async with async_client.beta.assistants.with_streaming_response.delete(
"string",
"assistant_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand Down
Loading