pub struct CompletionRequest {Show 16 fields
pub model: Model,
pub prompt: String,
pub suffix: Option<String>,
pub max_tokens: Option<i32>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub n: Option<i32>,
pub stream: Option<bool>,
pub logprobs: Option<i32>,
pub echo: Option<bool>,
pub stop: Option<Vec<String>>,
pub presence_penalty: Option<f32>,
pub frequency_penalty: Option<f32>,
pub best_of: Option<i32>,
pub logit_bias: Option<HashMap<String, i32>>,
pub user: Option<String>,
}
Expand description
Represents a request to generate text completions.
Fields§
§model: Model
Model to be used for generating completions.
prompt: String
Prompt for generating the completions.
suffix: Option<String>
Optional suffix that comes after the generated text.
max_tokens: Option<i32>
Optional maximum number of tokens to generate.
temperature: Option<f32>
Optional temperature setting for sampling.
top_p: Option<f32>
Optional top-p setting for nucleus sampling.
n: Option<i32>
Optional number of completions to generate.
stream: Option<bool>
Optional flag to stream the completions.
logprobs: Option<i32>
Optional number of log probabilities to return.
echo: Option<bool>
Optional flag to echo the prompt in the response.
stop: Option<Vec<String>>
Optional sequences where the generation will stop.
presence_penalty: Option<f32>
Optional penalty for presence of tokens.
frequency_penalty: Option<f32>
Optional penalty for frequency of tokens.
best_of: Option<i32>
Optional number of best completions to return.
logit_bias: Option<HashMap<String, i32>>
Optional bias for log probabilities of specific tokens.
user: Option<String>
Optional user identifier.
Implementations§
Source§impl CompletionRequest
impl CompletionRequest
Sourcepub fn new(model: Model, prompt: String) -> Self
pub fn new(model: Model, prompt: String) -> Self
Creates a new CompletionRequest
with the specified model and prompt.
Examples found in repository?
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let client = Client::from_env().unwrap();
10
11 let req = CompletionRequest::new(
12 Model::GPT3(GPT3::GPT35Turbo),
13 String::from("What is Bitcoin?"),
14 )
15 .max_tokens(3000)
16 .temperature(0.9)
17 .top_p(1.0)
18 .stop(vec![String::from(" Human:"), String::from(" AI:")])
19 .presence_penalty(0.6)
20 .frequency_penalty(0.0);
21
22 let result = client.completion(req).await?;
23 println!("{:}", result.choices[0].text);
24
25 Ok(())
26}
Source§impl CompletionRequest
impl CompletionRequest
Sourcepub fn max_tokens(self, max_tokens: i32) -> Self
pub fn max_tokens(self, max_tokens: i32) -> Self
Sets the value of the specified field.
Examples found in repository?
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let client = Client::from_env().unwrap();
10
11 let req = CompletionRequest::new(
12 Model::GPT3(GPT3::GPT35Turbo),
13 String::from("What is Bitcoin?"),
14 )
15 .max_tokens(3000)
16 .temperature(0.9)
17 .top_p(1.0)
18 .stop(vec![String::from(" Human:"), String::from(" AI:")])
19 .presence_penalty(0.6)
20 .frequency_penalty(0.0);
21
22 let result = client.completion(req).await?;
23 println!("{:}", result.choices[0].text);
24
25 Ok(())
26}
Sourcepub fn temperature(self, temperature: f32) -> Self
pub fn temperature(self, temperature: f32) -> Self
Sets the value of the specified field.
Examples found in repository?
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let client = Client::from_env().unwrap();
10
11 let req = CompletionRequest::new(
12 Model::GPT3(GPT3::GPT35Turbo),
13 String::from("What is Bitcoin?"),
14 )
15 .max_tokens(3000)
16 .temperature(0.9)
17 .top_p(1.0)
18 .stop(vec![String::from(" Human:"), String::from(" AI:")])
19 .presence_penalty(0.6)
20 .frequency_penalty(0.0);
21
22 let result = client.completion(req).await?;
23 println!("{:}", result.choices[0].text);
24
25 Ok(())
26}
Sourcepub fn top_p(self, top_p: f32) -> Self
pub fn top_p(self, top_p: f32) -> Self
Sets the value of the specified field.
Examples found in repository?
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let client = Client::from_env().unwrap();
10
11 let req = CompletionRequest::new(
12 Model::GPT3(GPT3::GPT35Turbo),
13 String::from("What is Bitcoin?"),
14 )
15 .max_tokens(3000)
16 .temperature(0.9)
17 .top_p(1.0)
18 .stop(vec![String::from(" Human:"), String::from(" AI:")])
19 .presence_penalty(0.6)
20 .frequency_penalty(0.0);
21
22 let result = client.completion(req).await?;
23 println!("{:}", result.choices[0].text);
24
25 Ok(())
26}
Sourcepub fn stop(self, stop: Vec<String>) -> Self
pub fn stop(self, stop: Vec<String>) -> Self
Sets the value of the specified field.
Examples found in repository?
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let client = Client::from_env().unwrap();
10
11 let req = CompletionRequest::new(
12 Model::GPT3(GPT3::GPT35Turbo),
13 String::from("What is Bitcoin?"),
14 )
15 .max_tokens(3000)
16 .temperature(0.9)
17 .top_p(1.0)
18 .stop(vec![String::from(" Human:"), String::from(" AI:")])
19 .presence_penalty(0.6)
20 .frequency_penalty(0.0);
21
22 let result = client.completion(req).await?;
23 println!("{:}", result.choices[0].text);
24
25 Ok(())
26}
Sourcepub fn presence_penalty(self, presence_penalty: f32) -> Self
pub fn presence_penalty(self, presence_penalty: f32) -> Self
Sets the value of the specified field.
Examples found in repository?
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let client = Client::from_env().unwrap();
10
11 let req = CompletionRequest::new(
12 Model::GPT3(GPT3::GPT35Turbo),
13 String::from("What is Bitcoin?"),
14 )
15 .max_tokens(3000)
16 .temperature(0.9)
17 .top_p(1.0)
18 .stop(vec![String::from(" Human:"), String::from(" AI:")])
19 .presence_penalty(0.6)
20 .frequency_penalty(0.0);
21
22 let result = client.completion(req).await?;
23 println!("{:}", result.choices[0].text);
24
25 Ok(())
26}
Sourcepub fn frequency_penalty(self, frequency_penalty: f32) -> Self
pub fn frequency_penalty(self, frequency_penalty: f32) -> Self
Sets the value of the specified field.
Examples found in repository?
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let client = Client::from_env().unwrap();
10
11 let req = CompletionRequest::new(
12 Model::GPT3(GPT3::GPT35Turbo),
13 String::from("What is Bitcoin?"),
14 )
15 .max_tokens(3000)
16 .temperature(0.9)
17 .top_p(1.0)
18 .stop(vec![String::from(" Human:"), String::from(" AI:")])
19 .presence_penalty(0.6)
20 .frequency_penalty(0.0);
21
22 let result = client.completion(req).await?;
23 println!("{:}", result.choices[0].text);
24
25 Ok(())
26}
Sourcepub fn logit_bias(self, logit_bias: HashMap<String, i32>) -> Self
pub fn logit_bias(self, logit_bias: HashMap<String, i32>) -> Self
Sets the value of the specified field.
Trait Implementations§
Source§impl Clone for CompletionRequest
impl Clone for CompletionRequest
Source§fn clone(&self) -> CompletionRequest
fn clone(&self) -> CompletionRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more