pub struct FileUploadBuilder { /* private fields */ }Expand description
Builder for file upload operations.
This builder provides a fluent interface for uploading files to OpenAI
with specified purposes and metadata.
Implementations§
Source§impl FileUploadBuilder
impl FileUploadBuilder
Sourcepub fn new(
filename: impl Into<String>,
purpose: FilePurpose,
content: Vec<u8>,
) -> Self
pub fn new( filename: impl Into<String>, purpose: FilePurpose, content: Vec<u8>, ) -> Self
Create a new file upload builder with file content and purpose.
§Examples
use openai_ergonomic::builders::files::{FileUploadBuilder, FilePurpose};
let content = b"Hello, world!";
let builder = FileUploadBuilder::new("hello.txt", FilePurpose::Assistants, content.to_vec());Sourcepub fn from_path(
path: impl AsRef<Path>,
purpose: FilePurpose,
) -> Result<Self, Error>
pub fn from_path( path: impl AsRef<Path>, purpose: FilePurpose, ) -> Result<Self, Error>
Create a file upload builder from a file path.
This is a convenience method that reads the file from disk. Note: This is a sync operation and will read the entire file into memory.
Sourcepub fn from_text(
filename: impl Into<String>,
purpose: FilePurpose,
text: impl Into<String>,
) -> Self
pub fn from_text( filename: impl Into<String>, purpose: FilePurpose, text: impl Into<String>, ) -> Self
Create a file upload builder from text content.
Sourcepub fn from_json(
filename: impl Into<String>,
purpose: FilePurpose,
json: &Value,
) -> Result<Self, Error>
pub fn from_json( filename: impl Into<String>, purpose: FilePurpose, json: &Value, ) -> Result<Self, Error>
Create a file upload builder from JSON content.
Sourcepub fn purpose(&self) -> &FilePurpose
pub fn purpose(&self) -> &FilePurpose
Get the purpose for this upload.
Sourcepub fn content_size(&self) -> usize
pub fn content_size(&self) -> usize
Get the size of the content in bytes.
Sourcepub fn content_as_string(&self) -> Option<String>
pub fn content_as_string(&self) -> Option<String>
Get the content as a string (if it’s valid UTF-8).
Trait Implementations§
Source§impl Clone for FileUploadBuilder
impl Clone for FileUploadBuilder
Source§fn clone(&self) -> FileUploadBuilder
fn clone(&self) -> FileUploadBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FileUploadBuilder
impl RefUnwindSafe for FileUploadBuilder
impl Send for FileUploadBuilder
impl Sync for FileUploadBuilder
impl Unpin for FileUploadBuilder
impl UnwindSafe for FileUploadBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more