chore: update examples

This commit is contained in:
Anush008
2023-08-25 17:29:36 +05:30
parent ffe2bd49be
commit f453dc9323
5 changed files with 15 additions and 20 deletions

View File

@ -2,8 +2,7 @@ use openai_api_rs::v1::api::Client;
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest};
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
let req = ChatCompletionRequest {
model: chat_completion::GPT4.to_string(),
@ -26,7 +25,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
logit_bias: None,
user: None,
};
let result = client.chat_completion(req).await?;
let result = client.chat_completion(req)?;
println!("{:?}", result.choices[0].message.content);
Ok(())
}