Add chat gpt api

This commit is contained in:
Dongri Jin
2023-03-02 12:20:01 +09:00
parent 6c809911f4
commit 6a68775555
13 changed files with 290 additions and 191 deletions

View File

@ -1,5 +1,5 @@
use openai_api_rs::v1::completion::{self, CompletionRequest};
use openai_api_rs::v1::api::Client;
use openai_api_rs::v1::completion::{self, CompletionRequest};
use std::env;
#[tokio::main]
@ -22,11 +22,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
best_of: None,
logit_bias: None,
user: None,
};
};
let result = client.completion(req).await?;
println!("{:}", result.choices[0].text);
Ok(())
}
// cargo run --package openai-rs --example completion
// OPENAI_API_KEY=xxxx cargo run --package openai-api-rs --example completion