openai-chat

Crates.ioopenai-chat
lib.rsopenai-chat
version0.1.1
sourcesrc
created_at2023-03-07 07:01:05.05578
updated_at2023-03-16 03:36:55.401465
descriptionchatgpt api
homepage
repositoryhttps://github.com/dobefore/chatgpt-api-rs
max_upload_size
id803357
size58,877
(dobefore)

documentation

https://docs.rs/chatgpt_api/

README

wrapper for official openai api for chatgpt in Rust.

Currently support models text-davinci-003 and gpt-3.5-turbo.

Todo: [ ] context dialog

use model text-davinci-003

use std::env;
use chatgpt_api::completions;

#[actix_rt::main]
async fn main() {
    let api_key = env::var("OPEN_AI_API_KEY").expect("OPEN_AI_API_KEY must be set");
let _ret=completions("how are you", &api_key).await.unwrap();

}

and gpt-3.5-turbo

use std::env;
use chatgpt_api::chat_completions;
    let api_key = env::var("OPEN_AI_API_KEY").expect("OPEN_AI_API_KEY must be set");
async fn gpt35_turbo() {
    let api_key = env::var("OPEN_AI_API_KEY").expect("OPEN_AI_API_KEY must be set");
    let _ret=chat_completions("how are you", &api_key).await;
}
Commit count: 8

cargo fmt