
Several cleanups: - Flesh out the README - Make the interface a little easier to use - Add some examples - Add some (sparse) documentation for public components - Mark the `FinishReason` and `Engine` enums as non-exhaustive so new members can be added in the future without breaking backwards compatibility
15 lines
404 B
Rust
15 lines
404 B
Rust
///! Example that prints out a story from a prompt. Used in the readme.
|
|
use openai_api::OpenAIClient;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let api_token = std::env::var("OPENAI_SK").unwrap();
|
|
let client = OpenAIClient::new(&api_token);
|
|
let prompt = String::from("Once upon a time,");
|
|
println!(
|
|
"{}{}",
|
|
prompt,
|
|
client.complete(prompt.as_str()).await.unwrap()
|
|
);
|
|
}
|