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

Streaming callbacks #85

Merged
merged 5 commits into from
Aug 22, 2024
Merged

Streaming callbacks #85

merged 5 commits into from
Aug 22, 2024

Conversation

bd-g
Copy link
Contributor

@bd-g bd-g commented Aug 12, 2024

Proposed changes

Allows specifying a callback for streaming requests. See docs.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update or tests (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING.md doc
  • I have added tests and/or examples that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Added a doc to the callback_method option to clarify the option is only respected for pre-recorded requests. May be worth making a breaking change in the future and refusing to accept streaming requests that attempt to set this option?

@bd-g bd-g requested review from jcdyer and DamienDeepgram August 12, 2024 18:30
@bd-g bd-g requested a review from jcdyer August 22, 2024 13:31
.file(PATH_TO_FILE, AUDIO_CHUNK_SIZE, FRAME_DELAY)
.await?;

println!("Deepgram Request ID: {}", results.request_id());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here - simple way to grab request ID from the TranscriptionStream

@@ -737,6 +759,10 @@ impl<'a> WebsocketHandle {
// eprintln!("<handle> receiving response: {resp:?}");
resp
}

pub fn request_id(&self) -> Uuid {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add docs to this function, and please mention that the request ID is needed for support on issues that come up with a particular request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/lib.rs Outdated

/// A Deepgram API server response was not in the expected format.
#[error("The Deepgram API server response was not in the expected format: {0}")]
UnexpectedServerResponse(String),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this from String to anyhow::Error, which is more flexible, and allows us to provide better-structured errors. (Then at error construction time, you can use anyhow!("missing request request_id") and anyhow!("malformed request_id: {:?}", request_id))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bd-g bd-g requested a review from jcdyer August 22, 2024 14:02
Copy link
Contributor

@jcdyer jcdyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@bd-g bd-g merged commit 5a1420c into main Aug 22, 2024
18 checks passed
@bd-g bd-g deleted the brent-george/streaming-callbacks branch August 22, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants