Skip to content

Commit 6174180

Browse files
authored
Merge branch '64bit:main' into main
2 parents 47ff5ee + de53c00 commit 6174180

File tree

25 files changed

+3176
-996
lines changed

25 files changed

+3176
-996
lines changed

async-openai/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "async-openai"
3-
version = "0.28.1"
3+
version = "0.28.2"
44
authors = ["Himanshu Neema"]
55
categories = ["api-bindings", "web-programming", "asynchronous"]
66
keywords = ["openai", "async", "openapi", "ai"]

async-openai/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- [x] Moderations
3737
- [x] Organizations | Administration (partially implemented)
3838
- [x] Realtime (Beta) (partially implemented)
39+
- [x] Responses (partially implemented)
3940
- [x] Uploads
4041
- Bring your own custom types for Request or Response objects.
4142
- SSE streaming on available APIs

async-openai/src/client.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
moderation::Moderations,
1515
traits::AsyncTryFrom,
1616
Assistants, Audio, AuditLogs, Batches, Chat, Completions, Embeddings, FineTuning, Invites,
17-
Models, Projects, Threads, Uploads, Users, VectorStores,
17+
Models, Projects, Responses, Threads, Uploads, Users, VectorStores,
1818
};
1919

2020
#[derive(Debug, Clone, Default)]
@@ -162,6 +162,11 @@ impl<C: Config> Client<C> {
162162
Projects::new(self)
163163
}
164164

165+
/// To call [Responses] group related APIs using this client.
166+
pub fn responses(&self) -> Responses<C> {
167+
Responses::new(self)
168+
}
169+
165170
pub fn config(&self) -> &C {
166171
&self.config
167172
}
@@ -341,7 +346,12 @@ impl<C: Config> Client<C> {
341346
let message: String = String::from_utf8_lossy(&bytes).into_owned();
342347
tracing::warn!("Server error: {status} - {message}");
343348
return Err(backoff::Error::Transient {
344-
err: OpenAIError::ApiError(ApiError { message, r#type: None, param: None, code: None }),
349+
err: OpenAIError::ApiError(ApiError {
350+
message,
351+
r#type: None,
352+
param: None,
353+
code: None,
354+
}),
345355
retry_after: None,
346356
});
347357
}

async-openai/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ mod project_api_keys;
146146
mod project_service_accounts;
147147
mod project_users;
148148
mod projects;
149+
mod responses;
149150
mod runs;
150151
mod steps;
151152
mod threads;
@@ -178,6 +179,7 @@ pub use project_api_keys::ProjectAPIKeys;
178179
pub use project_service_accounts::ProjectServiceAccounts;
179180
pub use project_users::ProjectUsers;
180181
pub use projects::Projects;
182+
pub use responses::Responses;
181183
pub use runs::Runs;
182184
pub use steps::Steps;
183185
pub use threads::Threads;

async-openai/src/responses.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use crate::{
2+
config::Config,
3+
error::OpenAIError,
4+
types::responses::{CreateResponse, Response},
5+
Client,
6+
};
7+
8+
/// Given text input or a list of context items, the model will generate a response.
9+
///
10+
/// Related guide: [Responses API](https://platform.openai.com/docs/guides/responses)
11+
pub struct Responses<'c, C: Config> {
12+
client: &'c Client<C>,
13+
}
14+
15+
impl<'c, C: Config> Responses<'c, C> {
16+
/// Constructs a new Responses client.
17+
pub fn new(client: &'c Client<C>) -> Self {
18+
Self { client }
19+
}
20+
21+
/// Creates a model response for the given input.
22+
#[crate::byot(
23+
T0 = serde::Serialize,
24+
R = serde::de::DeserializeOwned
25+
)]
26+
pub async fn create(&self, request: CreateResponse) -> Result<Response, OpenAIError> {
27+
self.client.post("/responses", request).await
28+
}
29+
}

async-openai/src/types/audio.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,16 @@ pub struct CreateSpeechRequest {
188188
/// One of the available [TTS models](https://platform.openai.com/docs/models/tts): `tts-1` or `tts-1-hd`
189189
pub model: SpeechModel,
190190

191-
/// The voice to use when generating the audio. Supported voices are `alloy`, `ash`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`.
191+
/// The voice to use when generating the audio. Supported voices are `alloy`, `ash`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer` and `verse`.
192+
192193
/// Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
193194
pub voice: Voice,
194195

196+
/// Control the voice of your generated audio with additional instructions.
197+
/// Does not work with `tts-1` or `tts-1-hd`.
198+
#[serde(skip_serializing_if = "Option::is_none")]
199+
pub instructions: Option<String>,
200+
195201
/// The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
196202
#[serde(skip_serializing_if = "Option::is_none")]
197203
pub response_format: Option<SpeechResponseFormat>,

0 commit comments

Comments
 (0)