-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dongri Jin
committed
Mar 2, 2023
1 parent
6c80991
commit 6a68775
Showing
13 changed files
with
290 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "openai-api-rs" | ||
version = "0.1.1" | ||
version = "0.1.2" | ||
edition = "2021" | ||
authors = ["Dongri Jin <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use openai_api_rs::v1::api::Client; | ||
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest}; | ||
use std::env; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string()); | ||
let req = ChatCompletionRequest { | ||
model: chat_completion::GPT3_5_TURBO.to_string(), | ||
messages: vec![chat_completion::ChatCompletionMessage { | ||
role: chat_completion::MessageRole::user, | ||
content: String::from("NFTとは?"), | ||
}], | ||
}; | ||
let result = client.chat_completion(req).await?; | ||
println!("{:?}", result.choices[0].message.content); | ||
|
||
Ok(()) | ||
} | ||
|
||
// OPENAI_API_KEY=xxxx cargo run --package openai-api-rs --example chat_completion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.