GithubHelp home page GithubHelp logo

Comments (7)

katya4oyu avatar katya4oyu commented on May 26, 2024 2

I think I have had the same problem.

This fix #157 is working well for me.

from async-openai.

armyofgnomes avatar armyofgnomes commented on May 26, 2024 2

@katya4oyu @64bit thank you for your help and for the new release!

from async-openai.

xunafay avatar xunafay commented on May 26, 2024 1

I think this bug emerged from #100

from async-openai.

armyofgnomes avatar armyofgnomes commented on May 26, 2024 1

@katya4oyu I just tried the fix out and it seems to work for me as well!

from async-openai.

xunafay avatar xunafay commented on May 26, 2024

I think I'm experiencing the same problem with
version
async-openai = "0.16.3"

Compiler error

error[E0277]: `dyn std::future::Future<Output = Result<reqwest::async_impl::multipart::Form, OpenAIError>>` cannot be sent between threads safely
   --> src/bot.rs:37:1
    |
37  | #[command]
    | ^^^^^^^^^^ `dyn std::future::Future<Output = Result<reqwest::async_impl::multipart::Form, OpenAIError>>` cannot be sent between threads safely
    |
    = help: the trait `std::marker::Send` is not implemented for `dyn std::future::Future<Output = Result<reqwest::async_impl::multipart::Form, OpenAIError>>`
    = note: required for `Unique<dyn std::future::Future<Output = Result<reqwest::async_impl::multipart::Form, OpenAIError>>>` to implement `std::marker::Send`
note: required because it appears within the type `Box<dyn Future<Output = Result<Form, OpenAIError>>>`
   --> /home/hannah/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:195:12
    |
195 | pub struct Box<
    |            ^^^
note: required because it appears within the type `Pin<Box<dyn Future<Output = Result<Form, OpenAIError>>>>`
   --> /home/hannah/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/pin.rs:410:12
    |
410 | pub struct Pin<P> {
    |            ^^^
    = note: required because it captures the following types: `reqwest::async_impl::request::RequestBuilder`, `Vec<(&str, &str)>`, `std::pin::Pin<Box<dyn std::future::Future<Output = Result<reqwest::async_impl::multipart::Form, OpenAIError>>>>`
note: required because it's used within this `async` block
   --> /home/hannah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-openai-0.16.3/src/client.rs:232:32
    |
232 |           let request_maker = || async {
    |  ________________________________^
233 | |             Ok(self
234 | |                 .http_client
235 | |                 .post(self.config.url(path))
...   |
239 | |                 .build()?)
240 | |         };
    | |_________^
    = note: required because it captures the following types: `{async block@async_openai::Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}::{closure#0}}`, `reqwest::async_impl::response::Response`, `impl std::future::Future<Output = Result<reqwest::async_impl::response::Response, reqwest::error::Error>>`, `StatusCode`, `impl std::future::Future<Output = Result<bytes::bytes::Bytes, reqwest::error::Error>>`
note: required because it's used within this `async` block
   --> /home/hannah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-openai-0.16.3/src/client.rs:257:57
    |
257 |           backoff::future::retry(self.backoff.clone(), || async {
    |  _________________________________________________________^
258 | |             let request = request_maker().await.map_err(backoff::Error::Permanent)?;
259 | |             let response = client
260 | |                 .execute(request)
...   |
296 | |             Ok(bytes)
297 | |         })
    | |_________^
note: required because it appears within the type `Retry<impl Sleeper, ExponentialBackoff<SystemClock>, NoopNotify, {closure@Client<OpenAIConfig>::execute_raw<{closure@Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}}, {async block@Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}::{closure#0}}>::{closure#0}::{closure#0}}, {async block@Client<OpenAIConfig>::execute_raw<{closure@Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}}, {async block@Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}::{closure#0}}>::{closure#0}::{closure#0}::{closure#0}}>`
   --> /home/hannah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backoff-0.4.0/src/future.rs:110:16
    |
110 |     pub struct Retry<S: Sleeper, B, N, Fn, Fut> {
    |                ^^^^^
    = note: required because it captures the following types: `{closure@async_openai::Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}}`, `reqwest::async_impl::client::Client`, `backoff::future::Retry<impl backoff::future::Sleeper, backoff::exponential::ExponentialBackoff<backoff::clock::SystemClock>, backoff::retry::NoopNotify, {closure@async_openai::Client<OpenAIConfig>::execute_raw<{closure@async_openai::Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}}, {async block@async_openai::Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}::{closure#0}}>::{closure#0}::{closure#0}}, {async block@async_openai::Client<OpenAIConfig>::execute_raw<{closure@async_openai::Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}}, {async block@async_openai::Client<OpenAIConfig>::post_form<CreateTranscriptionResponse, CreateTranscriptionRequest>::{closure#0}::{closure#0}::{closure#0}}>::{closure#0}::{closure#0}::{closure#0}}>`
note: required because it's used within this `async` fn body
   --> /home/hannah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-openai-0.16.3/src/client.rs:254:5
    |
254 | /     {
255 | |         let client = self.http_client.clone();
256 | |
257 | |         backoff::future::retry(self.backoff.clone(), || async {
...   |
298 | |         .await
299 | |     }
    | |_____^
    = note: required because it captures the following types: `impl std::future::Future<Output = Result<bytes::bytes::Bytes, OpenAIError>>`
note: required because it's used within this `async` fn body
   --> /home/hannah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-openai-0.16.3/src/client.rs:311:5
    |
311 | /     {
312 | |         let bytes = self.execute_raw(request_maker).await?;
313 | |
314 | |         let response: O = serde_json::from_slice(bytes.as_ref())
...   |
317 | |         Ok(response)
318 | |     }
    | |_____^
    = note: required because it captures the following types: `CreateTranscriptionRequest`, `impl std::future::Future<Output = Result<CreateTranscriptionResponse, OpenAIError>>`
note: required because it's used within this `async` fn body
   --> /home/hannah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-openai-0.16.3/src/client.rs:231:5
    |
231 | /     {
232 | |         let request_maker = || async {
233 | |             Ok(self
234 | |                 .http_client
...   |
242 | |         self.execute(request_maker).await
243 | |     }
    | |_____^
    = note: required because it captures the following types: `impl std::future::Future<Output = Result<CreateTranscriptionResponse, OpenAIError>>`
note: required because it's used within this `async` fn body
   --> /home/hannah/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-openai-0.16.3/src/audio.rs:26:59
    |
26  |       ) -> Result<CreateTranscriptionResponse, OpenAIError> {
    |  ___________________________________________________________^
27  | |         self.client
28  | |             .post_form("/audio/transcriptions", request)
29  | |             .await
30  | |     }
    | |_____^
    = note: required because it captures the following types: `Audio<'_, OpenAIConfig>`, `impl std::future::Future<Output = Result<CreateTranscriptionResponse, OpenAIError>>`
note: required because it's used within this `async` fn body
   --> src/openai.rs:44:93
    |
44  |       pub async fn stt(&self, file: &str) -> Result<CreateTranscriptionResponse, OpenAIError> {
    |  _____________________________________________________________________________________________^
45  | |         let request = CreateTranscriptionRequestArgs::default()
46  | |             .file(file)
47  | |             .model("whisper-1")
...   |
51  | |         self.client.audio().transcribe(request).await
52  | |     }
    | |_____^
    = note: required because it captures the following types: `OpenAI`, `Typing`, `regex::Regex`, `Vec<std::string::String>`, `Option<&std::string::String>`, `impl std::future::Future<Output = Result<serenity::model::channel::Message, SerenityError>>`, `std::string::String`, `Output`, `impl std::future::Future<Output = Result<serenity::model::channel::Message, SerenityError>>`, `impl std::future::Future<Output = Result<CreateTranscriptionResponse, OpenAIError>>`

from async-openai.

64bit avatar 64bit commented on May 26, 2024

Hello there,

To be honest I'm not sure whats going on, it might help to put full code on GitHub and share link, and get more eyes to debug.

from async-openai.

64bit avatar 64bit commented on May 26, 2024

Thank you for the fix, its released in v0.17.1

from async-openai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.