Skip to content
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

Set Field in Metadata as Optional #336

Merged
merged 1 commit into from
Mar 8, 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
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()
Loading