mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-08-22 23:25:39 +00:00
v2.1.0
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "openai-api-rs"
|
name = "openai-api-rs"
|
||||||
version = "2.0.5"
|
version = "2.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Dongri Jin <dongrify@gmail.com>"]
|
authors = ["Dongri Jin <dongrify@gmail.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -7,7 +7,7 @@ Check out the [docs.rs](https://docs.rs/openai-api-rs/).
|
|||||||
Cargo.toml
|
Cargo.toml
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
openai-api-rs = "2.0.5"
|
openai-api-rs = "2.1.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -33,8 +33,9 @@ let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
|||||||
### Create request
|
### Create request
|
||||||
```rust
|
```rust
|
||||||
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest};
|
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest};
|
||||||
|
use openai_api_rs::v1::common::GPT4;
|
||||||
let req = ChatCompletionRequest::new(
|
let req = ChatCompletionRequest::new(
|
||||||
chat_completion::GPT4.to_string(),
|
GPT4.to_string(),
|
||||||
vec![chat_completion::ChatCompletionMessage {
|
vec![chat_completion::ChatCompletionMessage {
|
||||||
role: chat_completion::MessageRole::user,
|
role: chat_completion::MessageRole::user,
|
||||||
content: String::from("Hello OpenAI!"),
|
content: String::from("Hello OpenAI!"),
|
||||||
@ -52,12 +53,13 @@ println!("{:?}", result.choices[0].text);
|
|||||||
```rust
|
```rust
|
||||||
use openai_api_rs::v1::api::Client;
|
use openai_api_rs::v1::api::Client;
|
||||||
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest};
|
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest};
|
||||||
|
use openai_api_rs::v1::common::GPT4;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
||||||
let req = ChatCompletionRequest::new(
|
let req = ChatCompletionRequest::new(
|
||||||
chat_completion::GPT4.to_string(),
|
GPT4.to_string(),
|
||||||
vec
|
- [x] [Fine-tunes](https://platform.openai.com/docs/api-reference/fine-tunes)
|
||||||
- [x] [Moderations](https://platform.openai.com/docs/api-reference/moderations)
|
- [x] [Moderations](https://platform.openai.com/docs/api-reference/moderations)
|
||||||
- [x] [Function calling](https://platform.openai.com/docs/guides/gpt/function-calling)
|
- [x] [Function calling](https://platform.openai.com/docs/guides/gpt/function-calling)
|
||||||
|
- [x] [Assistants](https://platform.openai.com/docs/assistants/overview)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This project is licensed under [MIT license](https://github.com/dongri/openai-api-rs/blob/main/LICENSE).
|
This project is licensed under [MIT license](https://github.com/dongri/openai-api-rs/blob/main/LICENSE).
|
||||||
|
Reference in New Issue
Block a user