From 1ed1f923767450ef9b49bd48a704ed2b3926a2ad Mon Sep 17 00:00:00 2001 From: Himanshu Neema Date: Sun, 19 Oct 2025 18:14:44 -0700 Subject: [PATCH 1/5] fix compilation --- examples/assistants-file-search/src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/assistants-file-search/src/main.rs b/examples/assistants-file-search/src/main.rs index 11770d6b..06e3434b 100644 --- a/examples/assistants-file-search/src/main.rs +++ b/examples/assistants-file-search/src/main.rs @@ -38,6 +38,7 @@ async fn main() -> Result<(), Box> { .create(CreateFileRequest { file: "./input/uber-10k.pdf".into(), purpose: FilePurpose::Assistants, + expires_after: None, }) .await?; @@ -84,6 +85,7 @@ async fn main() -> Result<(), Box> { .create(CreateFileRequest { file: "./input/lyft-10k.pdf".into(), purpose: FilePurpose::Assistants, + expires_after: None, }) .await?; From 685923129f9cc94a2527986ac0140d89a225cd31 Mon Sep 17 00:00:00 2001 From: Himanshu Neema Date: Sun, 19 Oct 2025 18:21:13 -0700 Subject: [PATCH 2/5] add github workflow for compilation and fmt checks --- .github/workflows/pr-checks.yml | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/pr-checks.yml diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml new file mode 100644 index 00000000..6446bfb3 --- /dev/null +++ b/.github/workflows/pr-checks.yml @@ -0,0 +1,43 @@ +name: PR Checks + +on: + pull_request: + types: [opened, synchronize, reopened] + pull_request_target: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build Workspace + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + override: true + + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Build workspace + run: cargo build --workspace --verbose + + - name: Check formatting + run: cargo fmt --all -- --check + + # - name: Run clippy + # run: cargo clippy --workspace -- -D warnings From 4d2bd7cb2e7cc0bdd9e1f84060fcf450b7e2d35f Mon Sep 17 00:00:00 2001 From: Himanshu Neema Date: Sun, 19 Oct 2025 18:21:30 -0700 Subject: [PATCH 3/5] cargo fmt --- async-openai/src/error.rs | 5 +---- async-openai/src/file.rs | 7 +++++-- async-openai/src/types/file.rs | 2 +- async-openai/src/types/impls.rs | 11 ++++++----- examples/responses/src/main.rs | 5 ++++- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/async-openai/src/error.rs b/async-openai/src/error.rs index 3a82d132..a6fd6ae2 100644 --- a/async-openai/src/error.rs +++ b/async-openai/src/error.rs @@ -82,10 +82,7 @@ pub struct WrappedError { pub(crate) fn map_deserialization_error(e: serde_json::Error, bytes: &[u8]) -> OpenAIError { let json_content = String::from_utf8_lossy(bytes); - tracing::error!( - "failed deserialization of: {}", - json_content - ); + tracing::error!("failed deserialization of: {}", json_content); OpenAIError::JSONDeserialize(e, json_content.to_string()) } diff --git a/async-openai/src/file.rs b/async-openai/src/file.rs index b8b1ed81..4ec33880 100644 --- a/async-openai/src/file.rs +++ b/async-openai/src/file.rs @@ -70,7 +70,7 @@ impl<'c, C: Config> Files<'c, C> { #[cfg(test)] mod tests { use crate::{ - types::{CreateFileRequestArgs, FilePurpose, FileExpiresAfter, FileExpiresAfterAnchor}, + types::{CreateFileRequestArgs, FileExpiresAfter, FileExpiresAfterAnchor, FilePurpose}, Client, }; @@ -89,7 +89,10 @@ mod tests { let request = CreateFileRequestArgs::default() .file(test_file_path) .purpose(FilePurpose::FineTune) - .expires_after(FileExpiresAfter{ anchor: FileExpiresAfterAnchor::CreatedAt, seconds: 3600 }) + .expires_after(FileExpiresAfter { + anchor: FileExpiresAfterAnchor::CreatedAt, + seconds: 3600, + }) .build() .unwrap(); diff --git a/async-openai/src/types/file.rs b/async-openai/src/types/file.rs index ebd90a83..89e3d25f 100644 --- a/async-openai/src/types/file.rs +++ b/async-openai/src/types/file.rs @@ -23,7 +23,7 @@ pub enum FilePurpose { pub enum FileExpiresAfterAnchor { #[default] #[serde(rename = "created_at")] - CreatedAt + CreatedAt, } #[derive(Debug, Default, Clone, PartialEq)] diff --git a/async-openai/src/types/impls.rs b/async-openai/src/types/impls.rs index d11bf604..af559127 100644 --- a/async-openai/src/types/impls.rs +++ b/async-openai/src/types/impls.rs @@ -27,9 +27,9 @@ use super::{ ChatCompletionRequestUserMessageContentPart, ChatCompletionToolChoiceOption, CreateFileRequest, CreateImageEditRequest, CreateImageVariationRequest, CreateMessageRequestContent, CreateSpeechResponse, CreateTranscriptionRequest, CreateTranslationRequest, DallE2ImageSize, - EmbeddingInput, FileInput, FilePurpose, FunctionName, Image, ImageInput, ImageModel, - ImageResponseFormat, ImageSize, ImageUrl, ImagesResponse, ModerationInput, Prompt, Role, Stop, - TimestampGranularity, FileExpiresAfterAnchor + EmbeddingInput, FileExpiresAfterAnchor, FileInput, FilePurpose, FunctionName, Image, + ImageInput, ImageModel, ImageResponseFormat, ImageSize, ImageUrl, ImagesResponse, + ModerationInput, Prompt, Role, Stop, TimestampGranularity, }; /// for `impl_from!(T, Enum)`, implements @@ -985,9 +985,10 @@ impl AsyncTryFrom for reqwest::multipart::Form { let mut form = reqwest::multipart::Form::new() .part("file", file_part) .text("purpose", request.purpose.to_string()); - + if let Some(expires_after) = request.expires_after { - form = form.text("expires_after[anchor]", expires_after.anchor.to_string()) + form = form + .text("expires_after[anchor]", expires_after.anchor.to_string()) .text("expires_after[seconds]", expires_after.seconds.to_string()); } Ok(form) diff --git a/examples/responses/src/main.rs b/examples/responses/src/main.rs index cffefe3d..47395185 100644 --- a/examples/responses/src/main.rs +++ b/examples/responses/src/main.rs @@ -2,7 +2,10 @@ use std::error::Error; use async_openai::{ types::responses::{ - AllowedTools, CreateResponseArgs, Input, InputItem, InputMessageArgs, McpArgs, RequireApproval, RequireApprovalPolicy, Role, TextConfig, ToolDefinition::{Mcp, WebSearchPreview}, Verbosity, WebSearchPreviewArgs + AllowedTools, CreateResponseArgs, Input, InputItem, InputMessageArgs, McpArgs, + RequireApproval, RequireApprovalPolicy, Role, TextConfig, + ToolDefinition::{Mcp, WebSearchPreview}, + Verbosity, WebSearchPreviewArgs, }, Client, }; From 4a0508f706e871f71d87893e18120b1b56b02364 Mon Sep 17 00:00:00 2001 From: Himanshu Neema Date: Sun, 19 Oct 2025 18:23:51 -0700 Subject: [PATCH 4/5] remove unused stuff --- async-openai/src/client.rs | 2 +- async-openai/src/error.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/async-openai/src/client.rs b/async-openai/src/client.rs index 42b7f662..28d6c3d4 100644 --- a/async-openai/src/client.rs +++ b/async-openai/src/client.rs @@ -487,7 +487,7 @@ async fn map_stream_error(value: EventSourceError) -> OpenAIError { "Unreachable because read_response returns err when status_code {status_code} is invalid" )) } - _ => OpenAIError::StreamError(StreamError::ReqwestEventSource(value.into())), + _ => OpenAIError::StreamError(StreamError::ReqwestEventSource(value)), } } diff --git a/async-openai/src/error.rs b/async-openai/src/error.rs index a6fd6ae2..288d198b 100644 --- a/async-openai/src/error.rs +++ b/async-openai/src/error.rs @@ -1,7 +1,5 @@ //! Errors originating from API calls, parsing responses, and reading-or-writing to the file system. -use std::string::FromUtf8Error; -use reqwest::{header::HeaderValue, Response}; use serde::{Deserialize, Serialize}; #[derive(Debug, thiserror::Error)] From eb7869e54fb6ad14dce655972762dd5e6e09b74e Mon Sep 17 00:00:00 2001 From: Himanshu Neema Date: Sun, 19 Oct 2025 18:27:59 -0700 Subject: [PATCH 5/5] fix compilation --- examples/assistants-code-interpreter/src/main.rs | 1 + examples/vector-store-retrieval/src/main.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/examples/assistants-code-interpreter/src/main.rs b/examples/assistants-code-interpreter/src/main.rs index bee370dc..d82aa85e 100644 --- a/examples/assistants-code-interpreter/src/main.rs +++ b/examples/assistants-code-interpreter/src/main.rs @@ -28,6 +28,7 @@ async fn main() -> Result<(), Box> { .create(CreateFileRequest { file: "./input/CASTHPI.csv".into(), purpose: FilePurpose::Assistants, + expires_after: None, }) .await?; diff --git a/examples/vector-store-retrieval/src/main.rs b/examples/vector-store-retrieval/src/main.rs index 9867144f..90b0dee7 100644 --- a/examples/vector-store-retrieval/src/main.rs +++ b/examples/vector-store-retrieval/src/main.rs @@ -21,6 +21,7 @@ async fn main() -> Result<(), Box> { .create(CreateFileRequest { file: "./input/uber-10k.pdf".into(), purpose: FilePurpose::Assistants, + expires_after: None, }) .await?; @@ -29,6 +30,7 @@ async fn main() -> Result<(), Box> { .create(CreateFileRequest { file: "./input/lyft-10k.pdf".into(), purpose: FilePurpose::Assistants, + expires_after: None, }) .await?;