dont change UploadedOpenAiFile shape

This commit is contained in:
colby-oai
2026-04-29 10:17:04 -04:00
parent 2c7598fb66
commit 7c7a417118

View File

@@ -27,7 +27,7 @@ pub struct UploadedOpenAiFile {
pub file_name: String,
pub file_size_bytes: u64,
pub mime_type: Option<String>,
pub path: Option<PathBuf>,
pub path: PathBuf,
}
#[derive(Debug, thiserror::Error)]
@@ -140,7 +140,7 @@ pub async fn upload_local_file(
file_name,
metadata.len(),
reqwest::Body::wrap_stream(ReaderStream::new(upload_file)),
Some(path.to_path_buf()),
path.to_path_buf(),
)
.await
}
@@ -152,13 +152,14 @@ pub async fn upload_file_bytes(
contents: Vec<u8>,
) -> Result<UploadedOpenAiFile, OpenAiFileError> {
let file_size_bytes = contents.len() as u64;
let source_path = PathBuf::from(file_name.clone());
upload_file_body_with_source_path(
base_url,
auth,
file_name,
file_size_bytes,
reqwest::Body::from(contents),
/*source_path*/ None,
source_path,
)
.await
}
@@ -169,13 +170,11 @@ async fn upload_file_body_with_source_path(
file_name: String,
file_size_bytes: u64,
body: reqwest::Body,
source_path: Option<PathBuf>,
source_path: PathBuf,
) -> Result<UploadedOpenAiFile, OpenAiFileError> {
if file_size_bytes > OPENAI_FILE_UPLOAD_LIMIT_BYTES {
return Err(OpenAiFileError::FileTooLarge {
path: source_path
.clone()
.unwrap_or_else(|| PathBuf::from(file_name.clone())),
path: source_path.clone(),
size_bytes: file_size_bytes,
limit_bytes: OPENAI_FILE_UPLOAD_LIMIT_BYTES,
});