Comments (7)
I think I have had the same problem.
This fix #157 is working well for me.
from async-openai.
@katya4oyu @64bit thank you for your help and for the new release!
from async-openai.
I think this bug emerged from #100
from async-openai.
@katya4oyu I just tried the fix out and it seems to work for me as well!
from async-openai.
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.
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.
Thank you for the fix, its released in v0.17.1
from async-openai.
Related Issues (20)
- Embedding deserialization error when using encoding_format `EncodingFormat::Base64`
- Ollama AI Chat Completion Example / OpenAI Compatibility HOT 3
- Sync OpenAPI spec changes after 4th Jan 24 HOT 1
- Initialize `Client` with custom HTTP client, config, and backoff HOT 3
- Usage of std::thread::sleep inside async function in assistants example HOT 1
- Add retry on 504 Gateway Time-out and "connection closed before message completed" HOT 5
- Missing fields in `CreateTranscriptionResponse` HOT 2
- Supporting streams when running assistants HOT 3
- Set OPENAI_API_BASE to environment variable HOT 1
- Open
- Deserialize error when retrieve content HOT 2
- Failing to deserialize API response when translating audio with SRT output HOT 5
- &chat_choice.delta.function_call in the function-call-stream example has been deprecated HOT 2
- How to call async function through function-call HOT 2
- The type of messages in deserialized CreateChatCompletionRequest are all SystemMessage HOT 5
- 【help】Could you please give me an example of defining multiple functions? HOT 4
- assistants header HOT 1
- Spec sync May 2024
- Running the `assistants` example results in Error HOT 4
- Wrong type of function tools in Assistant
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from async-openai.