-
Notifications
You must be signed in to change notification settings - Fork 63
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
[Automation] AbortSignal and Timeout Property #280
Comments
You can use _experimentalCustomFetch on the latest version to provide a custom fetch transport, including your abort. We have a PR up to allow for more granular configuration of fetch |
Yes I tried that. However, the parameters I get are objects to setup the fetch request. It seems like the properties when invoke 'transcribeFile' is being cleaned out. So even thought I pass signal and timeout, I don't see it when being passed to the experimental fetch. |
Oh no, It was my fault, I added the signal variable into the wrong line. Either way, it's difficult to use since the parameters are parsed into a URLSearchParams, and turns it into a string: Here is the code: createClient(envService.get('DEEPGRAM_API_KEY'), {
_experimentalCustomFetch: (input: URL, init: RequestInit) => {
console.log(input, init);
return fetch(input, init);
},
}), Here is the logs:
|
Which makes sense, if you look at the async transcribeFile(
source: FileSource,
options?: PrerecordedSchema,
endpoint = "v1/listen"
): Promise<DeepgramResponse<SyncPrerecordedResponse>> {
try {
let body;
if (isFileSource(source)) {
body = source;
} else {
throw new DeepgramError("Unknown transcription source type");
}
if (options !== undefined && "callback" in options) {
throw new DeepgramError(
"Callback cannot be provided as an option to a synchronous transcription. Use `transcribeUrlCallback` or `transcribeFileCallback` instead."
);
}
const transcriptionOptions: PrerecordedSchema = { ...{}, ...options };
const url = new URL(endpoint, this.baseUrl);
appendSearchParams(url.searchParams, transcriptionOptions);
const result: SyncPrerecordedResponse = await this.post(this.fetch as Fetch, url, body, {
"Content-Type": "deepgram/audio+video",
});
return { result, error: null };
} catch (error) {
if (isDeepgramError(error)) {
return { result: null, error };
}
throw error;
}
} |
Does this mean you're unblocked? I have a PR up to formalise the method of using custom fetch and websocket clients. It will be fowards compatible with Check out the PR for |
latest version going out will allow you to provide an abort and timeout config to the fetch config. see the readme after release |
Proposed changes
The invoke methods for asynchronously transcribing or etc, should have a signal property.
Context
Some models,
specifically whisper
sometimes takes a long time to execute, especially for our long files. We also have a concurrent request happening at the same time, which if it fails, this transcription is no longer needed, and we need a way to abort it.Possible Implementation
Add a signal property to the
schema
options, and handle it with the restful client.Other information
The text was updated successfully, but these errors were encountered: