Skip to content

Commit 8e2d96c

Browse files
Expose Response Classes for Inheritance
1 parent ee625c4 commit 8e2d96c

File tree

23 files changed

+591
-129
lines changed

23 files changed

+591
-129
lines changed

deepgram/__init__.py

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,37 @@
99
from .client import Deepgram, DeepgramClient
1010
from .options import DeepgramClientOptions
1111

12-
# live
13-
from .clients import LiveTranscriptionEvents
14-
from .clients import LiveClient, AsyncLiveClient, LiveOptions
12+
# listen client
13+
from .client import ListenClient
1514

16-
# onprem
17-
from .clients import (
18-
OnPremClient,
19-
AsyncOnPremClient,
15+
# live
16+
from .client import LiveTranscriptionEvents
17+
from .client import LiveClient, AsyncLiveClient
18+
from .client import LiveOptions
19+
from .client import (
20+
LiveResultResponse,
21+
MetadataResponse,
22+
ErrorResponse,
2023
)
2124

2225
# prerecorded
23-
from .clients import (
24-
PreRecordedClient,
25-
AsyncPreRecordedClient,
26-
PrerecordedOptions,
26+
from .client import PreRecordedClient, AsyncPreRecordedClient
27+
from .client import (
2728
PrerecordedSource,
2829
FileSource,
2930
UrlSource,
3031
BufferSource,
3132
ReadStreamSource,
33+
PrerecordedOptions,
34+
)
35+
from .client import (
36+
AsyncPrerecordedResponse,
37+
PrerecordedResponse,
3238
)
3339

3440
# manage
35-
from .clients import (
36-
ManageClient,
37-
AsyncManageClient,
41+
from .client import ManageClient, AsyncManageClient
42+
from .client import (
3843
ProjectOptions,
3944
KeyOptions,
4045
ScopeOptions,
@@ -44,6 +49,31 @@
4449
UsageFieldsOptions,
4550
)
4651

52+
# manage client responses
53+
from .client import (
54+
Message,
55+
Project,
56+
ProjectsResponse,
57+
MembersResponse,
58+
Key,
59+
KeyResponse,
60+
KeysResponse,
61+
ScopesResponse,
62+
InvitesResponse,
63+
UsageRequest,
64+
UsageRequestsResponse,
65+
UsageSummaryResponse,
66+
UsageFieldsResponse,
67+
Balance,
68+
BalancesResponse,
69+
)
70+
71+
# onprem
72+
from .client import (
73+
OnPremClient,
74+
AsyncOnPremClient,
75+
)
76+
4777
# utilities
4878
from .audio import Microphone
4979
from .audio import (

deepgram/client.py

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,74 @@
77
import logging, verboselogs
88
import os
99

10-
from .clients.listen import (
11-
ListenClient,
12-
PreRecordedClient,
13-
AsyncLiveClient,
14-
AsyncPreRecordedClient,
15-
PrerecordedOptions,
10+
# listen client
11+
from .clients import ListenClient
12+
13+
# live
14+
from .clients import LiveClient, AsyncLiveClient
15+
from .clients import (
1616
LiveOptions,
1717
LiveTranscriptionEvents,
1818
)
19+
20+
# live client responses
21+
from .clients import (
22+
LiveResultResponse,
23+
MetadataResponse,
24+
ErrorResponse,
25+
)
26+
27+
# prerecorded
28+
from .clients import PreRecordedClient, AsyncPreRecordedClient
29+
from .clients import (
30+
PrerecordedSource,
31+
FileSource,
32+
UrlSource,
33+
BufferSource,
34+
ReadStreamSource,
35+
PrerecordedOptions,
36+
)
37+
38+
# prerecorded client responses
39+
from .clients import (
40+
AsyncPrerecordedResponse,
41+
PrerecordedResponse,
42+
)
43+
44+
# manage client classes/input
45+
from .clients import ManageClient, AsyncManageClient
46+
from .clients import (
47+
ProjectOptions,
48+
KeyOptions,
49+
ScopeOptions,
50+
InviteOptions,
51+
UsageRequestOptions,
52+
UsageSummaryOptions,
53+
UsageFieldsOptions,
54+
)
55+
56+
# manage client responses
57+
from .clients import (
58+
Message,
59+
Project,
60+
ProjectsResponse,
61+
MembersResponse,
62+
Key,
63+
KeyResponse,
64+
KeysResponse,
65+
ScopesResponse,
66+
InvitesResponse,
67+
UsageRequest,
68+
UsageRequestsResponse,
69+
UsageSummaryResponse,
70+
UsageFieldsResponse,
71+
Balance,
72+
BalancesResponse,
73+
)
74+
75+
# on-prem
1976
from .clients.onprem.client import OnPremClient
2077
from .clients.onprem.v1.async_client import AsyncOnPremClient
21-
from .clients.manage.client import ManageClient
22-
from .clients.manage.v1.async_client import AsyncManageClient
2378

2479
from .options import DeepgramClientOptions
2580
from .errors import DeepgramApiKeyError, DeepgramModuleError

deepgram/clients/__init__.py

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
33
# SPDX-License-Identifier: MIT
44

5+
# listen
6+
from .listen import ListenClient
7+
58
# live
6-
from .live import LiveClient
7-
from .live import AsyncLiveClient
9+
from .live import LiveClient, AsyncLiveClient
810
from .live import LiveOptions
911
from .live import LiveTranscriptionEvents
10-
from ..options import DeepgramClientOptions
12+
from .live import (
13+
LiveResultResponse,
14+
MetadataResponse,
15+
ErrorResponse,
16+
)
1117

1218
# prerecorded
13-
from .prerecorded import PreRecordedClient
14-
from .prerecorded import AsyncPreRecordedClient
19+
from .prerecorded import PreRecordedClient, AsyncPreRecordedClient
1520
from .prerecorded import PrerecordedOptions
1621
from .prerecorded import (
1722
PrerecordedSource,
@@ -20,16 +25,13 @@
2025
BufferSource,
2126
ReadStreamSource,
2227
)
23-
from ..options import DeepgramClientOptions
24-
25-
# onprem
26-
from .onprem import OnPremClient
27-
from .onprem import AsyncOnPremClient
28-
from ..options import DeepgramClientOptions
28+
from .prerecorded import (
29+
AsyncPrerecordedResponse,
30+
PrerecordedResponse,
31+
)
2932

3033
# manage
31-
from .manage import ManageClient
32-
from .manage import AsyncManageClient
34+
from .manage import ManageClient, AsyncManageClient
3335
from .manage import (
3436
ProjectOptions,
3537
KeyOptions,
@@ -39,4 +41,26 @@
3941
UsageSummaryOptions,
4042
UsageFieldsOptions,
4143
)
44+
from .manage import (
45+
Message,
46+
Project,
47+
ProjectsResponse,
48+
MembersResponse,
49+
Key,
50+
KeyResponse,
51+
KeysResponse,
52+
ScopesResponse,
53+
InvitesResponse,
54+
UsageRequest,
55+
UsageRequestsResponse,
56+
UsageSummaryResponse,
57+
UsageFieldsResponse,
58+
Balance,
59+
BalancesResponse,
60+
)
61+
62+
# onprem
63+
from .onprem import OnPremClient, AsyncOnPremClient
64+
65+
# client options
4266
from ..options import DeepgramClientOptions

deepgram/clients/listen.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,37 @@
66
import logging, verboselogs
77

88
from ..options import DeepgramClientOptions
9+
from .errors import DeepgramModuleError
910

11+
# live client
12+
# classes and input
1013
from .prerecorded.client import (
1114
PreRecordedClient,
1215
AsyncPreRecordedClient,
1316
PrerecordedOptions,
1417
)
18+
19+
# responses
20+
from .prerecorded.client import (
21+
AsyncPrerecordedResponse,
22+
PrerecordedResponse,
23+
)
24+
25+
# live client
26+
# classes and input
1527
from .live.client import (
1628
LiveClient,
1729
AsyncLiveClient,
1830
LiveOptions,
31+
LiveTranscriptionEvents,
32+
)
33+
34+
# responses
35+
from .live.client import (
1936
LiveResultResponse,
2037
MetadataResponse,
2138
ErrorResponse,
22-
LiveTranscriptionEvents,
2339
)
24-
from .errors import DeepgramModuleError
2540

2641

2742
class ListenClient:
@@ -44,6 +59,7 @@ class ListenClient:
4459
asynclive: Returns an (Async) LiveClient instance for interacting with Deepgram's transcription services.
4560
asyncprerecorded: Returns an (Async) PreRecordedClient instance for interacting with Deepgram's prerecorded transcription services.
4661
"""
62+
4763
def __init__(self, config: DeepgramClientOptions):
4864
self.logger = logging.getLogger(__name__)
4965
self.logger.addHandler(logging.StreamHandler())

deepgram/clients/live/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
33
# SPDX-License-Identifier: MIT
44

5-
from .v1.client import LiveClient
6-
from .v1.async_client import AsyncLiveClient
5+
from .client import LiveClient
6+
from .client import AsyncLiveClient
77
from .v1.options import LiveOptions
88
from .enums import LiveTranscriptionEvents
99
from ...options import DeepgramClientOptions
10+
from .client import (
11+
LiveResultResponse,
12+
MetadataResponse,
13+
ErrorResponse,
14+
)

deepgram/clients/live/client.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,66 @@
66
from .v1.async_client import AsyncLiveClient as AsyncLiveClientLatest
77
from .v1.options import LiveOptions as LiveOptionsLatest
88
from .enums import LiveTranscriptionEvents
9-
from .v1.response import LiveResultResponse, MetadataResponse, ErrorResponse
9+
from .v1.response import (
10+
LiveResultResponse as LiveResultResponseLatest,
11+
MetadataResponse as MetadataResponseLatest,
12+
ErrorResponse as ErrorResponseLatest,
13+
)
1014

1115
"""
1216
The vX/client.py points to the current supported version in the SDK.
1317
Older versions are supported in the SDK for backwards compatibility.
1418
"""
1519

20+
21+
# input
1622
class LiveOptions(LiveOptionsLatest):
1723
"""
1824
pass through for LiveOptions based on API version
1925
"""
26+
27+
pass
28+
29+
30+
# responses
31+
class LiveResultResponse(LiveResultResponseLatest):
32+
"""
33+
pass through for LiveResultResponse based on API version
34+
"""
35+
36+
pass
37+
38+
39+
class MetadataResponse(MetadataResponseLatest):
40+
"""
41+
pass through for MetadataResponse based on API version
42+
"""
43+
44+
pass
45+
46+
47+
class ErrorResponse(ErrorResponseLatest):
48+
"""
49+
pass through for ErrorResponse based on API version
50+
"""
51+
2052
pass
2153

54+
55+
# clients
2256
class LiveClient(LiveClientLatest):
2357
"""
2458
Please see LiveClientLatest for details
2559
"""
60+
2661
def __init__(self, config):
2762
super().__init__(config)
2863

64+
2965
class AsyncLiveClient(AsyncLiveClientLatest):
3066
"""
3167
Please see LiveClientLatest for details
3268
"""
69+
3370
def __init__(self, config):
3471
super().__init__(config)

deepgram/clients/live/enums.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"""
88
Constants mapping to events from the Deepgram API
99
"""
10+
11+
1012
class LiveTranscriptionEvents(Enum):
11-
Open = "open"
12-
Close = "close"
13+
Open = "Open"
14+
Close = "Close"
1315
Transcript = "Results"
1416
Metadata = "Metadata"
15-
Error = "error"
16-
Warning = "warning"
17+
Error = "Error"
18+
Warning = "Warning"

0 commit comments

Comments
 (0)