Skip to content

Commit 727d76f

Browse files
Set Field in Metadata as Optional
1 parent 7750a01 commit 727d76f

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

deepgram/clients/live/v1/response.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ def __str__(self) -> str:
118118
@dataclass
119119
class Metadata:
120120
request_id: str = ""
121-
model_info: ModelInfo = field(
122-
default=None, metadata=config(exclude=lambda f: f is None)
123-
)
121+
model_info: ModelInfo = None
124122
model_uuid: str = ""
125123
extra: Optional[Dict[str, str]] = field(
126124
default=None, metadata=config(exclude=lambda f: f is None)
@@ -213,8 +211,12 @@ class MetadataResponse:
213211
created: str = ""
214212
duration: float = 0
215213
channels: int = 0
216-
models: List[str] = None
217-
model_info: Dict[str, ModelInfo] = None
214+
models: Optional[List[str]] = field(
215+
default=None, metadata=config(exclude=lambda f: f is None)
216+
)
217+
model_info: Optional[Dict[str, ModelInfo]] = field(
218+
default=None, metadata=config(exclude=lambda f: f is None)
219+
)
218220
extra: Optional[Dict] = field(
219221
default=None, metadata=config(exclude=lambda f: f is None)
220222
)

deepgram/clients/manage/v1/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class UsageFieldsResponse:
522522
models: List[UsageModel] = None
523523
processing_methods: List[str] = None
524524
features: List[str] = None
525-
languages: List[str] = field(
525+
languages: Optional[List[str]] = field(
526526
default=None, metadata=config(exclude=lambda f: f is None)
527527
)
528528

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import time
2+
import logging, verboselogs
3+
4+
from deepgram import DeepgramClient, DeepgramClientOptions, LiveOptions
5+
6+
7+
def main():
8+
# config: DeepgramClientOptions = DeepgramClientOptions(verbose=logging.DEBUG)
9+
config: DeepgramClientOptions = DeepgramClientOptions()
10+
deepgram: DeepgramClient = DeepgramClient("", config)
11+
options: LiveOptions = LiveOptions()
12+
13+
dg_connection = deepgram.listen.live.v("1")
14+
15+
for x in range(0, 10):
16+
if x > 0:
17+
# wait for the connection to close
18+
time.sleep(5)
19+
20+
if x == 0:
21+
print(f"Starting connection #{x}...")
22+
else:
23+
print(f"Restarting connection #{x}...")
24+
25+
dg_connection.start(options)
26+
time.sleep(15)
27+
print("Calling stop...")
28+
dg_connection.finish()
29+
30+
print("Finished")
31+
32+
33+
if __name__ == "__main__":
34+
main()

0 commit comments

Comments
 (0)