Skip to content

Commit

Permalink
Set Field in Metadata as Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvonthenen committed Mar 8, 2024
1 parent 7750a01 commit 727d76f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
12 changes: 7 additions & 5 deletions deepgram/clients/live/v1/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ def __str__(self) -> str:
@dataclass
class Metadata:
request_id: str = ""
model_info: ModelInfo = field(
default=None, metadata=config(exclude=lambda f: f is None)
)
model_info: ModelInfo = None
model_uuid: str = ""
extra: Optional[Dict[str, str]] = field(
default=None, metadata=config(exclude=lambda f: f is None)
Expand Down Expand Up @@ -213,8 +211,12 @@ class MetadataResponse:
created: str = ""
duration: float = 0
channels: int = 0
models: List[str] = None
model_info: Dict[str, ModelInfo] = None
models: Optional[List[str]] = field(
default=None, metadata=config(exclude=lambda f: f is None)
)
model_info: Optional[Dict[str, ModelInfo]] = field(
default=None, metadata=config(exclude=lambda f: f is None)
)
extra: Optional[Dict] = field(
default=None, metadata=config(exclude=lambda f: f is None)
)
Expand Down
2 changes: 1 addition & 1 deletion deepgram/clients/manage/v1/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ class UsageFieldsResponse:
models: List[UsageModel] = None
processing_methods: List[str] = None
features: List[str] = None
languages: List[str] = field(
languages: Optional[List[str]] = field(
default=None, metadata=config(exclude=lambda f: f is None)
)

Expand Down
34 changes: 34 additions & 0 deletions tests/edge_cases/reconnect_same_object/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import time
import logging, verboselogs

from deepgram import DeepgramClient, DeepgramClientOptions, LiveOptions


def main():
# config: DeepgramClientOptions = DeepgramClientOptions(verbose=logging.DEBUG)
config: DeepgramClientOptions = DeepgramClientOptions()
deepgram: DeepgramClient = DeepgramClient("", config)
options: LiveOptions = LiveOptions()

dg_connection = deepgram.listen.live.v("1")

for x in range(0, 10):
if x > 0:
# wait for the connection to close
time.sleep(5)

if x == 0:
print(f"Starting connection #{x}...")
else:
print(f"Restarting connection #{x}...")

dg_connection.start(options)
time.sleep(15)
print("Calling stop...")
dg_connection.finish()

print("Finished")


if __name__ == "__main__":
main()

0 comments on commit 727d76f

Please sign in to comment.