3 个版本
0.1.2 | 2024年4月29日 |
---|---|
0.1.1 | 2023年7月25日 |
0.1.0 | 2023年3月28日 |
#2 在 #chat-gpt
33 每月下载次数
用于 hoard-rs
14KB
201 行
ChatGPT-rs-blocking
Async ChatGPT_rs 的分支,我需要一个没有 reqwest 的阻塞版本
使用方法
以下是 API 的简单使用示例,获取单个消息的完成内容。您可以在 examples
目录中查看更多实用示例。
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(())
}
依赖项
~16–28MB
~548K SLoC