Skip to content

Commit 4442a44

Browse files
committed
upstream sync 0.23.1
2 parents 1fa18fc + 5c9c817 commit 4442a44

File tree

11 files changed

+153
-36
lines changed

11 files changed

+153
-36
lines changed

async-openai-wasm/src/audio.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
},
1313
};
1414

15-
/// Turn audio into text
15+
/// Turn audio into text or text into audio.
1616
/// Related guide: [Speech to text](https://platform.openai.com/docs/guides/speech-to-text)
1717
pub struct Audio<'c, C: Config> {
1818
client: &'c Client<C>,
@@ -69,6 +69,16 @@ impl<'c, C: Config> Audio<'c, C> {
6969
self.client.post_form("/audio/translations", request).await
7070
}
7171

72+
/// Transcribes audio into the input language.
73+
pub async fn translate_raw(
74+
&self,
75+
request: CreateTranslationRequest,
76+
) -> Result<Bytes, OpenAIError> {
77+
self.client
78+
.post_form_raw("/audio/translations", request)
79+
.await
80+
}
81+
7282
/// Generates audio from the input text.
7383
pub async fn speech(
7484
&self,

async-openai-wasm/src/types/chat.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,10 @@ pub struct CreateChatCompletionRequest {
483483
#[serde(skip_serializing_if = "Option::is_none")]
484484
pub tool_choice: Option<ChatCompletionToolChoiceOption>,
485485

486+
/// Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use.
487+
#[serde(skip_serializing_if = "Option::is_none")]
488+
pub parallel_tool_calls: Option<bool>,
489+
486490
/// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids).
487491
#[serde(skip_serializing_if = "Option::is_none")]
488492
pub user: Option<String>,

async-openai-wasm/src/types/message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
55

66
use crate::error::OpenAIError;
77

8-
use super::{AssistantToolsFileSearch, ImageDetail, ImageUrl};
8+
use super::{ImageDetail, ImageUrl};
99

1010
#[derive(Clone, Serialize, Debug, Deserialize, PartialEq, Default)]
1111
#[serde(rename_all = "lowercase")]
@@ -94,7 +94,7 @@ pub struct MessageAttachment {
9494
#[serde(rename_all = "snake_case")]
9595
pub enum MessageAttachmentTool {
9696
CodeInterpreter,
97-
FileSearch(AssistantToolsFileSearch),
97+
FileSearch,
9898
}
9999

100100
#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]

async-openai-wasm/src/types/run.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ pub struct RunObject {
7979

8080
pub tool_choice: Option<AssistantsApiToolChoiceOption>,
8181

82+
/// Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use.
83+
pub parallel_tool_calls: bool,
84+
8285
pub response_format: Option<AssistantsApiResponseFormatOption>,
8386
}
8487

@@ -224,6 +227,9 @@ pub struct CreateRunRequest {
224227

225228
pub tool_choice: Option<AssistantsApiToolChoiceOption>,
226229

230+
/// Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use.
231+
pub parallel_tool_calls: Option<bool>,
232+
227233
pub response_format: Option<AssistantsApiResponseFormatOption>,
228234
}
229235

async-openai-wasm/src/types/thread.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ pub struct CreateThreadAndRunRequest {
125125
#[serde(skip_serializing_if = "Option::is_none")]
126126
pub tool_choice: Option<AssistantsApiToolChoiceOption>,
127127

128+
/// Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use.
129+
#[serde(skip_serializing_if = "Option::is_none")]
130+
pub parallel_tool_calls: Option<bool>,
131+
128132
#[serde(skip_serializing_if = "Option::is_none")]
129133
pub response_format: Option<AssistantsApiResponseFormatOption>,
130134
}

async-openai-wasm/src/types/vector_store.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct VectorStoreObject {
6363
/// The Unix timestamp (in seconds) for when the vector store was created.
6464
pub created_at: u32,
6565
/// The name of the vector store.
66-
pub name: String,
66+
pub name: Option<String>,
6767
/// The total number of bytes used by the files in the vector store.
6868
pub usage_bytes: u64,
6969
pub file_counts: VectorStoreFileCounts,
@@ -192,7 +192,9 @@ pub enum VectorStoreFileErrorCode {
192192
pub enum VectorStoreFileObjectChunkingStrategy {
193193
/// This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
194194
Other,
195-
Static(StaticChunkingStrategy),
195+
Static {
196+
r#static: StaticChunkingStrategy,
197+
},
196198
}
197199

198200
#[derive(Debug, Serialize, Default, Clone, Builder, PartialEq)]

async-openai-wasm/src/vector_store_files.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,59 @@ impl<'c, C: Config> VectorStoreFiles<'c, C> {
7575
.await
7676
}
7777
}
78+
79+
#[cfg(test)]
80+
mod tests {
81+
use crate::types::{
82+
CreateFileRequest, CreateVectorStoreFileRequest, CreateVectorStoreRequest, FileInput,
83+
FilePurpose,
84+
};
85+
use crate::Client;
86+
87+
#[tokio::test]
88+
async fn vector_store_file_creation_and_deletion(
89+
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
90+
let client = Client::new();
91+
92+
// Create a file
93+
let file_handle = client
94+
.files()
95+
.create(CreateFileRequest {
96+
file: FileInput::from_vec_u8(
97+
String::from("meow.txt"),
98+
String::from(":3").into_bytes(),
99+
),
100+
purpose: FilePurpose::Assistants,
101+
})
102+
.await?;
103+
104+
// Create a vector store
105+
let vector_store_handle = client
106+
.vector_stores()
107+
.create(CreateVectorStoreRequest {
108+
file_ids: Some(vec![file_handle.id.clone()]),
109+
name: None,
110+
expires_after: None,
111+
chunking_strategy: None,
112+
metadata: None,
113+
})
114+
.await?;
115+
let vector_store_file = client
116+
.vector_stores()
117+
.files(&vector_store_handle.id)
118+
.retrieve(&file_handle.id)
119+
.await?;
120+
121+
assert_eq!(vector_store_file.id, file_handle.id);
122+
// Delete the vector store
123+
client
124+
.vector_stores()
125+
.delete(&vector_store_handle.id)
126+
.await?;
127+
128+
// Delete the file
129+
client.files().delete(&file_handle.id).await?;
130+
131+
Ok(())
132+
}
133+
}

async-openai/Cargo.toml

Whitespace-only changes.

examples/assistants-file-search/src/main.rs

Whitespace-only changes.

examples/audio-translate/src/main.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)