chatgpt_blocking_rs

Crates.iochatgpt_blocking_rs
lib.rschatgpt_blocking_rs
version0.1.2
sourcesrc
created_at2023-03-28 15:28:49.111959
updated_at2024-04-29 10:15:49.579817
descriptionBlocking ChatGPT API Wrapper
homepage
repositoryhttps://github.com/Hyde46/chatgpt_rs_blocking
max_upload_size
id823177
size14,916
Denis (Hyde46)

documentation

README

ChatGPT-rs-blocking

Fork of Async chatgpt_rs I needed a blocking variation of this without reqwest

Usage

Here is a simple usage of the API, getting completion for a single message. You can see more practical examples in the examples directory.

use chatgpt::prelude::*;

async fn main() -> Result<()> {
    // Getting the API key here
    let key = args().nth(1).unwrap();

    /// Creating a new ChatGPT client.
    /// Note that it requires an API key, and uses
    /// tokens from your OpenAI API account balance.
    let client = ChatGPT::new(key)?;

    /// Sending a message and getting the completion
    let response: CompletionResponse = client
        .send_message("Describe in five words the Rust programming language.")
        .unwrap();

    println!("Response: {}", response.message().content);

    Ok(())
}
Commit count: 0

cargo fmt