Struct openai_gpt_rs::args::EditArgs
source · pub struct EditArgs {
pub model: String,
pub input: String,
pub instruction: String,
pub n: usize,
pub temperature: f64,
pub top_p: f64,
}
Fields§
§model: String
§input: String
§instruction: String
§n: usize
§temperature: f64
§top_p: f64
Implementations§
source§impl EditArgs
impl EditArgs
sourcepub fn model(&mut self, model: EditModels) -> &mut Self
pub fn model(&mut self, model: EditModels) -> &mut Self
Set the model to use for the edit
Examples found in repository?
examples/edit.rs (line 27)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
async fn main() {
let mut prompt = String::new();
let mut instruction = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
print!("Enter the instruction: ");
let _ = stdout().flush();
stdin().read_line(&mut instruction).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_edit(|args| {
args.input(prompt)
.instruction(instruction)
.model(EditModels::TextDavinciEdit1)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let text = resp.get_content(0).unwrap();
println!("{}", text);
}
sourcepub fn input<T>(&mut self, input: T) -> &mut Selfwhere
T: ToString,
pub fn input<T>(&mut self, input: T) -> &mut Selfwhere T: ToString,
Set the input for the edit
Examples found in repository?
examples/edit.rs (line 25)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
async fn main() {
let mut prompt = String::new();
let mut instruction = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
print!("Enter the instruction: ");
let _ = stdout().flush();
stdin().read_line(&mut instruction).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_edit(|args| {
args.input(prompt)
.instruction(instruction)
.model(EditModels::TextDavinciEdit1)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let text = resp.get_content(0).unwrap();
println!("{}", text);
}
sourcepub fn instruction<T>(&mut self, instruction: T) -> &mut Selfwhere
T: ToString,
pub fn instruction<T>(&mut self, instruction: T) -> &mut Selfwhere T: ToString,
Set the instruction for the edit
Examples found in repository?
examples/edit.rs (line 26)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
async fn main() {
let mut prompt = String::new();
let mut instruction = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
print!("Enter the instruction: ");
let _ = stdout().flush();
stdin().read_line(&mut instruction).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_edit(|args| {
args.input(prompt)
.instruction(instruction)
.model(EditModels::TextDavinciEdit1)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let text = resp.get_content(0).unwrap();
println!("{}", text);
}
sourcepub fn n(&mut self, n: usize) -> &mut Self
pub fn n(&mut self, n: usize) -> &mut Self
Set the number of edits to return
Examples found in repository?
examples/edit.rs (line 28)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
async fn main() {
let mut prompt = String::new();
let mut instruction = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
print!("Enter the instruction: ");
let _ = stdout().flush();
stdin().read_line(&mut instruction).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_edit(|args| {
args.input(prompt)
.instruction(instruction)
.model(EditModels::TextDavinciEdit1)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let text = resp.get_content(0).unwrap();
println!("{}", text);
}
sourcepub fn temperature(&mut self, temperature: f64) -> &mut Self
pub fn temperature(&mut self, temperature: f64) -> &mut Self
Set the temperature for the edit
Examples found in repository?
examples/edit.rs (line 29)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
async fn main() {
let mut prompt = String::new();
let mut instruction = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
print!("Enter the instruction: ");
let _ = stdout().flush();
stdin().read_line(&mut instruction).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_edit(|args| {
args.input(prompt)
.instruction(instruction)
.model(EditModels::TextDavinciEdit1)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let text = resp.get_content(0).unwrap();
println!("{}", text);
}
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for EditArgs
impl Send for EditArgs
impl Sync for EditArgs
impl Unpin for EditArgs
impl UnwindSafe for EditArgs
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