diff --git a/async-openai/src/client.rs b/async-openai/src/client.rs index 88e1ae95..b393eba5 100644 --- a/async-openai/src/client.rs +++ b/async-openai/src/client.rs @@ -235,7 +235,7 @@ impl Client { .post(self.config.url(path)) .query(&self.config.query()) .headers(self.config.headers()) - .multipart(async_convert::TryInto::try_into(form.clone()).await?) + .multipart(async_convert::TryFrom::try_from(form.clone()).await?) .build()?) }; diff --git a/async-openai/tests/whisper.rs b/async-openai/tests/whisper.rs new file mode 100644 index 00000000..ee17a05f --- /dev/null +++ b/async-openai/tests/whisper.rs @@ -0,0 +1,57 @@ +use async_openai::types::CreateTranslationRequestArgs; +use async_openai::{types::CreateTranscriptionRequestArgs, Client}; +use tokio_test::assert_err; + +#[tokio::test] +async fn transcribe_test() { + let client = Client::new(); + + let request = CreateTranscriptionRequestArgs::default().build().unwrap(); + + let response = client.audio().transcribe(request).await; + + assert_err!(response); // FileReadError("cannot extract file name from ") +} + +#[tokio::test] +async fn transcribe_sendable_test() { + let client = Client::new(); + + // https://github.com/64bit/async-openai/issues/140 + let transcribe = tokio::spawn(async move { + let request = CreateTranscriptionRequestArgs::default().build().unwrap(); + + client.audio().transcribe(request).await + }); + + let response = transcribe.await.unwrap(); + + assert_err!(response); // FileReadError("cannot extract file name from ") +} + +#[tokio::test] +async fn translate_test() { + let client = Client::new(); + + let request = CreateTranslationRequestArgs::default().build().unwrap(); + + let response = client.audio().translate(request).await; + + assert_err!(response); // FileReadError("cannot extract file name from ") +} + +#[tokio::test] +async fn translate_sendable_test() { + let client = Client::new(); + + // https://github.com/64bit/async-openai/issues/140 + let translate = tokio::spawn(async move { + let request = CreateTranslationRequestArgs::default().build().unwrap(); + + client.audio().translate(request).await + }); + + let response = translate.await.unwrap(); + + assert_err!(response); // FileReadError("cannot extract file name from ") +}