Struct openai_gpt_rs::args::CompletionArgs
source · pub struct CompletionArgs {
pub prompt: String,
pub model: String,
pub suffix: String,
pub max_tokens: u32,
pub n: usize,
pub temperature: f64,
}
Fields§
§prompt: String
§model: String
§suffix: String
§max_tokens: u32
§n: usize
§temperature: f64
Implementations§
source§impl CompletionArgs
impl CompletionArgs
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 completion
Examples found in repository?
examples/completion.rs (line 19)
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
async fn main() {
let mut prompt = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_completion(|args| {
args.prompt(prompt)
.model(CompletionModels::TextDavinci3)
.max_tokens(32)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let completion = resp.get_content(0).unwrap();
println!("{}", completion);
}
sourcepub fn model(&mut self, model: CompletionModels) -> &mut Self
pub fn model(&mut self, model: CompletionModels) -> &mut Self
Set the model to use for the completion
Examples found in repository?
examples/completion.rs (line 20)
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
async fn main() {
let mut prompt = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_completion(|args| {
args.prompt(prompt)
.model(CompletionModels::TextDavinci3)
.max_tokens(32)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let completion = resp.get_content(0).unwrap();
println!("{}", completion);
}
sourcepub fn suffix<T>(&mut self, suffix: T) -> &mut Selfwhere
T: ToString,
pub fn suffix<T>(&mut self, suffix: T) -> &mut Selfwhere T: ToString,
Set the suffix for the completion
sourcepub fn max_tokens(&mut self, max_tokens: u32) -> &mut Self
pub fn max_tokens(&mut self, max_tokens: u32) -> &mut Self
Set the maximum number of tokens for the completion
Examples found in repository?
examples/completion.rs (line 21)
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
async fn main() {
let mut prompt = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_completion(|args| {
args.prompt(prompt)
.model(CompletionModels::TextDavinci3)
.max_tokens(32)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let completion = resp.get_content(0).unwrap();
println!("{}", completion);
}
sourcepub fn n(&mut self, n: usize) -> &mut Self
pub fn n(&mut self, n: usize) -> &mut Self
Set the number of completions to return
Examples found in repository?
examples/completion.rs (line 22)
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
async fn main() {
let mut prompt = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_completion(|args| {
args.prompt(prompt)
.model(CompletionModels::TextDavinci3)
.max_tokens(32)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let completion = resp.get_content(0).unwrap();
println!("{}", completion);
}
sourcepub fn temperature(&mut self, temperature: f64) -> &mut Self
pub fn temperature(&mut self, temperature: f64) -> &mut Self
Set the temperature for the completion
Examples found in repository?
examples/completion.rs (line 23)
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
async fn main() {
let mut prompt = String::new();
print!("Enter a prompt: ");
let _ = stdout().flush();
stdin().read_line(&mut prompt).unwrap();
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().as_str());
let resp = client
.create_completion(|args| {
args.prompt(prompt)
.model(CompletionModels::TextDavinci3)
.max_tokens(32)
.n(1)
.temperature(1.0)
})
.await
.unwrap();
let completion = resp.get_content(0).unwrap();
println!("{}", completion);
}
Trait Implementations§
source§impl Debug for CompletionArgs
impl Debug for CompletionArgs
Auto Trait Implementations§
impl RefUnwindSafe for CompletionArgs
impl Send for CompletionArgs
impl Sync for CompletionArgs
impl Unpin for CompletionArgs
impl UnwindSafe for CompletionArgs
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