Crates.io | gpt3_rs |
lib.rs | gpt3_rs |
version | 0.3.4 |
source | src |
created_at | 2022-05-10 16:55:46.455855 |
updated_at | 2022-06-26 10:08:31.776005 |
description | An API wrapper for OpenAi's gpt-3 |
homepage | |
repository | https://github.com/Sleepy-Kitten/gpt3_rs |
max_upload_size | |
id | 584086 |
size | 70,817 |
gpt3_rs is a rust library for interacting with OpenAi's gpt3
use gpt3_rs::{Client, api::*, Model};
#[tokio::main]
async fn main() {
let token = std::env::var("GPT_API_TOKEN").unwrap();
let client = Client::new(token);
let request = completions::Builder::default()
.model(Model::Babbage)
.prompt("what is 1 + 2?")
.build()
.unwrap();
let response = request.request(&client).await.unwrap();
let answer = &response.choices[0].text;
println!("{answer}");
}
use gpt3_rs::{Client, api::*, Model};
#[tokio::main]
async fn main() {
let token = std::env::var("GPT_API_TOKEN").unwrap();
let client = Client::new(token);
let request = classification::Builder::default()
.model(Model::Curie)
.search_model(Model::Ada)
.query("It is a rainy day :(")
.examples(&[
&["A happy moment", "Positive"],
&["I am sad.", "Negative"],
&["I am feeling awesome", "Positive"]
])
.labels(&["Positive", "Negative", "Neutral"])
.build()
.unwrap();
let response = request.request(&client).await.unwrap();
let answer = &response.choices[0].text;
println!("{answer}");
}