-
Notifications
You must be signed in to change notification settings - Fork 317
Description
I recently tried to upgrade my application to the latest version in order to make use of some of the new stuff announced at dev day. I have a telegram bot that uses teloxide, with a use of the image and transcription endpoints. However, I was running into this error with compiling:
the trait bound `fn(teloxide::Bot, teloxide::prelude::Message) -> impl futures_util::Future<Output = Result<(), RequestError>> {respond_to_voice}: Injectable<_, _, _>` is not satisfied
the following other types implement trait `Injectable<Input, Output, FnArgs>`:
<Asyncify<Func> as Injectable<Input, Output, ()>>
<Asyncify<Func> as Injectable<Input, Output, (A, B)>>
<Asyncify<Func> as Injectable<Input, Output, (A, B, C)>>
<Asyncify<Func> as Injectable<Input, Output, (A, B, C, D)>>
<Asyncify<Func> as Injectable<Input, Output, (A, B, C, D, E)>>
<Asyncify<Func> as Injectable<Input, Output, (A, B, C, D, E, F)>>
<Asyncify<Func> as Injectable<Input, Output, (A, B, C, D, E, F, G)>>
<Asyncify<Func> as Injectable<Input, Output, (A, B, C, D, E, F, G, H)>>
and 2 others
Instead of trying to upgrade directly to the latest version from 0.12, I tried upgrading incrementally until discovering that the issue appeared with the upgrade to 0.14. It looks like it might be related to the changes around retrying for rate limiting, but I'm at a bit of a loss with how to fix it.
My implementation is pretty simple in terms of how I'm calling the library itself:
pub async fn get_ai_transcription(audio: &String) -> Result<String, CustomError> {
let client = Client::new();
let request = CreateTranscriptionRequestArgs::default()
.file(audio)
.model("whisper-1")
.build()?;
let response = client.audio().transcribe(request).await?;
Ok(response.text)
}
but I was able to determine that it was occurring due to the let response = client.audio().transcribe(request).await?;
line.
After trying a lot of debugging to even get the error message to change, I added this basic test
fn test() {
fn assert_send(_: impl Send) {}
assert_send(get_ai_transcription(&"".to_string()));
}
and finally got a more readable error that disappears in 0.13 and reappears around 0.14.
|
309 | assert_send(get_ai_transcription(&"".to_string()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `get_ai_transcription` is not `Send`
|
= help: the trait `std::marker::Send` is not implemented for `dyn futures_util::Future<Output = Result<Form, OpenAIError>>`
note: required by a bound in `assert_send`
--> src/ai.rs:308:28
|
308 | fn assert_send(_: impl Send) {}
| ^^^^ required by this bound in `assert_send`
Unfortunately, now I'm a bit stuck. I'm pretty new to Rust, so debugging can still be a bit difficult. Do you have any suggestions or ideas for what I might be able to try?