4 个稳定版本
1.1.3 | 2023年7月7日 |
---|---|
1.1.0 | 2023年7月4日 |
1.0.5 |
|
1.0.1 |
|
#451 in 机器学习
每月47次下载
96KB
1.5K SLoC
OpenAI Rust Api
OpenAI 的非官方 API 客户端
core
模块的使用示例
聊天完成
use openai_rs_api::core::models::chat::{ChatParameters, ChatResponse, Message};
use openai_rs_api::core::OpenAI;
#[tokio::main]
async fn main() {
let oai = OpenAI::new("API_KEY".to_string(), "API_ORG".to_string());
let parameters = ChatParameters::new(
"gpt-3.5-turbo-16k".to_string(),
vec![Message {
role: "user".to_string(),
content: Some("Hello, my name is".to_string()),
name: None,
function_call: None,
}],
);
let response: ChatResponse = oai.create_chat_completions(parameters).await.unwrap();
// print answer message
if let Some(content) = &response.choices.get(0).unwrap().message.content {
println!("{}", content);
}
}
依赖关系
~21–35MB
~669K SLoC