Struct openai_gpt_rs::args::ImageArgs
source · pub struct ImageArgs {
pub prompt: String,
pub n: usize,
pub size: String,
pub response_format: String,
}
Fields§
§prompt: String
§n: usize
§size: String
§response_format: String
Implementations§
source§impl ImageArgs
impl ImageArgs
sourcepub fn prompt<T>(&mut self, prompt: T) -> &mut Selfwhere
T: ToString,
pub fn prompt<T>(&mut self, prompt: T) -> &mut Selfwhere T: ToString,
Set the prompt for the image
Examples found in repository?
examples/image.rs (line 19)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn main() {
let mut prompt = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
println!("Generating image...\n");
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_image(|args| args.prompt(prompt).size(ImageSize::Medium).n(1))
.await
.unwrap();
let url = resp.get_content(0).unwrap();
println!("Url: {}", url);
}
sourcepub fn n(&mut self, n: usize) -> &mut Self
pub fn n(&mut self, n: usize) -> &mut Self
Set the number of images to return
Examples found in repository?
examples/image.rs (line 19)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn main() {
let mut prompt = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
println!("Generating image...\n");
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_image(|args| args.prompt(prompt).size(ImageSize::Medium).n(1))
.await
.unwrap();
let url = resp.get_content(0).unwrap();
println!("Url: {}", url);
}
sourcepub fn size(&mut self, size: ImageSize) -> &mut Self
pub fn size(&mut self, size: ImageSize) -> &mut Self
Set the size of the images to return
Examples found in repository?
examples/image.rs (line 19)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
async fn main() {
let mut prompt = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
println!("Generating image...\n");
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_image(|args| args.prompt(prompt).size(ImageSize::Medium).n(1))
.await
.unwrap();
let url = resp.get_content(0).unwrap();
println!("Url: {}", url);
}
sourcepub fn response_format(
&mut self,
response_format: ImageResponseFormat
) -> &mut Self
pub fn response_format( &mut self, response_format: ImageResponseFormat ) -> &mut Self
Set the response format for the images to return
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for ImageArgs
impl Send for ImageArgs
impl Sync for ImageArgs
impl Unpin for ImageArgs
impl UnwindSafe for ImageArgs
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