Skip to content

Commit

Permalink
feat(api): Fix audio transcription response formats
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and gradenr committed Jun 11, 2024
1 parent c081730 commit 88e3d61
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 259 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-862b73eb4a57968b79e739f345b7f4523b8273477544fb03056c9e7d4230f42d.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/groqcloud%2Fgroqcloud-a4c1214ecaa24ad37fbb3c12b8392787ebe0fd51c5e7e08bdf25d7608dc7900b.yml
8 changes: 4 additions & 4 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ Methods:
Types:

```python
from groq.types.audio import Transcription, TranscriptionCreateResponse
from groq.types.audio import Transcription
```

Methods:

- <code title="post /openai/v1/audio/transcriptions">client.audio.transcriptions.<a href="./src/groq/resources/audio/transcriptions.py">create</a>(\*\*<a href="src/groq/types/audio/transcription_create_params.py">params</a>) -> <a href="./src/groq/types/audio/transcription_create_response.py">TranscriptionCreateResponse</a></code>
- <code title="post /openai/v1/audio/transcriptions">client.audio.transcriptions.<a href="./src/groq/resources/audio/transcriptions.py">create</a>(\*\*<a href="src/groq/types/audio/transcription_create_params.py">params</a>) -> <a href="./src/groq/types/audio/transcription.py">Transcription</a></code>

## Translations

Types:

```python
from groq.types.audio import Translation, TranslationCreateResponse
from groq.types.audio import Translation
```

Methods:

- <code title="post /openai/v1/audio/translations">client.audio.translations.<a href="./src/groq/resources/audio/translations.py">create</a>(\*\*<a href="src/groq/types/audio/translation_create_params.py">params</a>) -> <a href="./src/groq/types/audio/translation_create_response.py">TranslationCreateResponse</a></code>
- <code title="post /openai/v1/audio/translations">client.audio.translations.<a href="./src/groq/resources/audio/translations.py">create</a>(\*\*<a href="src/groq/types/audio/translation_create_params.py">params</a>) -> <a href="./src/groq/types/audio/translation.py">Translation</a></code>

# Models

Expand Down
46 changes: 18 additions & 28 deletions src/groq/resources/audio/transcriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, List, Union, Mapping, cast
from typing import List, Union, Mapping, cast
from typing_extensions import Literal

import httpx
Expand All @@ -26,7 +26,7 @@
from ..._base_client import (
make_request_options,
)
from ...types.audio.transcription_create_response import TranscriptionCreateResponse
from ...types.audio.transcription import Transcription

__all__ = ["Transcriptions", "AsyncTranscriptions"]

Expand Down Expand Up @@ -56,7 +56,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> TranscriptionCreateResponse:
) -> Transcription:
"""
Transcribes audio into the input language.
Expand Down Expand Up @@ -115,19 +115,14 @@ def create(
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return cast(
TranscriptionCreateResponse,
self._post(
"/openai/v1/audio/transcriptions",
body=maybe_transform(body, transcription_create_params.TranscriptionCreateParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(
Any, TranscriptionCreateResponse
), # Union types cannot be passed in as arguments in the type system
return self._post(
"/openai/v1/audio/transcriptions",
body=maybe_transform(body, transcription_create_params.TranscriptionCreateParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Transcription,
)


Expand Down Expand Up @@ -156,7 +151,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> TranscriptionCreateResponse:
) -> Transcription:
"""
Transcribes audio into the input language.
Expand Down Expand Up @@ -215,19 +210,14 @@ async def create(
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return cast(
TranscriptionCreateResponse,
await self._post(
"/openai/v1/audio/transcriptions",
body=await async_maybe_transform(body, transcription_create_params.TranscriptionCreateParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(
Any, TranscriptionCreateResponse
), # Union types cannot be passed in as arguments in the type system
return await self._post(
"/openai/v1/audio/transcriptions",
body=await async_maybe_transform(body, transcription_create_params.TranscriptionCreateParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Transcription,
)


Expand Down
46 changes: 18 additions & 28 deletions src/groq/resources/audio/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Any, Union, Mapping, cast
from typing import Union, Mapping, cast
from typing_extensions import Literal

import httpx
Expand All @@ -26,7 +26,7 @@
from ..._base_client import (
make_request_options,
)
from ...types.audio.translation_create_response import TranslationCreateResponse
from ...types.audio.translation import Translation

__all__ = ["Translations", "AsyncTranslations"]

Expand Down Expand Up @@ -54,7 +54,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> TranslationCreateResponse:
) -> Translation:
"""
Translates audio into English.
Expand Down Expand Up @@ -100,19 +100,14 @@ def create(
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return cast(
TranslationCreateResponse,
self._post(
"/openai/v1/audio/translations",
body=maybe_transform(body, translation_create_params.TranslationCreateParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(
Any, TranslationCreateResponse
), # Union types cannot be passed in as arguments in the type system
return self._post(
"/openai/v1/audio/translations",
body=maybe_transform(body, translation_create_params.TranslationCreateParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Translation,
)


Expand All @@ -139,7 +134,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> TranslationCreateResponse:
) -> Translation:
"""
Translates audio into English.
Expand Down Expand Up @@ -185,19 +180,14 @@ async def create(
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return cast(
TranslationCreateResponse,
await self._post(
"/openai/v1/audio/translations",
body=await async_maybe_transform(body, translation_create_params.TranslationCreateParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(
Any, TranslationCreateResponse
), # Union types cannot be passed in as arguments in the type system
return await self._post(
"/openai/v1/audio/translations",
body=await async_maybe_transform(body, translation_create_params.TranslationCreateParams),
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Translation,
)


Expand Down
8 changes: 8 additions & 0 deletions src/groq/resources/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def create(
logprobs: Optional[bool] | NotGiven = NOT_GIVEN,
max_tokens: Optional[int] | NotGiven = NOT_GIVEN,
n: Optional[int] | NotGiven = NOT_GIVEN,
parallel_tool_calls: Optional[bool] | NotGiven = NOT_GIVEN,
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -218,6 +219,8 @@ def create(
the current moment, only n=1 is supported. Other values will result in a 400
response.
parallel_tool_calls: Whether to enable parallel function calling during tool use.
presence_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on
whether they appear in the text so far, increasing the model's likelihood to
talk about new topics.
Expand Down Expand Up @@ -296,6 +299,7 @@ def create(
"logprobs": logprobs,
"max_tokens": max_tokens,
"n": n,
"parallel_tool_calls": parallel_tool_calls,
"presence_penalty": presence_penalty,
"response_format": response_format,
"seed": seed,
Expand Down Expand Up @@ -442,6 +446,7 @@ async def create(
logprobs: Optional[bool] | NotGiven = NOT_GIVEN,
max_tokens: Optional[int] | NotGiven = NOT_GIVEN,
n: Optional[int] | NotGiven = NOT_GIVEN,
parallel_tool_calls: Optional[bool] | NotGiven = NOT_GIVEN,
presence_penalty: Optional[float] | NotGiven = NOT_GIVEN,
response_format: Optional[completion_create_params.ResponseFormat] | NotGiven = NOT_GIVEN,
seed: Optional[int] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -503,6 +508,8 @@ async def create(
the current moment, only n=1 is supported. Other values will result in a 400
response.
parallel_tool_calls: Whether to enable parallel function calling during tool use.
presence_penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on
whether they appear in the text so far, increasing the model's likelihood to
talk about new topics.
Expand Down Expand Up @@ -581,6 +588,7 @@ async def create(
"logprobs": logprobs,
"max_tokens": max_tokens,
"n": n,
"parallel_tool_calls": parallel_tool_calls,
"presence_penalty": presence_penalty,
"response_format": response_format,
"seed": seed,
Expand Down
2 changes: 0 additions & 2 deletions src/groq/types/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
from .transcription import Transcription as Transcription
from .translation_create_params import TranslationCreateParams as TranslationCreateParams
from .transcription_create_params import TranscriptionCreateParams as TranscriptionCreateParams
from .translation_create_response import TranslationCreateResponse as TranslationCreateResponse
from .transcription_create_response import TranscriptionCreateResponse as TranscriptionCreateResponse
86 changes: 0 additions & 86 deletions src/groq/types/audio/transcription_create_response.py

This file was deleted.

Loading

0 comments on commit 88e3d61

Please sign in to comment.