deepgram / deepgram-js-sdk

Official JavaScript SDK for Deepgram's automated speech recognition APIs.
https://developers.deepgram.com
MIT License
127 stars 45 forks source link

Include signal or FetchParameters args to creation for easy request aborting #252

Closed myselfhimself closed 2 months ago

myselfhimself commented 3 months ago

Hello Deepgram!!

Proposed changes

Could you please add an AbortController signal parameter injection capability at Deepgram client initialisation time (be it through createClient() or new DeepgramClient())?

For now, rather lowly exposed Restful methods allow FetchParameters ie. signal passing, such as: https://github.com/deepgram/deepgram-js-sdk/blob/main/src%2Fpackages%2FAbstractRestfulClient.ts#L90

Context

In a JS web application (with dedicated Deepgram side proxy), I want my user - through button clicks - to be able to cancel a long duration Whisper query (say the user realizes some parameters were wrong) and rerun a more relevant one (eg. with more cleverly chosen parameters).

Possible Implementation

Include the FetchParameters with the Fetch Options? Add an extra DeepgramClient and createClient parameter for Fetchparameter ?

Other information

Interesting but not so sustainable forks related to request aborting control and Deepgram:

https://github.com/BartoszJarocki/deepgram-js-sdk-custom-fetch/blob/main/index.ts

https://github.com/BartoszJarocki/deepgram-js-sdk (see his feat*test branch's commits).

Thanks guys!!!

myselfhimself commented 3 months ago

Related to this PR https://github.com/deepgram/deepgram-js-sdk/pull/245

lukeocodes commented 2 months ago

this has been made possible with the release today of a solution to #245